editor/format: fix +format/region-or-buffer

The `r` interactive spec barfs an error if no mark is active, preventing
this function from ever calling `+format/buffer`.

Reported by @amosbird
This commit is contained in:
Henrik Lissner 2019-04-02 00:51:29 -04:00
parent 3eaa57c747
commit 5c3188afd5
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -204,13 +204,14 @@ snippets or single lines."
(+format/buffer arg))))
;;;###autoload
(defun +format/region-or-buffer (beg end &optional arg)
(defun +format/region-or-buffer ()
"Runs the active formatter on the selected region (or whole buffer, if nothing
is selected)."
(interactive "rP")
(interactive)
(call-interactively
(if (use-region-p)
(+format/region beg end arg)
(call-interactively #'+format/buffer)))
#'+format/region
#'+format/buffer)))
;;