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>,
	emacs-devel@gnu.org, Manuel Uberti <manuel.uberti@inventati.org>,
	Gregory Heytings <gregory@heytings.org>, Ergus <spacibba@aol.com>
Subject: Re: Simple isearch concerns
Date: Tue, 11 May 2021 23:56:14 +0300	[thread overview]
Message-ID: <871radvvkh.fsf@mail.linkov.net> (raw)
In-Reply-To: <87k0ofyd4p.fsf@mail.linkov.net> (Juri Linkov's message of "Mon,  03 May 2021 19:51:18 +0300")

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

> Testing shows that the `isearch-buffer-local' change works fine,
> with only one deficiency: as (info "(elisp) Searching Keymaps") says
> get-char-property takes precedence over emulation-mode-map-alists.
>
> This means that typing isearch characters when point is e.g.
> on a Gnus attachment line, typing a character like 'o' bound
> to 'gnus-mime-save-part' will exit isearch and run this command.
>
> I see no way to workaround this limitation.

Here is a patch that allows minor mode keys to take precedence over
char-property keys, by adding a special property to mode symbol, e.g.

  (put 'isearch-mode 'overriding-keymap t)

indicated in the decision tree by NEW:

     (or (if overriding-terminal-local-map
             (FIND-IN overriding-terminal-local-map))
         (if overriding-local-map
             (FIND-IN overriding-local-map)
           (or ;; => NEW: modes with overriding-keymap
               (FIND-IN (get-char-property (point) 'keymap))
               (FIND-IN-ANY emulation-mode-map-alists)
               (FIND-IN-ANY minor-mode-overriding-map-alist)
               (FIND-IN-ANY minor-mode-map-alist)
               (if (get-text-property (point) 'local-map)
                   (FIND-IN (get-char-property (point) 'local-map))
                 (FIND-IN (current-local-map)))))
         (FIND-IN (current-global-map)))


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: overriding_keymap.patch --]
[-- Type: text/x-diff, Size: 5338 bytes --]

diff --git a/src/keymap.c b/src/keymap.c
index fb8eceaec1..c3801cca67 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1331,7 +1331,7 @@ silly_event_symbol_error (Lisp_Object c)
    list, let the key sequence be read, and hope some other piece of
    code signals the error.  */
 ptrdiff_t
-current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
+current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr, int overriding)
 {
   ptrdiff_t i = 0;
   Lisp_Object alist, assoc, var, val;
@@ -1358,7 +1358,10 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
 	if ((assoc = XCAR (alist), CONSP (assoc))
 	    && (var = XCAR (assoc), SYMBOLP (var))
 	    && (val = find_symbol_value (var), !EQ (val, Qunbound))
-	    && !NILP (val))
+	    && !NILP (val)
+	    && (overriding == 0
+		|| (overriding == 1 && NILP (Fget (var, Qoverriding_keymap)))
+		|| (overriding == 2 && !NILP (Fget (var, Qoverriding_keymap)))))
 	  {
 	    Lisp_Object temp;
 
@@ -1556,7 +1559,7 @@ DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps,
 	keymaps = Fcons (local_map, keymaps);
 
       /* Now put all the minor mode keymaps on the list.  */
-      nmaps = current_minor_maps (0, &maps);
+      nmaps = current_minor_maps (0, &maps, 1);
 
       for (int i = --nmaps; i >= 0; i--)
 	if (!NILP (maps[i]))
@@ -1565,6 +1568,12 @@ DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps,
       if (!NILP (keymap))
 	keymaps = Fcons (keymap, keymaps);
 
+      /* Now put all the overriding minor mode keymaps on the list.  */
+      nmaps = current_minor_maps (0, &maps, 2);
+      for (int i = --nmaps; i >= 0; i--)
+	if (!NILP (maps[i]))
+	  keymaps = Fcons (maps[i], keymaps);
+
       if (!NILP (olp) && !NILP (otlp))
 	keymaps = Fcons (otlp, keymaps);
     }
@@ -1658,7 +1667,7 @@ DEFUN ("minor-mode-key-binding", Fminor_mode_key_binding, Sminor_mode_key_bindin
   (Lisp_Object key, Lisp_Object accept_default)
 {
   Lisp_Object *modes, *maps;
-  int nmaps = current_minor_maps (&modes, &maps);
+  int nmaps = current_minor_maps (&modes, &maps, 0);
   Lisp_Object binding = Qnil;
 
   int j;
@@ -1719,7 +1728,7 @@ DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_
   (void)
 {
   Lisp_Object *maps;
-  int nmaps = current_minor_maps (0, &maps);
+  int nmaps = current_minor_maps (0, &maps, 0);
 
   return Flist (nmaps, maps);
 }
@@ -2713,7 +2722,7 @@ DEFUN ("describe-buffer-bindings", Fdescribe_buffer_bindings, Sdescribe_buffer_b
 	 minor modes correctly.  */
       Fset_buffer (buffer);
 
-      int nmaps = current_minor_maps (&modes, &maps);
+      int nmaps = current_minor_maps (&modes, &maps, 0);
       Fset_buffer (outbuf);
 
       start1 = get_local_map (BUF_PT (XBUFFER (buffer)),
@@ -3124,6 +3133,7 @@ syms_of_keymap (void)
   DEFSYM (Qdescribe_map_tree, "describe-map-tree");
 
   DEFSYM (Qkeymap_canonicalize, "keymap-canonicalize");
+  DEFSYM (Qoverriding_keymap, "overriding-keymap");
 
   /* Now we are ready to set up this property, so we can
      create char tables.  */
diff --git a/src/keymap.h b/src/keymap.h
index f417301c8f..b01698d394 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -36,7 +36,7 @@ #define KEYMAPP(m) (!NILP (get_keymap (m, false, false)))
 extern char *push_key_description (EMACS_INT, char *);
 extern Lisp_Object access_keymap (Lisp_Object, Lisp_Object, bool, bool, bool);
 extern Lisp_Object get_keymap (Lisp_Object, bool, bool);
-extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **);
+extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **, int);
 extern void initial_define_lispy_key (Lisp_Object, const char *, const char *);
 extern void syms_of_keymap (void);
 
diff --git a/src/keyboard.c b/src/keyboard.c
index 47b5e59024..a64d99e4c3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7395,7 +7395,7 @@ menu_bar_items (Lisp_Object old)
 	   properties may not work reliable, as they are only
 	   recognized when the menu-bar (or mode-line) is updated,
 	   which does not normally happen after every command.  */
-	ptrdiff_t nminor = current_minor_maps (NULL, &tmaps);
+	ptrdiff_t nminor = current_minor_maps (NULL, &tmaps, 0);
 	SAFE_NALLOCA (maps, 1, nminor + 4);
 	nmaps = 0;
 	Lisp_Object tem = KVAR (current_kboard, Voverriding_terminal_local_map);
@@ -7948,7 +7948,7 @@ tab_bar_items (Lisp_Object reuse, int *nitems)
 	 properties may not work reliably, as they are only
 	 recognized when the tab-bar (or mode-line) is updated,
 	 which does not normally happen after every command.  */
-      ptrdiff_t nminor = current_minor_maps (NULL, &tmaps);
+      ptrdiff_t nminor = current_minor_maps (NULL, &tmaps, 0);
       SAFE_NALLOCA (maps, 1, nminor + 4);
       nmaps = 0;
       Lisp_Object tem = KVAR (current_kboard, Voverriding_terminal_local_map);
@@ -8332,7 +8332,7 @@ tool_bar_items (Lisp_Object reuse, int *nitems)
 	 properties may not work reliably, as they are only
 	 recognized when the tool-bar (or mode-line) is updated,
 	 which does not normally happen after every command.  */
-      ptrdiff_t nminor = current_minor_maps (NULL, &tmaps);
+      ptrdiff_t nminor = current_minor_maps (NULL, &tmaps, 0);
       SAFE_NALLOCA (maps, 1, nminor + 4);
       nmaps = 0;
       Lisp_Object tem = KVAR (current_kboard, Voverriding_terminal_local_map);

  parent reply	other threads:[~2021-05-11 20:56 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
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 [this message]
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=871radvvkh.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).