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:
Henrik Lissner 2018-09-10 08:22:42 -04:00
parent e0f8325f45
commit c52d2a5a14
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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)