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

From: martin rudalics <[email-masked]>
Date: Mon, 30 Nov 2020 20:01:48 +0100

> I'm slightly confused about the conclusion of this thread, though.
 > You and Eli said it was too radical to set inhibit_buffer_hooks based
 > on whether a buffer name starts with a space, as there may be legitimate
 > cases where those hooks should run in a temporary buffer.

Yes.

 > I accept this, but I don't see how setting inhibit_buffer_hooks based on
 > a new optional argument to Fgenerate_new_buffer (and/or
 > Fget_buffer_create) solves the problem entirely.
 >
 > If I create a temporary buffer with the proposed
 >
 >    (generate-new-buffer "foo" t)
 >
 > then how do I later tell Emacs that this buffer's hooks should run?
 >
 > In other words, can we be sure that the buffers we choose to create with
 > inhibit_buffer_hooks set will *never* need to later unset it?
 >
 > Should we expose a getter or setter for this buffer member, or is that
 > opening ourselves up to abuse?

I'm not sure.  But if we do that, we can get rid of the rest: We'd just
generate the new buffer and set/reset its hook inhibitor afterwards.

 > I suppose if someone *really* wanted to un-temporarify a buffer with
 > inhibit_buffer_hooks set, they could create a new, non-temporary buffer
 > and swap buffer contents, or something to that effect?

Admittedly clumsy.

 > Am I wildly misunderstanding something here?

I don't think so.

 >> And also tell us why 'buffer-list-update-hook' would be still needed now
 >> that we have 'window-selection-change-functions'.
 >
 > I've yet to look into these hooks and their precise semantics, but are
 > you suggesting that one might obsolete the other, in which case we
 > should deprecate the old one?

People usually don't care about the buffer lists, they always wanted to
run a hook when a window got selected in a more permanent fashion.  At
the time of adding 'buffer-list-update-hook', I thought that it
fulfilled some of the criteria wanted for a 'select-window-hook' and
added text in that sense to the manual.  So if you care about the buffer
lists, 'buffer-list-update-hook' is the one to use.  If you care about
window selection, 'window-selection-change-functions' is the one.

martin