emacs: improve format on save function
This commit is contained in:
parent
c21d249e75
commit
1fe29f7da0
@ -60,9 +60,20 @@
|
|||||||
(interactive)
|
(interactive)
|
||||||
(company-abort)
|
(company-abort)
|
||||||
(evil-force-normal-state)
|
(evil-force-normal-state)
|
||||||
(+format/buffer)
|
(without-minibuffer '+format/buffer) ; Skip if no formatter is defined (e.g. in text mode)
|
||||||
(save-buffer))
|
(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
|
;; Do not ask before exiting emacs
|
||||||
(setq confirm-kill-emacs nil)
|
(setq confirm-kill-emacs nil)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
Loading…
x
Reference in New Issue
Block a user