diff options
-rw-r--r-- | smart-documents.org | 26 |
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 |