From b77d708e541b3c740deb219b4e03ffed4e454373 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Mon, 16 Aug 2021 21:07:46 -0700 Subject: Cleanup the cleanup function :) --- smart-documents.org | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'smart-documents.org') diff --git a/smart-documents.org b/smart-documents.org index f5b49dd..17cf199 100644 --- a/smart-documents.org +++ b/smart-documents.org @@ -507,27 +507,12 @@ documents. #+END_SRC -*** Indent buffer +*** Clean up buffer -Indent buffer in every mode. +Clean up buffer in every mode. #+BEGIN_SRC emacs-lisp :tangle yes - (global-set-key [f12] - '(lambda () - "Clean up buffer in the most general sense. - This means indenting the buffer according to the major mode in force, - as well as deleting trailing whitespaces." - (interactive) - (sd-indent-buffer) - (delete-trailing-whitespace))) -#+END_SRC - -*** TODO Beautify Org mode buffer - -Not only indent, but also clean up superfluous newlines. - -#+BEGIN_SRC emacs-lisp :tangle yes - (local-set-key [f12] 'sd-org-beautify) + (global-set-key [f12] 'sd-beautify-buffer) #+END_SRC * Packages @@ -1427,9 +1412,9 @@ PDF. The binding is defined in Section [[Export to PDF]]. major-mode))))) #+END_SRC -** Beautify buffer +** Whole buffer -Binding defined in Section [[Indent buffer]]. +*** Indent #+BEGIN_SRC emacs-lisp :tangle yes (defun sd-indent-buffer () @@ -1439,15 +1424,26 @@ Binding defined in Section [[Indent buffer]]. (indent-region (point-min) (point-max) nil))) #+END_SRC +*** Beautify + #+BEGIN_SRC emacs-lisp :tangle yes - (defun sd-org-beautify () - "Beautify Org mode buffer." + (defun sd-beautify-buffer () + "Clean up buffer in the most general sense. + + This means performing the following actions: + 1) indenting the buffer according to the major mode in force, + 2) deleting trailing whitespaces. + + As well as a couple other things." (interactive) - (when (eq major-mode 'org-mode) - (sd-indent-buffer))) + (sd-indent-buffer) + (delete-trailing-whitespace)) #+END_SRC -** Smart window quitting + +** Smart quitting + +*** Window #+BEGIN_SRC emacs-lisp :tangle yes (defun sd-delete-window-or-previous-buffer () @@ -1458,7 +1454,7 @@ Binding defined in Section [[Indent buffer]]. (previous-buffer))) #+END_SRC -** Smart frame quitting +*** Frame #+BEGIN_SRC emacs-lisp :tangle yes (defun sd-delete-frame-or-kill-emacs () -- cgit v1.2.3