emacs: improve format on save function

This commit is contained in:
Julian Mutter 2023-09-17 19:32:59 +02:00
parent c21d249e75
commit 1fe29f7da0

View File

@ -60,9 +60,20 @@
(interactive)
(company-abort)
(evil-force-normal-state)
(+format/buffer)
(without-minibuffer '+format/buffer) ; Skip if no formatter is defined (e.g. in text mode)
(save-buffer))
(defmacro without-minibuffer (&rest body)
"Like `progn', but stop and return nil if any of BODY forms tries to use the minibuffer.
Also disable dialogs while evaluating BODY forms, since dialogs
are just an alternative to the minibuffer."
`(catch 'tried-to-use-minibuffer
(minibuffer-with-setup-hook
(lambda (&rest args) (throw 'tried-to-use-minibuffer nil))
(let ((use-dialog-box)) ; No cheating by using dialogs instead of minibuffer
,@body))))
;; Do not ask before exiting emacs
(setq confirm-kill-emacs nil)
#+end_src