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
Ping! How should we proceed with this issue? Was it resolved?
> Cc: 78097 <at> debbugs.gnu.org
> From: "Peter J. Jones" <mlists <at> devalot.com>
> Date: Mon, 05 May 2025 09:14:50 +0200
>
> On Sun, May 04 2025, Stefan Monnier wrote:
> >>> 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.
>
> 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?
>
> >> 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?
>
> No. I was starting to suspect that it wasn't working and after seeing
> your patch I now know it's most definitely not working! I was so deep
> in the weeds trying to fix the "stringp nil" issue that I never went
> back to see if my fix actually worked. Sorry about that.
>
> Your patch makes a lot more sense than the non-functional hack I first
> posted.
>
> Thanks for the help!
>
> --
> Peter J. Jones (he/him)
> blog: https://freerangebits.com
> social: https://fosstodon.org/@devalot
> code: https://github.com/pjones
>
>
>
>
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.