From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#72229: (setq overriding-terminal-local-map nil) in isearch-done Date: Tue, 23 Jul 2024 09:32:21 +0300 Organization: LINKOV.NET Message-ID: <864j8gsk4i.fsf@mail.linkov.net> References: <87r0bmer66.fsf@web.de> <87sew17fs1.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31773"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 72229@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 23 08:40:37 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sW9CP-00082U-4j for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Jul 2024 08:40:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sW9CD-0004Xk-60; Tue, 23 Jul 2024 02:40:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sW9Bn-00038m-RM for bug-gnu-emacs@gnu.org; Tue, 23 Jul 2024 02:40:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sW9Bm-00057N-CG for bug-gnu-emacs@gnu.org; Tue, 23 Jul 2024 02:39:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sW9Bq-0007a4-DI for bug-gnu-emacs@gnu.org; Tue, 23 Jul 2024 02:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Jul 2024 06:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72229 X-GNU-PR-Package: emacs Original-Received: via spool by 72229-submit@debbugs.gnu.org id=B72229.172171678929084 (code B ref 72229); Tue, 23 Jul 2024 06:40:02 +0000 Original-Received: (at 72229) by debbugs.gnu.org; 23 Jul 2024 06:39:49 +0000 Original-Received: from localhost ([127.0.0.1]:59018 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sW9Bc-0007Z2-M2 for submit@debbugs.gnu.org; Tue, 23 Jul 2024 02:39:49 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:45955) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sW9Ba-0007Ym-JW for 72229@debbugs.gnu.org; Tue, 23 Jul 2024 02:39:48 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 575BF240005; Tue, 23 Jul 2024 06:39:34 +0000 (UTC) In-Reply-To: <87sew17fs1.fsf@web.de> (Michael Heerdegen's message of "Mon, 22 Jul 2024 14:49:34 +0200") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289143 Archived-At: --=-=-= Content-Type: text/plain > Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife > of text editors" writes: > >> exiting isearch always explicitly sets `overriding-terminal-local-map' >> to nil. This will interfere with any other users of >> `overriding-terminal-local-map', including any active transient maps. >> >> Wouldn't a less radical means suffice? If isearch really must _set_, >> i.e., completely override that variable, why not restore the original >> value? > > Juri, what's your opinion on this? Indeed, you are right, `isearch-done' should restore the original value. The existing variable `isearch--saved-overriding-local-map' can't be used, so a similar variable should be added like in this patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=isearch--saved-local-map.patch diff --git a/lisp/isearch.el b/lisp/isearch.el index dc9edf267f2..697dcdbb3d8 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -972,6 +972,7 @@ isearch-hidden ;; The value of input-method-function when isearch is invoked. (defvar isearch-input-method-function nil) +(defvar isearch--saved-local-map nil) (defvar isearch--saved-overriding-local-map nil) ;; Minor-mode-alist changes - kind of redundant with the @@ -1321,6 +1322,7 @@ isearch-mode (setq isearch-mode " Isearch") ;; forward? regexp? (force-mode-line-update) + (setq isearch--saved-local-map overriding-terminal-local-map) (setq overriding-terminal-local-map isearch-mode-map) (run-hooks 'isearch-mode-hook) ;; Remember the initial map possibly modified @@ -1439,10 +1444,12 @@ isearch-update (defun isearch-done (&optional nopush edit) "Exit Isearch mode. +Called by all commands that terminate isearch-mode. For successful search, pass no args. For a failing search, NOPUSH is t. For going to the minibuffer to edit the search string, -NOPUSH is t and EDIT is t." +NOPUSH is t and EDIT is t. +If NOPUSH is non-nil, we don't push the string on the search ring." (when isearch-resume-in-command-history (add-to-history 'command-history @@ -1460,9 +1467,7 @@ isearch-done (setq isearch--current-buffer nil) (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit)))) - ;; Called by all commands that terminate isearch-mode. - ;; If NOPUSH is non-nil, we don't push the string on the search ring. - (setq overriding-terminal-local-map nil) + (setq overriding-terminal-local-map isearch--saved-local-map) ;; (setq pre-command-hook isearch-old-pre-command-hook) ; for lemacs (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout) (isearch-dehighlight) @@ -2676,7 +2681,7 @@ isearch-mouse-2 is bound to outside of Isearch." (interactive "e") (let ((w (posn-window (event-start click))) - (binding (let ((overriding-terminal-local-map nil) + (binding (let ((overriding-terminal-local-map isearch--saved-local-map) ;; Key search depends on mode (bug#47755) (isearch-mode nil)) (key-binding (this-command-keys-vector) t)))) --=-=-= Content-Type: text/plain > A little more forward looking: > > In such situations I often get this thought: if the variable was > replaced with a function accepting zero arguments, then we could use > `add-function' and `remove-function' to control the return value of the > "binding". > > I know the advice mechanism has the reputation of only being suitable > for end user customization/hacks, but in cases like this one we could > make the modification of the value more explicit and controllable. > Dealing with interferences would be forced to be taken into account more > directly , and we would get some useful mechanisms like priorities or > looking at the context out of the box. > > We could also invent some even better mechanism, maybe. But in this > case binding variables doesn't look like an optimal approach at least. This mechanism looks like a variable watcher enabled by `add-variable-watcher'. So you could add a watcher that conditionally controls variable modifications. --=-=-=--