From 658ba299ba5ea74f5944318797021a9920d037e2 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Wed, 8 Feb 2023 21:05:57 -0500 Subject: [PATCH] cleanup open new line and indent --- global.org | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/global.org b/global.org index dfb5afe..a3fe802 100644 --- a/global.org +++ b/global.org @@ -462,13 +462,19 @@ #+end_src ** Smart open-line #+begin_src emacs-lisp - (defun open-line-and-indent () - (interactive) - (save-excursion (newline-and-indent)) - (indent-line)) + (defun open-line-and-indent (arg) + (interactive "*p") + (save-excursion + (newline-and-indent) + (skip-chars-forward "[:blank:]") + (when (eolp) + (let ((e (point)) + (b (progn (beginning-of-line) (point)))) + (delete-region b e)))) + (funcall indent-line-function)) (global-set-key (kbd "C-o") #'open-line-and-indent) - #+end_src + #+end_src ** Whitespace Trailing whitespace is evil; get rid of it unless we are in special modes, namely calendar (and later mu4e)