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
Message #17 received at 78097 <at> debbugs.gnu.org (full text, mbox):
On Sat, May 03 2025, Stefan Monnier wrote:
>> When a function called from
>> `editorconfig-get-local-variables-functions' returns an alist, but
>> there is no .editorconfig file in the directory tree,
>
> 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)))
Projects that don't have editor configuration files trigger the bug
where nil is passed to `file-name-directory'.
Thank you.
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.