From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master 2b3f3d421a: Make minibuffer lazy highlight setup buffer-local where appropriate Date: Wed, 18 May 2022 16:51:40 -0400 Message-ID: References: <165264034407.21518.7194358780844409479@vcs2.savannah.gnu.org> <20220515184546.6304CC01683@vcs2.savannah.gnu.org> <87lev2h590.fsf@gmail.com> <86ee0qd5sf.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5548"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Augusto Stoffel , emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 18 22:52:42 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nrQev-0001Em-C1 for ged-emacs-devel@m.gmane-mx.org; Wed, 18 May 2022 22:52:41 +0200 Original-Received: from localhost ([::1]:35556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrQet-000140-TI for ged-emacs-devel@m.gmane-mx.org; Wed, 18 May 2022 16:52:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrQe5-0000NZ-28 for emacs-devel@gnu.org; Wed, 18 May 2022 16:51:49 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:35420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrQe1-0003A2-QG for emacs-devel@gnu.org; Wed, 18 May 2022 16:51:47 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 0AEC5100596; Wed, 18 May 2022 16:51:44 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 541C2100139; Wed, 18 May 2022 16:51:42 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1652907102; bh=p3l2vJ54m9xPfw/t81UjbXRk1L7gds5TgC90AjcMuC0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=L8vkZGjocayOnosKgsOHTj5aSSVjyc/S9wsJ6B2lR5Wdnlbjzz8ojqwrPFynYFbRl QomKyWu7pkIzFs/D1ov9Ps77ZcUlQbNWL/S6A2Ybu8jfAqG+8nEkmf26bIDt2PL0eL 3AAEfKLHIu1xmOdsx3HnmDNRXtLM/Izz0OoLDS3ByKk5Dp7jgDTHyGipx3cPgIGjVh e5lh/P2L7NxKo6kd5Xo2mVgITL+okm/gjYPGifGrIAyCvvpURyeEPvs10ZPvM79Kaz 1tkpXEXCkioqk4Vwb2XkNke1As++Uumz/Qrz4/isRuLYWidydeXBa49IAF6xRQE9kU 8yCNtZytfZTvQ== Original-Received: from alfajor (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3D388120C1E; Wed, 18 May 2022 16:51:42 -0400 (EDT) In-Reply-To: <86ee0qd5sf.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 18 May 2022 21:59:04 +0300") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289934 Archived-At: Juri Linkov [2022-05-18 21:59:04] wrote: >>> `add-function` is modeled after `add-hook`, so the above >>> `make-local-variable` would be better replaced with >>> >>> (add-function :after-while (local 'isearch-filter-predicate) filter) >>> >>> [ Of course, that's pure theory. You'd better test it first. ] >> >> Yes, I guess that's the right way to approach this. The attached patch >> implements it. > > Thanks, pushed. > >> Now, I had tried it earlier and noticed something looked fishy. Now I >> can reproduce the problem: >> >> 1. With an active region, call C-M-% >> 2. Switch from the minibuffer back to the original buffer >> 3. Call keyboard-escape-quit (maybe twice) to quit the minibuffer >> prompt. >> >> Then the buffer-local value of `isearch-filter-predicate' is not cleaned >> up. Is it by any chance intentional that minibuffer-exit-hook doesn't >> run in this case? > > Indeed, a buffer-local minibuffer-exit-hook is not called > when the minibuffer is exited outside of the minibuffer. Looks like a bug. How 'bout the patch below? Stefan diff --git a/src/minibuf.c b/src/minibuf.c index df82bcb121a..ac48d0f4714 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -265,7 +265,7 @@ DEFUN ("set-minibuffer-window", Fset_minibuffer_window, static void read_minibuf_unwind (void); static void minibuffer_unwind (void); -static void run_exit_minibuf_hook (void); +static void run_exit_minibuf_hook (Lisp_Object minibuf); /* Read a Lisp object from VAL and return it. If VAL is an empty @@ -749,7 +749,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, separately from read_minibuf_unwind because we need to make sure that read_minibuf_unwind is fully executed even if exit-minibuffer-hook signals an error. --Stef */ - record_unwind_protect_void (run_exit_minibuf_hook); + record_unwind_protect (run_exit_minibuf_hook, Fcurrent_buffer ()); /* Now that we can restore all those variables, start changing them. */ @@ -1076,9 +1076,13 @@ get_minibuffer (EMACS_INT depth) } static void -run_exit_minibuf_hook (void) +run_exit_minibuf_hook (Lisp_Object minibuf) { + specpdl_ref count = SPECPDL_INDEX (); + record_unwind_current_buffer (); + Fset_buffer (minibuf); safe_run_hooks (Qminibuffer_exit_hook); + unbind_to (count, Qnil); } /* This variable records the expired minibuffer's frame between the