Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scratch/editorconfig #346

Merged
merged 6 commits into from
Jul 18, 2024
Merged

Scratch/editorconfig #346

merged 6 commits into from
Jul 18, 2024

Conversation

10sr
Copy link
Member

@10sr 10sr commented Jun 24, 2024

Closes #345

This follows the convention used in Emacs's own test suite and works around
annoying circular `require`s when `ert-tests` happens to be in `load-path`.
Also adjust the Makefile not to get confused by generated files.

* Makefile (SRCS): Filter out ELPA-generated files.
Instead of treating `lisp-indent-offset` specially in
`editorconfig--should-set` (to obey `editorconfig-lisp-use-default-indent`),
use a new function `editorconfig-set-indentation-lisp-mode`
for Lisp modes.

* lisp/editorconfig.el (editorconfig--should-set): Remove `size` argument.
(editorconfig-set-indentation): Adjust calls accordingly.
(editorconfig-set-indentation-lisp-mode): New function.
(editorconfig-indentation-alist): Use it.
Mostly fix compiler warnings and prefer #' to quote function names.

* editorconfig.el: Remove dependency on `nadvice` since we require
Emacs-26 which includes `nadvice` already.
Remove redundant `require`s.  Remove redundant `:group` arguments.
Move `defvar`s outside of `eval-when-compile`.
Remove "post-end trailer".
* .dir-locals.el: New file, to replace the "post-end trailer".

* ert-tests/editorconfig-core-handle-tests.el (editorconfig--fixtures):
Rename from `fixtures`.  Change all uses.

* ert-tests/editorconfig-tests.el (test-editorconfig)
(test-local-variables, test-hack-properties-functions):
Use `bound-and-true-p` when it's not guaranteed that the var will
be defined.
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.

* ert-tests/editorconfig-tests.el (test-trim-trailing-ws): Adjust the
test accordingly.
Match relative file names against the glob pattern instead of
trying to construct a glob pattern that matches the absolute
file name (where the code failed to escape the possible
special chars).

* lisp/editorconfig-core-handle.el
(editorconfig-core-handle-section-get-properties): Delete `dir` arg.
(editorconfig-core-handle-get-properties-hash)
(editorconfig-core-handle-get-properties): Adjust call accordingly.
Use `declare` to mark it obsolete.
(editorconfig-core-handle--fnmatch-p): Delete `dir` arg.
@10sr 10sr marked this pull request as ready for review July 12, 2024 13:41
@10sr 10sr closed this Jul 12, 2024
@10sr 10sr reopened this Jul 12, 2024
@10sr 10sr merged commit 906b78e into master Jul 18, 2024
12 checks passed
@10sr 10sr deleted the scratch/editorconfig branch July 18, 2024 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failure to apply EditorConfig settings in dirs with funny names
2 participants