feat(format): add :lang emacs-lisp formatter
Introduce a formatter function for emacs-lisp (tracked upstream here [1]) that tries to preserve as much of what the user wants as possible [1]: https://github.com/radian-software/apheleia/pull/102
This commit is contained in:
parent
3aa9796b84
commit
cd79edf134
2 changed files with 18 additions and 2 deletions
|
@ -49,6 +49,21 @@ select buffers.")
|
|||
;;
|
||||
;;; Additional formatters
|
||||
|
||||
(after! apheleia-mode
|
||||
(after! apheleia
|
||||
;; TODO html-tidy
|
||||
)
|
||||
(cl-defun apheleia--indent-lisp-buffer
|
||||
(&key buffer scratch callback &allow-other-keys)
|
||||
"Format a Lisp BUFFER. Use SCRATCH as a temporary buffer and CALLBACK to
|
||||
apply the transformation. For more implementation detail, see
|
||||
`apheleia--run-formatter-function'."
|
||||
(with-current-buffer scratch
|
||||
(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))
|
||||
(goto-char (point-min))
|
||||
(let ((inhibit-message t)
|
||||
(message-log-max nil))
|
||||
(indent-region (point-min) (point-max)))
|
||||
(funcall callback))))
|
||||
|
|
|
@ -39,6 +39,7 @@ See `+emacs-lisp-non-package-mode' for details.")
|
|||
:documentation #'+emacs-lisp-lookup-documentation)
|
||||
(set-docsets! '(emacs-lisp-mode lisp-interaction-mode) "Emacs Lisp")
|
||||
(set-ligatures! 'emacs-lisp-mode :lambda "lambda")
|
||||
(set-formatter! 'lisp-indent #'apheleia--indent-lisp-buffer :modes '(emacs-lisp-mode))
|
||||
(set-rotate-patterns! 'emacs-lisp-mode
|
||||
:symbols '(("t" "nil")
|
||||
("let" "let*")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue