editor/reformat: refactor & fixes

+ Change +format-type to +format-region-p (now a boolean)
+ Add PRESERVE-INDENT-P boolean argument to +format-buffer
+ Add +format-preserve-indentation variable (only controls indent
  preservation during +format/buffer, not +format/region, where it's
  always enabled).
+ Fix error arising from +format|buffer hook when no formatter is
  defined for the current mode #893
+ Change +format|buffer to alias for +format/buffer.
This commit is contained in:
Henrik Lissner 2018-09-18 13:14:39 -04:00
parent f4e119a642
commit 6a44cf0124
3 changed files with 74 additions and 61 deletions

View file

@ -15,7 +15,7 @@
;; Redefines default formatter to *not* use goimports if reformatting a
;; region; as it doesn't play well with partial code.
(set-formatter! 'gofmt
'(("%s" (if (or (eq +format-type 'region)
'(("%s" (if (or +format-region-p
(not (executable-find "goimports")))
"gofmt"
"goimports"))))