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:
Julian Mutter 2023-12-03 19:55:06 +01:00
parent f47ecce302
commit 4cc2834027
2 changed files with 10 additions and 20 deletions

View File

@ -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)

View File

@ -56,7 +56,7 @@
(evil +everywhere); come to the dark side, we have cookies
file-templates ; auto-snippets for empty files
fold ; (nigh) universal code folding
format ;+onsave) ; automated prettiness
(format +onsave) ; automated prettiness
;;god ; run Emacs commands without modifier keys
;; lispy ; vim for lisp, for people who don't like vim
;;multiple-cursors ; editing in many places at once
@ -151,7 +151,7 @@
;;lua ; one-based indices? one-based indices
markdown ; writing docs for people to ignore
;;nim ; python + lisp at the speed of c
nix ; I hereby declare "nix geht mehr!"
(nix +lsp) ; I hereby declare "nix geht mehr!"
;;ocaml ; an objective camel
(org +dragndrop +pandoc +pretty +roam2 +pomodoro +noter) ; organize your plain life in plain text
;;php ; perl's insecure younger brother