From a014d30451f9d39e2a33d12e305272e95e1155cd Mon Sep 17 00:00:00 2001 From: Emma Turner Date: Fri, 27 Feb 2026 16:12:11 -0700 Subject: [PATCH] Add function to format org files Change default line numbers to be relative --- config.el | 22 +++++++++++++++++++++- custom.el | 6 ------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/config.el b/config.el index ff36c20..8ac6313 100644 --- a/config.el +++ b/config.el @@ -40,7 +40,8 @@ ;; This determines the style of line numbers in effect. If set to `nil', line ;; numbers are disabled. For relative line numbers, set this to `relative'. -(setq display-line-numbers-type t) +;; (setq display-line-numbers-type t) +(setq display-line-numbers-type 'relative) ;; If you use `org' and don't want your org files in the default location below, ;; change `org-directory'. It must be set before org loads! @@ -138,3 +139,22 @@ (append exec-path (split-string (getenv "PATH") path-separator t))))) (setenv "PATH" (mapconcat 'identity (delete-dups path) path-separator)))) + +;; Based off https://github.com/alphapapa/unpackaged.el#ensure-blank-lines-between-headings-and-before-contents +;;;###autoload +(defun org-format (&optional prefix) + "Ensure blank lines exist after each org entry (before each heading). +With prefix, operate on whole buffer" + (interactive "P") + (org-map-entries (lambda () + (let ((end (org-entry-end-position))) + (goto-char end) + (unless (string-equal (string (char-before)) "\n") + ;; Insert blank line after entry end + (insert "\n")) + ) + ) + t (if prefix + nil + 'tree)) + ) diff --git a/custom.el b/custom.el index c76ae2a..44d2759 100644 --- a/custom.el +++ b/custom.el @@ -15,9 +15,3 @@ ("csh" . sh) ("ksh88" . sh) ("oash" . sh) ("pdksh" . sh) ("mksh" . sh) ("posix" . sh) ("wksh" . sh) ("wsh" . sh) ("zsh" . sh) ("cs" . csharp) ("rpm" . sh)))) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - )