GNU bug report logs - #78097
30.1; editorconfig can pass nil to file-name-directory

Previous Next

Package: emacs;

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: "Peter J. Jones" <mlists <at> devalot.com>
Cc: 78097 <at> debbugs.gnu.org
Subject: bug#78097: 30.1; editorconfig can pass nil to file-name-directory
Date: Sun, 04 May 2025 11:55:21 -0400
>> Could you give a concrete example of how this can happen?
>
> Yes.  I want to have `delete-trailing-whitespace' in a `before-save'
> hook by default but still allow editor config to remove it if
> "trim_trailing_whitespace" is set to false in the current project.  So I
> wrote the following function and put it in
> `editorconfig-get-local-variables-functions':
>
> (defun pjones:editorconfig-apply-trim-whitespace (props)
>   "Conditionally change the trim_trailing_whitespace setting.
>
> Enable whitespace trimming unless the editor configuration file
> explicitly disables it.  PROPS is the hash from the editor configuration
> file."
>   (when (null (gethash 'trim_trailing_whitespace props))
>     (puthash 'trim_trailing_whitespace "true" props)
>     (editorconfig--get-trailing-ws props)))

I see, thanks.

FWIW, the fact that `editorconfig-get-local-variables-functions' is run
when there are no `.editorconfig` files is an accident.

> Projects that don't have editor configuration files trigger the bug
> where nil is passed to `file-name-directory'.

IIUC the patch you sent silences the error but also has the effect that
AFAICT it does not enable `delete-trailing-whitespace` in those files
for which there is no `.editorconfig`, contrarily to what I understood
to be your goal.

Was that on purpose?


        Stefan





This bug report was last modified 54 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.