Commit Graph

29 Commits

Author SHA1 Message Date
c795a988e6 Conform many modules to new conventions 2019-07-23 12:30:47 +02:00
9bba39bd3a Prevent unsaved prompts when formatting #1498
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.
2019-06-16 19:16:22 +02:00
13f5a76278 Fix formatters unable to find project root #1489 2019-06-13 18:01:45 +02:00
12233811a8 fix: format-all upstream definitions
Upstream renamed definitions in
f3ed09c430 .
2019-06-08 17:45:42 +02:00
0c743afcfd editor/format: remove utf-8 conversion on Windows #914 2019-05-30 14:11:53 -04:00
5c3188afd5 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
2019-04-02 00:52:10 -04:00
99fd8b4e1b O'byte-compiler
Who forbade the obsolete,
Hooks, functions; adieu.

(And an unused argument too)
2019-02-03 18:42:09 -05:00
09603c5444 +format-region-p = nil
Should be a boolean in the first place; this fixes custom formatters
that use it like a boolean.
2018-10-19 11:48:47 -04:00
6859f77e1d format.el: fix Wrong type argument: listp, t
The intention here was to build a list of two elements.

Signed-off-by: Edwin Török <edwin@etorok.net>
2018-10-03 23:03:11 +01:00
6a44cf0124 editor/reformat: refactor & fixes
+ 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.
2018-09-18 15:19:50 -04:00
c52d2a5a14 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.
2018-09-10 08:25:48 -04:00
e0f8325f45 editor/format: fix wrong-number-of-args error
+format|buffer takes no arguments
2018-09-10 08:25:48 -04:00
8480f52081 editor/format: add +format-with option
+ 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
2018-09-09 09:58:22 -04:00
46083ed398 editor/format: preserve indent in +format-buffer 2018-09-09 09:58:22 -04:00
7d3ffdff06 Remove third line in section headers
This is truly important stuff. We've saved many lives with this update.
2018-09-09 09:58:19 -04:00
81ee563c4c +format|buffer: use pcase-let & return boolean
So it can be used in other functions.
2018-09-03 03:58:43 +02:00
75b39a9396 editor/format: preserve indentation for regions 2018-09-03 03:58:43 +02:00
c885cd2b9d editor/format: refactor & reformat +format-buffer
Also switches cl-destructuring-bind to pcase-let to avoid breaking
errors being thrown.
2018-09-03 03:58:43 +02:00
349fb49c7b editor/format: refactor +format-buffer & users 2018-08-30 15:00:33 +02:00
1b4040229e editor/format: update documentation 2018-08-30 14:56:50 +02:00
1ae3523f75 editor/format: autoload format-all-probe #834 2018-08-30 14:44:37 +02:00
7616316634 editor/format: improve message feedback
Announce failures, noops and successes clearly, and log errors.
2018-08-30 13:29:49 +02:00
fd9a3c36ee editor/format: refactor (again) 2018-08-29 17:02:49 +02:00
4b9233bec7 editor/format: format by diff & major refactor
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
2018-08-29 12:48:38 +02:00
2b560a6a0e General & minor refactoring 2018-08-28 13:36:44 +02:00
e932c74758 editor/format: don't move cursor on format-on-save
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`.
2018-08-28 12:02:56 +02:00
98b5c95ee5 editor/format: add +format|enable-on-save alias 2018-08-27 10:30:31 +02:00
f1460ff592 editor/format: don't move cursor on save 2018-08-26 17:26:54 +02:00
171c87aa2c editor/format: general fix & refactor
+ Fixes function/command formatters (like #'gofmt)
+ Fixes formatting by region
+ Adds default keybindings:
  + gQ evil operator
  + SPC c f (normal mode) to format buffer
  + SPC c f (visual mode) to format selection
2018-08-25 00:06:12 +02:00