* Rename apheleia-hide-log-buffer to apheleia-hide-log-buffers.
* Rename apheleia-verbose to apheleia-log-only-errors (note, meaning
is inverted).
* Add apheleia-hide-old-log-entries.
* Include more information in log and format it more neatly.
* Convert log buffer to special-mode and attempt to keep point at the
end (although this is not working for an undetermined reason).
* [#62] Support functions as formatters
Closes#62.
Lets you use a lisp function as a formatter. This gives apheleia a lot
more flexibility in regards to what constitutes a formatter. For example
you can now plug an external language server or another tool as a
formatter for use with apheleia.
Here's a very basic example of using indent-line-function with apheleia
after merging this commit. Note: this doesn't take into account any
special local variables in the original buffer such as lisp-body-indent.
It's really just for demonstration purposes and as a proof of concept.
```lisp
(defun apheleia-indent-region+ (orig scratch callback)
(with-current-buffer scratch
(setq-local indent-line-function
(buffer-local-value 'indent-line-function orig))
(indent-region (point-min)
(point-max))
(funcall callback scratch)))
(push '(indent-region . apheleia-indent-region+) apheleia-formatters)
(push '(elisp-mode . indent-region) apheleia-mode-alist)
(push '(lisp-interaction-mode . indent-region) apheleia-mode-alist)
```
* Fix misc-bugs + prevent race conditions
* Update docstring
* Reword a bit
* Add to README
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
* Run the same formatter in multiple buffers in parallel (#64) (#65)
Previously when apheleia formatted a buffer it created a stdout and
stderr buffer for each formatter, but it reused this buffer each time
that formatter would run. This makes sense if we only ever format one
buffer at a time (meaning we don't format a new buffer until the
previous buffer has been formatted) such as when calling
`apheleia-format-buffer` interactively (since the interval for running a
formatter is likely far below hitting a key combination for this
command). But this assumption falls apart when using `apheleia-mode` and
`apheleia--format-after-save`.
Now a lot of files could be saved, triggering the same formatters again
and again, within a short period of each other. Apheleia used to keep
track of the current formatter process and kill it when a newer
formatter is attempted, but this also kills all but the last buffer
called by `apheleia--format-after-save`.
With this commit we still have separate stdout and stderr buffers for
each formatter, but we *always* create a new one when attempting a
format. There is a new buffer type, a log buffer, which is populated
with a formatter processes stderr when it fails. We also still have a
`apheleia--current-process` variable, but instead of being global, it's
local to the current buffer being formatted. We now kill it if starting
a new format in the current buffer, but two separate buffers can call
the same formatter with no issue.
* Mark change as bugfix in changelog
* Add to docstring
* Remove no longer needed code
* Re-wrap docstring
* Remove newline
* Change spelling
* Use correct buffer when checking (buffer-size)
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
* Evaluate any non-special args in apheleia-formatters (#55)
Allows you to place snippets of elisp within a formatter command that
will be evaluated and substituted in place when apheleia decides to run
that command.
* Update apheleia.el
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
* Support multiple formatters (#31)
Closes#31
This commit makes it so apheleia can run multiple formatters one after
the other and use the resultant output to format the current buffer.
This works somewhat like a pipeline. The output of one formatter becomes
the input to the next formatter until all formatters have run and then
an RCS patch is built from the resultant output and applied to the
current buffer.
Note: For convenience we internally represent the users configuration as
a list of formatters even when it may only be one. For example if the
user has configured `(python-mode . black)` in apheleia-mode-alist then
internally we interpret that as a formatter list of `(black)` instead of
`black` as we did previously.
* Support multiple formatters (#31)
Closes#31
This commit makes it so apheleia can run multiple formatters one after
the other and use the resultant output to format the current buffer.
This works somewhat like a pipeline. The output of one formatter becomes
the input to the next formatter until all formatters have run and then
an RCS patch is built from the resultant output and applied to the
current buffer.
Note: For convenience we internally represent the users configuration as
a list of formatters even when it may only be one. For example if the
user has configured `(python-mode . black)` in apheleia-mode-alist then
internally we interpret that as a formatter list of `(black)` instead of
`black` as we did previously.
* Make some changes
* Make some changes
* Error when a (not-first) formatter uses file or filepath
* Prevent formatter recieving stdin when using `file'
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
* Fix rustfmt dumping child modules' content into file
rustfmt by default analyses all files dependent on the current file,
too. The out put of --emit stdout contain all child modules. Apheleia
would happily dump that into the currently edited buffer (even though
the content came from another file.)
The unstable option --skip-children prevents that. It's as yet
untested! I've only made a couple of quick sanity checks.
* Fix long line
* Add Rust formatter rustfmt.
* Add LaTeX formatter latexindent.
There's a lot of LaTeX modes. I'm not sure how to distinguish them.
* Alphabetize apheleia-formatters and apheleia-mode-alist.
Alphabetizing them makes it easier to find which formatters are
supported.
* Add Java formatter with google-java-format.
* Add C and C++ formatter with clang-format.
* Update changelog
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
* Update apheleia-formatters type spec to avoid customize-variable error
Declare all of the permitted special symbols used in apheleia-formatters commands.
Without this, 'customize-variable never allows settting the value of apheleia-formatters, instead reporting an error about a mismatch between the default value and the type.
* Update CHANGELOG.md
* Break long line
* Update CHANGELOG.md
* Update CHANGELOG.md
* Create CHANGELOG.md
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>