mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
editor/format: don't move cursor on save
This commit is contained in:
@ -217,3 +217,14 @@ is selected)."
|
||||
(if (use-region-p)
|
||||
(+format-region beg end)
|
||||
(format-all-buffer)))
|
||||
|
||||
|
||||
;;
|
||||
;; Hooks
|
||||
;;
|
||||
|
||||
;;;###autoload
|
||||
(defun +format|on-save ()
|
||||
"Runs `format-all-buffer' without moving the cursor."
|
||||
(save-excursion
|
||||
(format-all-buffer)))
|
||||
|
@ -26,7 +26,7 @@ control which major modes to target."
|
||||
((not (memq major-mode +format-on-save-enabled-modes))))
|
||||
(not (require 'format-all nil t))
|
||||
(not (format-all-probe)))
|
||||
(format-all-mode +1)))
|
||||
(add-hook 'before-save-hook #'+format|on-save)))
|
||||
|
||||
(when (featurep! +onsave)
|
||||
(add-hook 'after-change-major-mode-hook #'+format|enable-on-save-maybe))
|
||||
|
Reference in New Issue
Block a user