]> git.eshelyaron.com Git - emacs.git/commit
lisp/editorconfig: Don't hook into `read-only-mode-hook`
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 12 Jun 2024 22:27:15 +0000 (18:27 -0400)
committerEshel Yaron <me@eshelyaron.com>
Fri, 21 Jun 2024 19:00:03 +0000 (21:00 +0200)
commit866b4309f291a1fdbafb09d8e43b12aca426242b
treeb6ce3e335202079b2313118e2aaba85a9490be51
parentd60d4a94f79574fe1b16698458c1f7367bae8323
lisp/editorconfig: Don't hook into `read-only-mode-hook`

Don't re-set variables just because `read-only-mode` is (de)activated,
and with Emacs-30's hooks it would be even less natural to do.
Also `buffer-read-only` can change without calling `read-only-mode`,
so better test it dynamically when we try to trim whitespace.

* lisp/editorconfig.el (editorconfig--delete-trailing-whitespace):
New function.
(editorconfig-set-trailing-ws): Use it.  Use `pcase`.
Also prefer `before-save-hook` and use `add/remove-hook` to
manipulate hooks, like god intended.
Don't test `buffer-read-only` any more.
(editorconfig-mode): Don't hook into `read-only-mode-hook` any more.

(cherry picked from commit 527a45abc37f1885652b0f29ed5eeabff6db6cda)
lisp/editorconfig.el