editor/format: add +format-type letvar
In case we need a conditional to test against in our formatters. e.g. in go-mode, goimports is incompatible with partial formatting, so we force it to use gofmt in that case.
This commit is contained in:
parent
e0f8325f45
commit
c52d2a5a14
1 changed files with 6 additions and 1 deletions
|
@ -1,5 +1,9 @@
|
||||||
;;; editor/format/autoload.el -*- lexical-binding: t; -*-
|
;;; editor/format/autoload.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
(defvar +format-type 'buffer
|
||||||
|
"A symbol representing whether the buffer or a region of it is being
|
||||||
|
formatted. Can be 'buffer or 'region.")
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(autoload 'format-all-probe "format-all")
|
(autoload 'format-all-probe "format-all")
|
||||||
|
|
||||||
|
@ -184,7 +188,8 @@ snippets or single lines."
|
||||||
(interactive "rP")
|
(interactive "rP")
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(narrow-to-region beg end)
|
(narrow-to-region beg end)
|
||||||
(+format/buffer arg)))
|
(let ((+format-type 'region))
|
||||||
|
(+format/buffer arg))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +format/region-or-buffer (beg end &optional arg)
|
(defun +format/region-or-buffer (beg end &optional arg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue