Skip to content

Commit

Permalink
Update apheleia-indent-lisp-buffer to respect local variables (radi…
Browse files Browse the repository at this point in the history
…an-software#286)

I ran into some issues using apheleia while contributing to a project
that works with `indent-tabs-mode` disabled. This led to this slight
modification of `apheleia-indent-lisp-buffer`

This allows for any local values for `indent-line-function`,
`lisp-indent-function` to be carried over when
formatting. Additionally, added `indent-tabs-mode` in order to
prevent adding tabs when unwanted.
  • Loading branch information
tpeacock19 authored Mar 2, 2024
1 parent 7ba74c7 commit 2fec569
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].

## Unreleased
### Enhancements
### Formatters
### Bugs fixed
* `apheleia-indent-lisp-buffer` updated to apply local variables after
calling major-mode. Also includes setting for `indent-tabs-mode` ([#286]).

[#286]: https://github.com/radian-software/apheleia/pull/286

## 4.1 (released 2024-02-25)
### Enhancements
* Use `perltidy` as default formatter for `cperl-mode` ([#260]).
Expand Down
6 changes: 4 additions & 2 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -1095,11 +1095,13 @@ transformation.
For more implementation detail, see
`apheleia--run-formatter-function'."
(with-current-buffer scratch
(funcall (with-current-buffer buffer major-mode))
(setq-local indent-line-function
(buffer-local-value 'indent-line-function buffer))
(setq-local lisp-indent-function
(buffer-local-value 'lisp-indent-function buffer))
(funcall (with-current-buffer buffer major-mode))
(buffer-local-value 'lisp-indent-function buffer))
(setq-local indent-tabs-mode
(buffer-local-value 'indent-tabs-mode buffer))
(goto-char (point-min))
(let ((inhibit-message t)
(message-log-max nil))
Expand Down

0 comments on commit 2fec569

Please sign in to comment.