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)