Subject: bug#78097: 30.1; editorconfig can pass nil to file-name-directory

From: Stefan Monnier <[email-masked]>
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