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 ;; 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'. ;; 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, ;; 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! ;; change `org-directory'. It must be set before org loads!
@@ -138,3 +139,22 @@
(append exec-path (append exec-path
(split-string (getenv "PATH") path-separator t))))) (split-string (getenv "PATH") path-separator t)))))
(setenv "PATH" (mapconcat 'identity (delete-dups path) path-separator)))) (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))
)

View File

@@ -15,9 +15,3 @@
("csh" . sh) ("ksh88" . sh) ("oash" . sh) ("pdksh" . sh) ("mksh" . sh) ("csh" . sh) ("ksh88" . sh) ("oash" . sh) ("pdksh" . sh) ("mksh" . sh)
("posix" . sh) ("wksh" . sh) ("wsh" . sh) ("zsh" . sh) ("cs" . csharp) ("posix" . sh) ("wksh" . sh) ("wsh" . sh) ("zsh" . sh) ("cs" . csharp)
("rpm" . sh)))) ("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.
)