Minor, general refactor & comment revision
This commit is contained in:
parent
33ae889e39
commit
84fd744e3f
5 changed files with 10 additions and 13 deletions
|
@ -16,14 +16,14 @@ Irrelevant if you do not have the +onsave flag enabled for this module.")
|
|||
"If non-nil, the leading indentation is preserved when formatting the whole
|
||||
buffer. This is particularly useful for partials.
|
||||
|
||||
Indentation is always preserved when formatting regions. ")
|
||||
Indentation is always preserved when formatting regions.")
|
||||
|
||||
(defvar-local +format-with nil
|
||||
"Set this to explicitly use a certain formatter for the current buffer.")
|
||||
|
||||
|
||||
;;
|
||||
;; Bootstrap
|
||||
;;; Bootstrap
|
||||
|
||||
(defun +format|enable-on-save-maybe ()
|
||||
"Enable formatting on save in certain major modes.
|
||||
|
@ -43,16 +43,14 @@ This is controlled by `+format-on-save-enabled-modes'."
|
|||
|
||||
|
||||
;;
|
||||
;; Hacks
|
||||
;;; Hacks
|
||||
|
||||
;; Allow a specific formatter to be used by setting `+format-with', either
|
||||
;; buffer-locally or let-bound.
|
||||
(advice-add #'format-all--probe :around #'+format*probe)
|
||||
|
||||
;; Doom uses a modded `format-all-buffer', which
|
||||
;; 1. Doesn't move the cursorafter reformatting,
|
||||
;; 2. Can reformat regions, rather than the entire buffer (while preserving
|
||||
;; leading indentation),
|
||||
;; 3. Applies changes via RCS patch, line by line, as not to protect buffer
|
||||
;; markers and avoid any jarring cursor+window scrolling.
|
||||
;; 1. Enables partial reformatting (while preserving leading indentation),
|
||||
;; 2. Applies changes via RCS patch, line by line, to protect buffer markers
|
||||
;; and avoid any jarring cursor+window scrolling.
|
||||
(advice-add #'format-all-buffer :override #'+format/buffer)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue