Fix autoformat in org mode opening dialogue
Now every saving by default formats the buffer, only using :w skips that
This commit is contained in:
@ -43,10 +43,13 @@
|
||||
(map! :desc "Flycheck previous error" :nv "g N" #'flycheck-previous-error)
|
||||
(map! :leader "c X" #'flycheck-list-errors)
|
||||
|
||||
(map! :desc "Format and save" :g "C-s" #'fd-format-and-save)
|
||||
(map! :desc "Save" :g "C-s" #'save-buffer)
|
||||
(map! :leader "w 1" #'delete-other-windows)
|
||||
(map! :leader "t p" #'+popup/toggle)
|
||||
|
||||
;; Do not use autosave when using vim save command
|
||||
(evil-ex-define-cmd "write" #'fd-format-without-autosave)
|
||||
|
||||
(dotimes (counter 9)
|
||||
(let ((command (format "(map! :leader \"%d\" #'winum-select-window-%d)"
|
||||
(1+ counter) (1+ counter))))
|
||||
@ -56,24 +59,11 @@
|
||||
|
||||
(setq-default evil-escape-key-sequence "kj")
|
||||
|
||||
(defun fd-format-and-save()
|
||||
(defun fd-format-without-autosave()
|
||||
(interactive)
|
||||
(company-abort)
|
||||
(evil-force-normal-state)
|
||||
;; (without-minibuffer '+format/buffer) ; Skip if no formatter is defined (e.g. in text mode)
|
||||
(+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))))
|
||||
(let ((current-prefix-arg 4)) ;; pass universal argument
|
||||
(call-interactively #'save-buffer))
|
||||
)
|
||||
|
||||
;; Do not ask before exiting emacs
|
||||
(setq confirm-kill-emacs nil)
|
||||
|
Reference in New Issue
Block a user