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.devel Subject: Re: Simple isearch concerns Date: Tue, 11 May 2021 23:56:14 +0300 Organization: LINKOV.NET Message-ID: <871radvvkh.fsf@mail.linkov.net> References: <20210403001539.x4rb55dvh46rmhb3.ref@Ergus> <2599ffef-4f70-025c-5f9c-61b9ac94faf8@inventati.org> <87eefrbo9k.fsf@posteo.net> <7473b27b2b479f5686af@heytings.org> <87tuon9vf1.fsf@posteo.net> <20210403174508.xwr5uc36dzityitn@Ergus> <87wnsurdr7.fsf@gmail.com> <87fszij6to.fsf@mail.linkov.net> <87v98asulc.fsf@gmail.com> <87pmyimiwd.fsf@mail.linkov.net> <87bla11u5q.fsf@gmail.com> <87lf937hgk.fsf@mail.linkov.net> <87y2d1ksga.fsf@mail.linkov.net> <87r1it7zfw.fsf@gmail.com> <87v98466it.fsf@mail.linkov.net> <87bl9wcksv.fsf@gmail.com> <87tunnzqci.fsf@mail.linkov.net> <87bl9tmzun.fsf@gmail.com> <87y2cwhiti.fsf@mail.linkov.net> <87h7jk75b7.fsf@gmail.com> <87k0ofyd4p.fsf@mail.linkov.net> 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="21814"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: Philip Kaludercic , emacs-devel@gnu.org, Manuel Uberti , Gregory Heytings , Ergus To: Augusto Stoffel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 11 23:05:19 2021 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 1lgZZ8-0005Yq-LO for ged-emacs-devel@m.gmane-mx.org; Tue, 11 May 2021 23:05:18 +0200 Original-Received: from localhost ([::1]:55696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgZZ7-00018j-IW for ged-emacs-devel@m.gmane-mx.org; Tue, 11 May 2021 17:05:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgZWc-0006FI-Mt for emacs-devel@gnu.org; Tue, 11 May 2021 17:02:42 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:49737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgZWV-0001Kn-5e for emacs-devel@gnu.org; Tue, 11 May 2021 17:02:41 -0400 X-Originating-IP: 91.129.102.166 Original-Received: from mail.gandi.net (m91-129-102-166.cust.tele2.ee [91.129.102.166]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id CDCA7FF804; Tue, 11 May 2021 21:02:29 +0000 (UTC) In-Reply-To: <87k0ofyd4p.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 03 May 2021 19:51:18 +0300") Received-SPF: pass client-ip=217.70.183.199; envelope-from=juri@linkov.net; helo=relay9-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:269190 Archived-At: --=-=-= Content-Type: text/plain > 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))) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=overriding_keymap.patch 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); --=-=-=--