docs(format): revise docstrings and comments

This commit is contained in:
Henrik Lissner 2024-07-07 20:41:03 -04:00
parent 9224ac56f0
commit d648bfda40
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -27,10 +27,10 @@
;; possible, in case the formatter is an elisp function, like `gofmt'. ;; possible, in case the formatter is an elisp function, like `gofmt'.
(cl-loop for (var . val) (cl-loop for (var . val)
in (cl-remove-if-not #'listp (buffer-local-variables cur-buffer)) in (cl-remove-if-not #'listp (buffer-local-variables cur-buffer))
;; Making enable-multibyte-characters buffer-local causes an ;; `enable-multibyte-characters' can change how Emacs reads the
;; error. ;; buffer's contents (or writes them to the formatters), which
;; can cause errors.
unless (eq var 'enable-multibyte-characters) unless (eq var 'enable-multibyte-characters)
;; Using setq-local would quote var.
do (set (make-local-variable var) val)) do (set (make-local-variable var) val))
;; ;;
(insert-buffer-substring-no-properties cur-buffer start end) (insert-buffer-substring-no-properties cur-buffer start end)
@ -66,18 +66,17 @@
;;;###autoload ;;;###autoload
(defun +format/region (beg end &optional _arg) (defun +format/region (beg end &optional _arg)
"Runs the active formatter on the lines within BEG and END. "Format the selected region.
WARNING: this may not work everywhere. It will throw errors if the region WARNING: if the formatter doesn't support partial formatting, this command tries
contains a syntax error in isolation. It is mostly useful for formatting to pretend the active selection is the contents of a standalone file, but this
snippets or single lines." may not always work. Keep your undo keybind handy!"
(interactive "rP") (interactive "rP")
(+format-region beg end)) (+format-region beg end))
;;;###autoload ;;;###autoload
(defun +format/region-or-buffer () (defun +format/region-or-buffer ()
"Runs the active formatter on the selected region (or whole buffer, if nothing "Format the selected region, or whole buffer if nothing is selected."
is selected)."
(interactive) (interactive)
(call-interactively (call-interactively
(if (doom-region-active-p) (if (doom-region-active-p)