From 2fec5692e424cd24e7450d63bbe58f75eafb7417 Mon Sep 17 00:00:00 2001 From: tpeacock19 Date: Sat, 2 Mar 2024 14:27:24 -0700 Subject: Update `apheleia-indent-lisp-buffer` to respect local variables (#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. --- CHANGELOG.md | 9 +++++++++ apheleia-formatters.el | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af248c0..d64ec42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]). diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 4de755c..21976e7 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -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)) -- cgit v1.0