unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Visuwesh <visuwesh@tutanota.com>
Cc: 51390@debbugs.gnu.org
Subject: bug#51390: 29.0.50; repeat-mode: Fails to repeat keys in global-map(?)
Date: Sun, 21 Nov 2021 22:49:40 +0200	[thread overview]
Message-ID: <86sfvpxmhn.fsf@mail.linkov.net> (raw)
In-Reply-To: <MmsHxhi--3-2@tutanota.com> (Visuwesh via's message of "Mon, 25 Oct 2021 18:32:33 +0200 (CEST)")

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

>         (defvar teest
>           (let ((map (make-sparse-keymap)))
>             (define-key map "n" #'next-line)
>             (define-key map "p" #'previous-line)
>             map))
>
>         (put 'next-line 'repeat-map 'teest)
>         (put 'previous-line 'repeat-map 'teest)
>...
> 4. Type C-n.  Notice that it does not trigger the repeat map.

I tried to implement what you asked to do, but got horrible results
caused too much damage.  Here is the lossage explaining the problem:

 C-<tab>           ;; tab-next
 o                 ;; tab-next
 n                 ;; gnus-group-next-unread-group

i.e. I typed C-<tab> to switch to the next tab with the text buffer
where I started to type text that begins with the letters "on..."

But instead of inserting letters to the buffer, the letter "o"
switched to the second next tab.  This tab contained the Gnus buffer
where typing the second letter "n" called the bound command
gnus-group-next-unread-group, and I lost all unread messages.

But I never had such a problem when the repeating sequence was
activated only by 'C-x t o ... o o ...' instead of 'C-<tab> o o o ...'
because 'C-<tab>' is a single key, there is no need to activate
other keys doing the same.

This means that by default this behavior should be disabled.
But maybe a new variable should allow to skip this check:


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

diff --git a/lisp/repeat.el b/lisp/repeat.el
index 4dcd353e34..03e5b032fe 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -360,6 +360,12 @@ repeat-keep-prefix
   :group 'convenience
   :version "28.1")
 
+(defcustom repeat-foreign-key nil
+  "Whether to check if the last key exists in the repeat map."
+  :type 'boolean
+  :group 'convenience
+  :version "28.1")
+
 (defcustom repeat-echo-function #'repeat-echo-message
   "Function to display a hint about available keys.
 Function is called after every repeatable command with one argument:
@@ -428,7 +434,8 @@ repeat-post-hook
                        (eq current-minibuffer-command (cdr repeat--prev-mb)))
                    ;; Exit when the last char is not among repeatable keys,
                    ;; so e.g. `C-x u u' repeats undo, whereas `C-/ u' doesn't.
-                   (or (lookup-key map (this-command-keys-vector))
+                   (or repeat-foreign-key
+                       (lookup-key map (vector last-nonmenu-event))
                        prefix-arg))
 
               ;; Messaging

  parent reply	other threads:[~2021-11-21 20:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 16:32 bug#51390: 29.0.50; repeat-mode: Fails to repeat keys in global-map(?) Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-25 17:16 ` Juri Linkov
2021-10-25 17:26   ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-25 17:41     ` Juri Linkov
2021-11-15 18:54       ` Juri Linkov
2021-11-16  8:43         ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-16 20:18           ` Juri Linkov
2021-11-17  1:47             ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-17  7:54               ` Juri Linkov
2021-11-20 13:23                 ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-20 19:12                   ` Juri Linkov
2021-11-21  2:21                     ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-21 20:49 ` Juri Linkov [this message]
2021-11-22  3:44   ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-22  3:45     ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-25  3:32   ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-25  7:54     ` Juri Linkov
2021-11-25  8:11       ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-30 19:09         ` Juri Linkov
2021-12-02 10:23           ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=86sfvpxmhn.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=51390@debbugs.gnu.org \
    --cc=visuwesh@tutanota.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).