From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#34765: 26.1; with-temp-buffer should not run buffer-list-update-hook Date: Fri, 26 Apr 2019 14:26:31 +0300 Message-ID: <83y33xvwgo.fsf@gnu.org> References: <5C7FD591.9090505@gmx.at> <83lg1sc8ob.fsf@gnu.org> <5C8009F3.5000405@gmx.at> <767e1b59-6ac2-cd11-076e-82a56ac53e29@gmx.at> <11be4631-b087-52a3-92fe-4cbd5248908d@gmx.at> <838svxxk41.fsf@gnu.org> <49c11920-0909-dcc2-4a39-4cdcfaf20453@gmx.at> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="197610"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 34765@debbugs.gnu.org, alexanderm@web.de, monnier@IRO.UMontreal.CA To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 26 13:27:16 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJz0d-000pJq-AO for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 Apr 2019 13:27:15 +0200 Original-Received: from localhost ([127.0.0.1]:45276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJz0c-0000NX-9U for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 Apr 2019 07:27:14 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJz0S-0000JH-Vq for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2019 07:27:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJz0R-0000lr-Qp for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2019 07:27:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46660) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hJz0R-0000lk-JW for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2019 07:27:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hJz0Q-0005Tj-EH for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2019 07:27:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Apr 2019 11:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34765 X-GNU-PR-Package: emacs Original-Received: via spool by 34765-submit@debbugs.gnu.org id=B34765.155627801921048 (code B ref 34765); Fri, 26 Apr 2019 11:27:02 +0000 Original-Received: (at 34765) by debbugs.gnu.org; 26 Apr 2019 11:26:59 +0000 Original-Received: from localhost ([127.0.0.1]:60204 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hJz0L-0005TO-8d for submit@debbugs.gnu.org; Fri, 26 Apr 2019 07:26:59 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:42865) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hJz0J-0005TB-1O for 34765@debbugs.gnu.org; Fri, 26 Apr 2019 07:26:55 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:47743) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJz0D-0000a7-HK; Fri, 26 Apr 2019 07:26:49 -0400 Original-Received: from [176.228.60.248] (port=2711 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hJz0C-0006nJ-SC; Fri, 26 Apr 2019 07:26:49 -0400 In-reply-to: <49c11920-0909-dcc2-4a39-4cdcfaf20453@gmx.at> (message from martin rudalics on Fri, 26 Apr 2019 13:00:06 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158286 Archived-At: > Cc: monnier@IRO.UMontreal.CA, 34765@debbugs.gnu.org, alexanderm@web.de > From: martin rudalics > Date: Fri, 26 Apr 2019 13:00:06 +0200 > > > I attach a preliminary patch. Thanks. This will need documentation changes when pushed. > +/** > + * run_buffer_list_update_hook: > + * > + * Run any functions on 'buffer-list-update-hook'. Do not run the > + * functions when BUFFER is a buffer and its inhibit_buffer_hooks > + * structure element is set. Do not run any functions either when we > + * are not allowed to run hooks. > + */ Can we please use our style in commentary? We don't use bock comments in Emacs, so I'd like not to proliferate them. > + if (!inhibit_buffer_hooks) > + /* Run buffer-list-update-hook. */ > + run_buffer_list_update_hook (buffer); It is somewhat strange that part of the reasons for not running hooks are tested inside run_buffer_list_update_hook, and others explicitly here. Any special reasons for this inconsistency? > +DEFUN ("get-buffer-create", Fget_buffer_create, Sget_buffer_create, 1, 1, 0, > + doc: /* Return the buffer specified by BUFFER-OR-NAME, creating a new one if needed. > +If BUFFER-OR-NAME is a string and a live buffer with that name exists, > +return that buffer. If no such buffer exists, create a new buffer with > +that name and return it. If BUFFER-OR-NAME starts with a space, the new > +buffer does not keep undo information. > + > +If BUFFER-OR-NAME is a buffer instead of a string, return it as given, > +even if it is dead. The return value is never nil. */) > + (Lisp_Object buffer_or_name) > +{ > + return get_buffer_create (buffer_or_name, false); > +} Should this function also acquire an additional optional argument? If not, why not? > +Optional second argument INHIBIT-BUFFER-HOOKS non-nil means to not run > +any buffer hooks ('kill-buffer-hook', 'buffer-list-update-hook' or > +'kill-buffer-query-functions') for this buffer. This argument should The hooks should be quoted `like this', right? We do want them to become hyperlinks. > +be set only for internal buffers that are never presented to users or > +passed on to other applications. */) > + (Lisp_Object name, Lisp_Object inhibit_buffer_hooks) > +{ > + Lisp_Object buffer_name = Fgenerate_new_buffer_name (name, Qnil); > + Lisp_Object buffer = get_buffer_create (buffer_name, > + !NILP (inhibit_buffer_hooks)); > + > + if (!NILP (inhibit_buffer_hooks)) > + { > + struct buffer *b = XBUFFER (buffer); > + > + b->inhibit_buffer_hooks = true; > + } Should this flag be set inside get_buffer_create? > +Neither 'kill-buffer-query-functions' nor 'kill-buffer-hook' are run > +for buffers created by 'generate-new-buffer' with the second argument > +'inhibit-buffer-hooks' non-nil. Quoting again. > @@ -6268,9 +6334,9 @@ The function `kill-all-local-variables' runs this before doing anything else. * > doc: /* Hook run when the buffer list changes. > Functions (implicitly) running this hook are `get-buffer-create', > `make-indirect-buffer', `rename-buffer', `kill-buffer', `bury-buffer' > -and `select-window'. Functions run by this hook should avoid calling > -`select-window' with a nil NORECORD argument or `with-temp-buffer' > -since either may lead to infinite recursion. */); > +and `select-window'. This hook is not run for buffers created by > +'generate-new-buffer' with the second argument 'inhibit-buffer-hooks' > +non-nil. */); And here.