editor/format: don't move cursor on save
This commit is contained in:
parent
af045213e3
commit
f1460ff592
2 changed files with 12 additions and 1 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue