Add function to format org files
Change default line numbers to be relative
This commit is contained in:
22
config.el
22
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))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user