GNU bug report logs -
#78097
30.1; editorconfig can pass nil to file-name-directory
Previous Next
Reported by: "Peter J. Jones" <mlists <at> devalot.com>
Date: Sun, 27 Apr 2025 15:31:02 UTC
Severity: normal
Found in version 30.1
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> Cc: 78097 <at> debbugs.gnu.org
> Date: Sat, 17 May 2025 11:15:54 -0400
> From: Stefan Monnier via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> >>> FWIW, the fact that `editorconfig-get-local-variables-functions' is run
> >>> when there are no `.editorconfig` files is an accident.
> >> The reason I was using `editorconfig-get-local-variables-functions' is
> >> because both `editorconfig-after-apply-functions' and
> >> `editorconfig-hack-properties-functions' are documented to behave that
> >> way but are deprecated and `editorconfig-hack-properties-functions'
> >> reports that `editorconfig-get-local-variables-functions' should be used
> >> instead.
> >> If none of these hooks are available for this purpose can you recommend
> >> a way that I can achieve my goal?
> >
> > I'm afraid I don't have a ready answer for it.
> > Maybe something like:
> >
> > (add-hook 'change-major-mode-after-body-hook #'my-global-file-defaults)
> > (defun my-global-file-defaults ()
> > (when buffer-file-name
> > (add-hook 'before-save-hook
> > #'editorconfig--delete-trailing-whitespace nil t)))
> >
> > Obviously, Emacs lacks an official "delete-trailing-whitespace mode":
> > the above should not have to rely on an editorconfig-specific function.
> > š
>
> There is now a `delete-trailing-whitespace-mode` in `master, so the
> above snippet can be updated to something like:
>
> (add-hook 'change-major-mode-after-body-hook #'my-global-file-defaults)
> (defun my-global-file-defaults ()
> (when buffer-file-name
> (if (fboundp 'delete-trailing-whitespace-mode) ;; Emacsā„31
> (delete-trailing-whitespace-mode 1)
> (add-hook 'before-save-hook
> #'editorconfig--delete-trailing-whitespace nil t))))
>
> Eli writes:
> > Ping! How should we proceed with this issue? Was it resolved?
>
> I think the above provides the OP with a good alternative solution.
> Their code relied on an accidental "feature" which is that
> `editorconfig-get-local-variables-functions` is run even if we found no
> `.editorconfig` settings. I think that in the absence of such settings,
> `editorconfig-mode` should have no effect, so I suggest we install the
> patch below.
>
> I'd lean towards pushing it to `master` rather than `emacs-30`.
Fine by me, thanks.
This bug report was last modified 55 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.