Add function to format org files

Change default line numbers to be relative
This commit is contained in:
Emma Turner
2026-02-27 16:12:11 -07:00
parent 8f50408300
commit a014d30451
2 changed files with 21 additions and 7 deletions

View File

@@ -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))
)