-
Notifications
You must be signed in to change notification settings - Fork 108
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
Don't set variables like fill-column for excluded files #365
Comments
I have editorconfig set up like so:
```el
(use-package editorconfig
:diminish editorconfig-mode
:hook (after-init . editorconfig-mode)
:init
(setq editorconfig-exclude-regexps '("COMMIT_EDITMSG"
"cover-letter\\.patch")))
```
Side question: how do you open such "excluded" files and which major
mode do you use for them?
```ini
[*]
max_line_length = 80
```
Would you ideally want that exclusion to apply also to all other
possible editorconfig settings (e.g. coding system, TAB-vs-SPC, ...),
and more importantly, would you also want to ignore non-editorconfig
dir-local settings (i.e. coming from a `.dir-locals.el` file)?
|
Thanks for this quick response!
I open files from the magit status buffer with RET or with C-x C-f, usually.
I think that files/modes that are excluded should just work in the same way as if there was no editorconfig file present. So yes, don't set other values either. |
> Side question: how do you open such "excluded" files and which major mode do you use for them?
I open files from the magit status buffer with RET or with C-x C-f, usually.
`text-mode` with minor `git-commit-mode` for commit editmsgs and
`message-mode` for patch cover-letter files.
Hmm... maybe something like:
(defun my-ignore-dir-locals-for-git ()
(setq-local enable-local-variables nil))
(add-hook 'git-commit-mode-hook #'my-ignore-dir-locals-for-git)
(add-hook 'message-mode-hook #'my-ignore-dir-locals-for-git)
would make sense (currently `enable-local-variables` affects
editorconfig settings only with the editorconfig code that's in
Emacs≥30).
> Would you ideally want that exclusion to apply also to all other possible
> editorconfig settings (e.g. coding system, TAB-vs-SPC, ...), and more
> importantly, would you also want to ignore non-editorconfig dir-local
> settings (i.e. coming from a `.dir-locals.el` file)?
I think that files/modes that are excluded should just work in the same way
as if there was no editorconfig file present. So yes, don't set other
values either.
My question is not about what you think `editorconfig-exclude-regexps`
should do, but about what behavior you'd like from Emacs in the specific
case of interest (those Git-related files).
Also what about settings from `.dir-locals.el`?
I'm asking since, in Emacs≥30, Editorconfig settings are treated via the
same mechanism as those from `.dir-locals.el`.
|
Sorry for the delay and the misunderstanding. I have upgraded from 29 to 30.0.93 and removed editorconfig from the external I have tried using When opening the When running starting a commit in the magit status buffer, the fill-column is |
I have upgraded from 29 to 30.0.93 and removed editorconfig from the external
packages but I can't seem to get it to work still.
Not completely sure what "it" is, but `editorconfig-exclude-regexps` is
currently not obeyed at all by the code in Emacs-30.
I have tried using `debug-watch` on `fill-column` with the ignore local
variables hook.
When opening the `*cover-letter.patch` file, the fill-column is first set to 72
(I have this as `(setq-default fill-column 72)` in my init.el) and then to 80
(specified in `.editorconfig`).
That's the behavior I'd except unless you disable file/dir-local vars, as
in my suggested:
(defun my-ignore-dir-locals-for-git ()
(setq-local enable-local-variables nil))
(add-hook 'git-commit-mode-hook #'my-ignore-dir-locals-for-git)
(add-hook 'message-mode-hook #'my-ignore-dir-locals-for-git)
When running starting a commit in the magit status buffer, the fill-column is
only set to 80 but 4 times. I am not sure why that is triggered so frequently.
Don't know either, yet not completely surprised: it's presumably set
every time a major mode is enabled, and it's not uncommon to enable
different mode(s) before "the right one". Plus some modes/packages call
`hack-local-variables` by hand (for various reasons) which would cause
it to be (re)set yet more times.
If you want to investigate that, I'd suggest you start by comparing the
backtraces in the 4 cases.
|
I was/am using your solution. :) However, the hook seems to run too late and editorconfig already sets the fill column earlier. enable-local-variables is also set multiple times to different values. As a hacky fix, I could also set |
I have editorconfig set up like so:
I want to have editorconfig rules like this at the project root not interfere with
fill-column
when writing commit messages or git patch cover letters that typically should use 72 characters per line.It seems that for this
editorconfig-set-local-variables
should only be called if the exclude modes/regexps checks call for it.The text was updated successfully, but these errors were encountered: