summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2021-08-21 22:13:36 -0700
committerMarius Peter <marius.peter@tutanota.com>2021-08-21 22:13:36 -0700
commit35ac6222ea2b5763859c9a35fac412dfa13c1d8e (patch)
treefa7dac4fa8ac97ebb7bded9d6b73e42571ae37fc
parent746a442bda79016ab94c1c9451a6b33938b43b69 (diff)
Buffer beautification.
-rw-r--r--smart-documents.org26
1 files changed, 23 insertions, 3 deletions
diff --git a/smart-documents.org b/smart-documents.org
index 71404ea..1736c30 100644
--- a/smart-documents.org
+++ b/smart-documents.org
@@ -1463,9 +1463,9 @@ PDF. The binding is defined in Section [[Export to PDF]].
major-mode)))))
#+END_SRC
-** Whole buffer
+** Operate on whole buffer
-*** Indent
+*** Fix indentation
#+BEGIN_SRC emacs-lisp :tangle yes
(defun sd-indent-buffer ()
@@ -1477,6 +1477,8 @@ PDF. The binding is defined in Section [[Export to PDF]].
*** Beautify
+**** All types of buffers
+
#+BEGIN_SRC emacs-lisp :tangle yes
(defun sd-beautify-buffer ()
"Clean up buffer in the most general sense.
@@ -1488,9 +1490,27 @@ PDF. The binding is defined in Section [[Export to PDF]].
As well as a couple other things."
(interactive)
(sd-indent-buffer)
- (delete-trailing-whitespace))
+ (delete-trailing-whitespace)
+ (when (string-equal
+ major-mode "org-mode")
+ (sd-org-fix-headlines-spacing)))
+
+
#+END_SRC
+**** COMMENT For Org mode, specifically
+
+#+BEGIN_SRC emacs-lisp :tangle yes
+ (defun sd-org-fix-headlines-spacing ()
+ "Insert the proper amount of newlines between Org headlines."
+ (save-excursion
+ (progn
+ (goto-char (point-min))
+ (mark-whole-buffer)
+ (delete-blank-lines)
+ (org-next-visible-heading)
+ (re-search-backward "^$")))
+#+END_SRC
** Smart quitting
Copyright 2019--2024 Marius PETER