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

Don't set variables like fill-column for excluded files #365

Open
tmuehlbacher opened this issue Jan 11, 2025 · 6 comments
Open

Don't set variables like fill-column for excluded files #365

tmuehlbacher opened this issue Jan 11, 2025 · 6 comments

Comments

@tmuehlbacher
Copy link

I have editorconfig set up like so:

(use-package editorconfig
  :diminish editorconfig-mode
  :hook (after-init . editorconfig-mode)
  :init
  (setq editorconfig-exclude-regexps '("COMMIT_EDITMSG"
                                       "cover-letter\\.patch")))

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.

[*]
max_line_length = 80

It seems that for this editorconfig-set-local-variables should only be called if the exclude modes/regexps checks call for it.

@monnier
Copy link
Collaborator

monnier commented Jan 11, 2025 via email

@tmuehlbacher
Copy link
Author

Thanks for this quick response!

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.

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.

@monnier
Copy link
Collaborator

monnier commented Jan 11, 2025 via email

@tmuehlbacher
Copy link
Author

Sorry for the delay and the misunderstanding.

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.

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).

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.

@monnier
Copy link
Collaborator

monnier commented Jan 14, 2025 via email

@tmuehlbacher
Copy link
Author

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 fill-column in my-ignore-dir-locals-for-git.

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

No branches or pull requests

2 participants