GNU bug report logs -
#66317
Project mode-line
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Tue, 3 Oct 2023 06:33:01 UTC
Severity: wishlist
Fixed in version 30.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 19/10/2023 09:40, Juri Linkov wrote:
>> FWIW, I haven't been able to reproduce this so far.
>
> Unfortunately it's not easily reproducible.
>
>>> The bug occurs when multiple lines are displayed in the echo area.
>>> Then '(:eval (project-mode-line-format)) is called twice.
>>> At the end of the first call 'buffer-file-coding-system'
>>> is still correct: utf-8. But at the beginning of the
>>> second call it's already wrong: raw-text.
>>>
>>> I guess it was a mistake to allow specifying the project name
>>> in .dir-locals.el. A better place would be in ~/.emacs.d/projects.
>>
>> But project-name uses project--value-in-dir which uses a temporary buffer
>> to apply all variables in.
>
> So it does this extensive work several times per second every time
> when the mode-line is updated?
>
> Then maybe better to cache the project name somewhere?
There is an existing caching mechanism IIUC based on the dir-locals'
file mtime (see the description in dir-locals-find-file), which is
better than nothing.
We could add something on top of it, but it would have to be a cache
keyed on the directory (because project-name should return the right
value inside C-x p p <choose other project> k, for example), and it
would be invalidated once every 5 seconds or so (or use some other more
advanced logic, but I'm not sure which).
>> Does that affect the original buffer somehow?
>
> Actually it doesn't affect the original buffer directly.
> When saving a buffer and the message is multi-line
> during saving, then '(project-mode-line-format)' is called twice,
> and the buffer coding is changed between these calls.
I suppose some global value like last-coding-system-used might create an
interrelation between such calls. The use of a temp buffer should
protect us from adverse effects, though.
> I don't know where is this code that decides to evaluate
> mode-line-format twice in a row, and how this code is affected
> by temporary buffers used by project--value-in-dir.
I'm not sure what to recommend, but some print-debugging could help.
E.g. just add a (backtrace) call inside project-mode-line-format.
But that's a lot of output to sort through, so there's definitely room
for improvement in this recipe.
This bug report was last modified 1 year and 199 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.