Make +format-buffer copy all buffer-local variables from the original buffer into the temporary buffer. When resolving a symbol inside of a formatter, the value it is bound to in the formatted buffer will now be used instead of the default value. Fixes#2036.
Currently `+format-completing-read` returns a cons cell like `(symbol . t)`, where `+format/buffer` expects a symbol. This commit makes `+format-completing-read` return a symbol instead. Fixes#2349.
The fix for #1489 (in 13f5a762) gives the temp buffer (where formatting
is performed) a real buffer-file-name, which causes it to prompt to save
it when it is killed.
:feature was a "catch-all" category. Many of its modules fit better in
other categories, so they've been moved:
- feature/debugger -> tools/debugger
- feature/evil -> editor/evil
- feature/eval -> tools/eval
- feature/lookup -> tools/lookup
- feature/snippets -> editor/snippets
- feature/file-templates -> editor/file-templates
- feature/workspaces -> ui/workspaces
More potential changes in the future:
- A new :term category for terminal emulation modules (eshell, term and
vterm).
- A new :os category for modules dedicated to os-specific functionality.
The :tools macos module would fit here, but so would modules for nixos
and arch.
- A new :services category for web-service integration, like wakatime,
twitter, elfeed, gist and pastebin services.
In +format--set:
../modules/editor/format/autoload/settings.el:81:26:Warning: ‘error’ called
with 0 args to fill 1 format field(s)
Signed-off-by: Edwin Török <edwin@etorok.net>
+ 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.
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.
+ First argument is no longer a major mode or list thereof, it is NAME.
Use :modes instead.
+ Updated docstring & examples.
+ Added formatting unsetting: (set-formatter! 'some-formatter nil)
+ A formatter can now be specified explicitly buffer-locally by setting
+format-with to a symbol representing the name of the
formatter (accepts any key of format-all-format-table)
+ Passing C-u to any of +format/buffer, +format/region or
+format/region-or-buffer will now prompt you to select a formatter.
+ Revise docstring for +format-on-save-enabled-modes
General code and comment improvements.
Also, removed the :desc's for csv-mode because map! is currently unable
to set which-key descriptions mode-locally, and should be avoided for
anything but global keybinds. This will be fixed when General is
introduced into Doom.
+ Updated docstring (and added two more examples)
+ Can now be used with shell command strings or string lists. String
sublists can have more than 2 elements. Non-string items will be
interpolated into the string before it. If any non-string item is nil,
its sublist is omitted entirely.
+ Can now be used to redefine formatters predefined by the format-all
package, by passing the formatter's name (as a symbol) as the first
argument.
+ Added :modes property for cases when first argument isn't a major mode
or list of them (when redefining a formatter).
This redesigns how format-all applies changes. Before, it would erase
the buffer and insert the formatted result. This would throw markers out
of whack, and usually meant the cursor would end up somewhere else (e.g.
the beginning of the file).
Now, changes are made to the buffer line by line, via RCS patch.
Other changes:
+ +format-region function was removed (replaced by +format-buffer and
+format/region).
+ set-formatter! was moved to autoload/settings.el
+ New +format/buffer command to replace format-all-buffer
This is much too unpredictable, considering the variable nature of elisp
indentation, and the possibility that certain functions and their indent
behavior may not be defined/declared when the file is being formatted.
Also renames +format|on-save to +format|buffer for clarity. It should
not (normally) be used directly. Use `+format|enable-on-save-maybe` and
`+format|enable-on-save`.