Subject: Re: bug#34765: 26.1; with-temp-buffer should not run buffer-list-update-hook

From: martin rudalics <[email-masked]>
Date: Wed, 06 Mar 2019 15:13:37 +0100

> I do no understand the use-case you have in mind here. with-temp-buffer
 > serves to create a short-lived temporary buffer that is quickly disposed
 > of again. When would such a buffer be shown anywhere?

I confused this 'with-output-to-temp-buffer'.  Maybe we should indeed
rebind 'buffer-list-update-hook' around the 'generate-new-buffer' and
'kill-buffer' calls of 'with-temp-buffer'.

 >  > I'm afraid you have to dig further to find out how
 >  > 'buffer-list-update-hook' precisely gets called here.
 >
 > Did that, turns out it's down to mode-line packages, both powerline and
 > doom-modeline are advising select-window.

And do not preserve NORECORD?

 > I'll create PRs for both.
 >
 >  > What was the issue there?
 >
 > Same feedback loop as described above, except it would only happen
 > when a region was active in magit's status buffer. I had tracked
 > the cause to a temp buffer deep inside magit's internals. Here's the
 > github link:
 > https://github.com/magit/magit/issues/3738#issuecomment-464520582

Maybe magit should simply try to reuse the same temporary buffer
instead of recreating it excessively.  Creating/killing temporary
buffers does not come without some overhead.

 >  > Emacs 27 now has 'window-selection-change-functions', strongly
 >  > tied to redisplay and triggering only when the window selection has
 >  > changed since last redisplay. Maybe you could try that.
 >
 > This problem occurs in my treemacs package, so I cannot use a solution
 > provided by a bleeding edge release, my modus operandi is to support the
 > last 2 versions of emacs, so 25 and 26 (since stable distros like debian
 > still use emacs 25). At any rate I have found the culprit in those modeline
 > packages, so that point is solved.

I see.  But please try 'window-selection-change-functions' sooner or
later so we know whether it fixes these problems.

martin