unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Augusto Stoffel <arstoffel@gmail.com>
Cc: Philip Kaludercic <philipk@posteo.net>,
	Gregory Heytings <gregory@heytings.org>,
	Manuel Uberti <manuel.uberti@inventati.org>,
	Ergus <spacibba@aol.com>,
	emacs-devel@gnu.org
Subject: Re: Simple isearch concerns
Date: Thu, 29 Apr 2021 19:29:45 +0300	[thread overview]
Message-ID: <87y2d1ksga.fsf@mail.linkov.net> (raw)
In-Reply-To: <87lf937hgk.fsf@mail.linkov.net> (Juri Linkov's message of "Tue,  27 Apr 2021 20:41:47 +0300")

[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]

>> Is this overriding map there just so that `isearch-mode-map' takes
>> precedence over other minor mode maps?  If so, couldn't this be achieved
>> by manipulating minor-mode-map-alist to put Isearch's map at the top?
>> Maybe that can be done buffer-locally.
>
> According to (info "(elisp) Searching Keymaps") the next keymap to try is
> `overriding-local-map`.  It can be set buffer-locally.

Actually, overriding-local-map can't be used, because it prioritizes
global-map over local maps, so e.g. in Dired typing C-o exits isearch
and calls open-line instead of dired-display-file.

According to (info "(elisp) Searching Keymaps"), the next available keymap is
emulation-mode-map-alists.  The following patch added a single line:

  (add-to-list 'emulation-mode-map-alists `((isearch-mode . ,isearch-mode-map)))

then removed all mentions of overriding-terminal-local-map,
removed all 156 lines of the monstrous macro with-isearch-suspended,
added a single line to the end of isearch-edit-string:

  (isearch-search-and-update)

and then M-e edits the search string without exiting isearch.  And it's
trivial to use isearch commands without exiting the minibuffer with e.g.

  (with-minibuffer-selected-window (isearch-repeat-forward))

And everything works fine.  It's too good to be true,
but I don't see where's the catch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: isearch-emulation-mode-map-alists.patch --]
[-- Type: text/x-diff, Size: 7674 bytes --]

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 9f3cfd70fb..bbf091fd0e 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -668,6 +668,8 @@ isearch-mode-map
     map)
   "Keymap for `isearch-mode'.")
 
+(add-to-list 'emulation-mode-map-alists `((isearch-mode . ,isearch-mode-map)))
+
 (easy-menu-define isearch-menu-bar-map  isearch-mode-map
   "Menu for `isearch-mode'."
   '("Isearch"
@@ -952,8 +954,6 @@ isearch-hidden
 ;; The value of input-method-function when isearch is invoked.
 (defvar isearch-input-method-function nil)
 
-(defvar isearch--saved-overriding-local-map nil)
-
 ;; Minor-mode-alist changes - kind of redundant with the
 ;; echo area, but if isearching in multiple windows, it can be useful.
 ;; Also, clicking the mode-line indicator pops up
@@ -1295,11 +1295,7 @@ isearch-mode
   (setq	isearch-mode " Isearch")  ;; forward? regexp?
   (force-mode-line-update)
 
-  (setq overriding-terminal-local-map isearch-mode-map)
   (run-hooks 'isearch-mode-hook)
-  ;; Remember the initial map possibly modified
-  ;; by external packages in isearch-mode-hook.  (Bug#16035)
-  (setq isearch--saved-overriding-local-map overriding-terminal-local-map)
 
   ;; Pushing the initial state used to be before running isearch-mode-hook,
   ;; but a hook might set `isearch-push-state-function' used in
@@ -1308,10 +1304,10 @@ isearch-mode
 
   (isearch-update)
 
-  (add-hook 'pre-command-hook 'isearch-pre-command-hook)
-  (add-hook 'post-command-hook 'isearch-post-command-hook)
-  (add-hook 'mouse-leave-buffer-hook 'isearch-mouse-leave-buffer)
-  (add-hook 'kbd-macro-termination-hook 'isearch-done)
+  (add-hook 'pre-command-hook 'isearch-pre-command-hook nil t)
+  (add-hook 'post-command-hook 'isearch-post-command-hook nil t)
+  (add-hook 'mouse-leave-buffer-hook 'isearch-mouse-leave-buffer nil t)
+  (add-hook 'kbd-macro-termination-hook 'isearch-done nil t)
 
   ;; isearch-mode can be made modal (in the sense of not returning to
   ;; the calling function until searching is completed) by entering
@@ -1406,10 +1402,11 @@ isearch-done
                                      ,isearch-message
                                      ',isearch-case-fold-search)))
 
-  (remove-hook 'pre-command-hook 'isearch-pre-command-hook)
-  (remove-hook 'post-command-hook 'isearch-post-command-hook)
-  (remove-hook 'mouse-leave-buffer-hook 'isearch-mouse-leave-buffer)
-  (remove-hook 'kbd-macro-termination-hook 'isearch-done)
+  (remove-hook 'pre-command-hook 'isearch-pre-command-hook t)
+  (remove-hook 'post-command-hook 'isearch-post-command-hook t)
+  (remove-hook 'mouse-leave-buffer-hook 'isearch-mouse-leave-buffer t)
+  (remove-hook 'kbd-macro-termination-hook 'isearch-done t)
+
   (when (buffer-live-p isearch--current-buffer)
     (with-current-buffer isearch--current-buffer
       (setq isearch--current-buffer nil)
@@ -1417,7 +1414,6 @@ isearch-done
 
   ;; 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 pre-command-hook isearch-old-pre-command-hook) ; for lemacs
   (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout)
   (isearch-dehighlight)
@@ -1792,32 +1788,32 @@ isearch-edit-string
 \\[isearch-reverse-exit-minibuffer] to resume isearching backward.
 \\[isearch-complete-edit] to complete the search string using the search ring."
   (interactive)
-  (with-isearch-suspended
-   (let* ((message-log-max nil)
-	  ;; Don't add a new search string to the search ring here
-	  ;; in `read-from-minibuffer'. It should be added only
-	  ;; by `isearch-update-ring' called from `isearch-done'.
-	  (history-add-new-input nil)
-	  ;; Binding minibuffer-history-symbol to nil is a work-around
-	  ;; for some incompatibility with gmhist.
-	  (minibuffer-history-symbol)
-	  ;; Search string might have meta information on text properties.
-	  (minibuffer-allow-text-properties t))
-     (setq isearch-new-string
-	   (read-from-minibuffer
-	    (isearch-message-prefix nil isearch-nonincremental)
-	    (cons isearch-string (1+ (or (isearch-fail-pos)
-					 (length isearch-string))))
-	    minibuffer-local-isearch-map nil
-	    (if isearch-regexp
-		(cons 'regexp-search-ring
-		      (1+ (or regexp-search-ring-yank-pointer -1)))
-	      (cons 'search-ring
-		    (1+ (or search-ring-yank-pointer -1))))
-	    nil t)
-	   isearch-new-message
-	   (mapconcat 'isearch-text-char-description
-		      isearch-new-string "")))))
+  (let* ((message-log-max nil)
+	 ;; Don't add a new search string to the search ring here
+	 ;; in `read-from-minibuffer'. It should be added only
+	 ;; by `isearch-update-ring' called from `isearch-done'.
+	 (history-add-new-input nil)
+	 ;; Binding minibuffer-history-symbol to nil is a work-around
+	 ;; for some incompatibility with gmhist.
+	 (minibuffer-history-symbol)
+	 ;; Search string might have meta information on text properties.
+	 (minibuffer-allow-text-properties t))
+    (setq isearch-string
+	  (read-from-minibuffer
+	   (isearch-message-prefix nil isearch-nonincremental)
+	   (cons isearch-string (1+ (or (isearch-fail-pos)
+					(length isearch-string))))
+	   minibuffer-local-isearch-map nil
+	   (if isearch-regexp
+	       (cons 'regexp-search-ring
+		     (1+ (or regexp-search-ring-yank-pointer -1)))
+	     (cons 'search-ring
+		   (1+ (or search-ring-yank-pointer -1))))
+	   nil t)
+	  isearch-message
+	  (mapconcat 'isearch-text-char-description
+		     isearch-string ""))
+    (isearch-search-and-update)))
 
 (defun isearch-nonincremental-exit-minibuffer ()
   (interactive)
@@ -2599,7 +2595,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 (
                        ;; Key search depends on mode (bug#47755)
                        (isearch-mode nil))
                    (key-binding (this-command-keys-vector) t))))
@@ -2715,16 +2711,16 @@ isearch-char-by-name
 Completion is available like in `read-char-by-name' used by `insert-char'.
 With argument, add COUNT copies of the character."
   (interactive "p")
-  (with-isearch-suspended
-   (let ((char (read-char-by-name "Add character to search (Unicode name or hex): ")))
-     (when char
-       (let ((string (if (and (integerp count) (> count 1))
-			 (make-string count char)
-		       (char-to-string char))))
-	 (setq isearch-new-string (concat isearch-string string)
-	       isearch-new-message (concat isearch-message
-					   (mapconcat 'isearch-text-char-description
-						      string ""))))))))
+  (let ((char (read-char-by-name "Add character to search (Unicode name or hex): ")))
+    (when char
+      (let ((string (if (and (integerp count) (> count 1))
+			(make-string count char)
+		      (char-to-string char))))
+	(setq isearch-string (concat isearch-string string)
+	      isearch-message (concat isearch-message
+				      (mapconcat 'isearch-text-char-description
+						 string ""))))))
+  (isearch-search-and-update))
 
 (defun isearch-search-and-update ()
   "Do the search and update the display."
@@ -3016,9 +3012,6 @@ isearch-pre-command-hook
   (let* ((key (this-single-command-keys))
 	 (main-event (aref key 0)))
     (cond
-     ;; Don't exit Isearch if we're in the middle of some
-     ;; `set-transient-map' thingy like `universal-argument--mode'.
-     ((not (eq overriding-terminal-local-map isearch--saved-overriding-local-map)))
      ;; Don't exit Isearch for isearch key bindings.
      ((or (commandp (lookup-key isearch-mode-map key nil))
           (commandp

  reply	other threads:[~2021-04-29 16:29 UTC|newest]

Thread overview: 143+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210403001539.x4rb55dvh46rmhb3.ref@Ergus>
2021-04-03  0:15 ` Simple isearch concerns Ergus
2021-04-03  5:56   ` Thierry Volpiatto
2021-04-03  6:33   ` Manuel Uberti
2021-04-03 10:37     ` Daniel Martín
2021-04-06  7:12       ` Zhiwei Chen
2021-04-06 13:04         ` Stefan Monnier
2021-04-06 13:18           ` Gregory Heytings
2021-04-06 14:17             ` Gregory Heytings
2021-04-06 18:56               ` Juri Linkov
2021-04-06 20:10                 ` Gregory Heytings
2021-04-07 10:22                   ` Gregory Heytings
2021-04-07 16:24                     ` Juri Linkov
2021-04-07 17:03                       ` Gregory Heytings
2021-04-08 19:08                         ` Juri Linkov
2021-04-09  6:42                           ` Zhiwei Chen
2021-04-21 17:51         ` Juri Linkov
2021-04-25  8:16           ` Zhiwei Chen
2021-04-03 11:28     ` Philip Kaludercic
2021-04-03 12:26       ` Gregory Heytings
2021-04-03 16:37         ` Philip Kaludercic
2021-04-03 17:31           ` Gregory Heytings
2021-04-03 18:36             ` Philip Kaludercic
2021-04-03 19:36               ` Dmitry Gutov
2021-04-05  2:18                 ` Ergus
2021-04-05  8:39                   ` Juri Linkov
2021-04-03 17:45           ` Ergus
2021-04-22  7:15             ` Augusto Stoffel
2021-04-22 22:24               ` Juri Linkov
2021-04-25  7:15                 ` Augusto Stoffel
2021-04-25 17:24                   ` Juri Linkov
2021-04-25 18:41                     ` [External] : " Drew Adams
2021-04-26  5:39                     ` Augusto Stoffel
2021-04-27 17:41                       ` Juri Linkov
2021-04-29 16:29                         ` Juri Linkov [this message]
2021-04-29 17:50                           ` Augusto Stoffel
2021-04-29 23:00                             ` Juri Linkov
2021-04-30  7:07                               ` Augusto Stoffel
2021-04-30 16:41                                 ` Juri Linkov
2021-05-02  6:09                                   ` Augusto Stoffel
2021-05-02 22:18                                     ` Juri Linkov
2021-05-03  5:30                                       ` Augusto Stoffel
2021-05-03 16:51                                         ` Juri Linkov
2021-05-05 20:52                                           ` Juri Linkov
2021-05-07 17:14                                             ` Juri Linkov
2021-05-08 10:17                                               ` Augusto Stoffel
2021-05-09 19:12                                                 ` Juri Linkov
2021-05-09 19:53                                                   ` [External] : " Drew Adams
2021-05-10 21:11                                                     ` Juri Linkov
2021-05-10 23:06                                                       ` Drew Adams
2021-05-11 18:32                                                         ` Juri Linkov
2021-05-11 20:01                                                           ` Drew Adams
2021-05-11  6:20                                                       ` Yuri Khan
2021-05-11  9:01                                                         ` Augusto Stoffel
2021-05-11 18:37                                                         ` Juri Linkov
2021-05-11 20:56                                           ` Juri Linkov
2021-04-03 12:29       ` Gregory Heytings
2021-04-03 13:02         ` Daniel Martín
2021-04-03 13:25           ` Gregory Heytings
2021-04-03 17:25         ` Ergus
2021-04-03 10:28   ` Daniel Martín
2021-04-04 22:48   ` Juri Linkov
2021-04-04 23:27     ` Stefan Monnier
2021-04-05  1:41       ` Ergus
2021-04-05  2:22         ` [External] : " Drew Adams
2021-04-05  8:34           ` Juri Linkov
2021-04-05 14:58             ` Drew Adams
2021-04-05  2:38         ` Stefan Monnier
2021-04-05  8:30           ` Juri Linkov
2021-04-05  9:52           ` Basil L. Contovounesios
2021-04-05 15:08             ` [External] : " Drew Adams
2021-04-05  2:08     ` Ergus
2021-04-05 20:37   ` Juri Linkov
2021-04-05 21:18     ` [External] : " Drew Adams
2021-04-05 21:35       ` Juri Linkov
2021-04-05 22:37         ` Ergus
2021-04-06 19:11           ` Juri Linkov
2021-04-06 19:30             ` Eli Zaretskii
2021-04-06 20:10               ` Gregory Heytings
2021-04-07 16:30                 ` Juri Linkov
2021-04-07 17:14                   ` Gregory Heytings
2021-04-07 20:12             ` Gregory Heytings
2021-04-05 23:06         ` Drew Adams
2021-04-05 22:16     ` Ergus
2021-04-06 19:17       ` Juri Linkov
2021-04-06  0:30     ` Gregory Heytings
2021-04-06  0:44       ` Gregory Heytings
2021-04-06 18:53         ` Juri Linkov
2021-04-06 20:10           ` Gregory Heytings
2021-04-07 16:36             ` Juri Linkov
2021-04-07 17:21               ` Gregory Heytings
2021-04-07 20:12                 ` Juri Linkov
2021-04-07 21:09                   ` Gregory Heytings
2021-04-08  8:08                     ` Juri Linkov
2021-04-08  8:48                       ` Gregory Heytings
2021-04-08 19:12                         ` Juri Linkov
2021-04-08 19:27                           ` Gregory Heytings
2021-04-08 20:05                             ` Juri Linkov
2021-04-08 20:10                               ` Gregory Heytings
2021-04-08 22:40                               ` Gregory Heytings
2021-04-09  6:22                                 ` Eli Zaretskii
2021-04-09  7:20                                   ` Gregory Heytings
2021-04-09  8:37                                     ` Juri Linkov
2021-04-09 10:50                                       ` Eli Zaretskii
2021-04-09 16:49                                         ` Juri Linkov
2021-04-09 10:46                                     ` Eli Zaretskii
2021-04-09 11:27                                       ` Gregory Heytings
2021-04-09 12:45                                         ` Eli Zaretskii
2021-04-09  6:05                               ` Eli Zaretskii
2021-04-09  8:39                                 ` Juri Linkov
2021-04-09 10:51                                   ` Eli Zaretskii
2021-04-09 11:48                                     ` Gregory Heytings
2021-04-09 12:48                                       ` Eli Zaretskii
2021-04-09 13:26                                         ` Gregory Heytings
2021-04-09 13:49                                           ` Eli Zaretskii
2021-04-09 14:36                                             ` Gregory Heytings
2021-04-09 14:56                                               ` Eli Zaretskii
2021-04-09 15:25                                                 ` Gregory Heytings
2021-04-09 19:01                                                   ` Eli Zaretskii
2021-04-09 19:04                                                     ` [External] : " Drew Adams
2021-04-09 23:18                                                     ` Gregory Heytings
2021-04-10  7:17                                                       ` Eli Zaretskii
2021-04-10 10:36                                                         ` Gregory Heytings
2021-04-10 10:46                                                           ` Eli Zaretskii
2021-04-10 10:57                                                             ` Gregory Heytings
2021-04-10 11:13                                                               ` Eli Zaretskii
2021-04-10 19:02                                                               ` Now branch isearch-vertical Ergus
2021-04-10 20:00                                                                 ` Gregory Heytings
2021-04-10 22:12                                                               ` Simple isearch concerns Juri Linkov
2021-04-10 23:55                                                                 ` Gregory Heytings
2021-04-11  7:07                                                                 ` Eli Zaretskii
2021-04-11  8:49                                                                   ` Gregory Heytings
2021-04-11 10:16                                                                     ` Gregory Heytings
2021-04-11 22:09                                                                       ` Juri Linkov
2021-04-11 22:17                                                                       ` Juri Linkov
2021-04-11 23:06                                                                         ` Gregory Heytings
2021-04-11 22:05                                                                   ` Juri Linkov
2021-04-08  3:32                   ` Ergus
2022-03-03 16:36                   ` Augusto Stoffel
2022-03-03 17:50                     ` Alan Mackenzie
2022-03-03 18:39                       ` Augusto Stoffel
2022-03-03 18:46                         ` Eli Zaretskii
2021-04-07 16:41             ` Howard Melman
2021-04-06  2:21       ` Ergus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2d1ksga.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=arstoffel@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=gregory@heytings.org \
    --cc=manuel.uberti@inventati.org \
    --cc=philipk@posteo.net \
    --cc=spacibba@aol.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).