Subject: bug#51390: 29.0.50; repeat-mode: Fails to repeat keys in global-map(?)

From: Visuwesh <[email-masked]>
Date: Mon, 25 Oct 2021 18:32:33 +0200 (CEST)

Hello,

I'm trying to make next/previous-line repeatable by using the follow
code snippet,

        (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)

However, next-line triggers the repeat map only when it is run in the
last line of the buffer, and similarly previous-line triggers the repeat
map only when it is run in the first line of the buffer.

A similar behaviour is observed when replacing next-line and
previous-line with forward-char at BOB and backward-char at EOB
respectively.  If I make move-end/beginning-of-line repeatable instead,
 the repeat map does not get triggered at all (regardless of where the 
point is).

To reproduce the issue,

1. emacs -Q
2. Evaluate the expressions in this message.  Turn on repeat-mode.
3. Switch to the *scratch* buffer and press M-<.
4. Type C-n.  Notice that it does not trigger the repeat map.
5. Type C-p twice.  The repeat map gets triggered in the second keypress
i.e., when the point is at the first line.

I can reproduce this issue in the master branch and in an Emacs 28 build
with emacs-repository-version fc8df2561b8e37089463d0d4d008d73e23cb2dc5.

Regards.

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.16.0)
Repository revision: 709e1e59f0f4db24580566f5ca661e730afbf9a2
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12012000
System Description: NixOS 21.11 (Porcupine)

Configured using:
'configure
--prefix=/nix/store/w1fmhydqpvjl9lz9frqsc8203d0nqd76-emacs-git-20211025.0
--disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft
--with-cairo'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE
XIM XPM GTK3 ZLIB

Important settings:
  value of $EMACSLOADPATH:
  value of $EMACSNATIVELOADPATH: /nix/store/llq9dy2f8zmf697jwrnly37g66pwwq1y-emacs-packages-deps/share/emacs/native-lisp::
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  repeat-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils edebug
backtrace pulse color thingatpt xref project ring jka-compr find-func
cl-print dabbrev kmacro facemenu two-column time-date cl-extra seq gv
subr-x byte-opt bytecomp byte-compile cconv help-fns radix-tree
cus-start cus-load repeat misearch multi-isearch help-mode cl-loaddefs
cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 106524 8571)
(symbols 48 9251 1)
(strings 32 25944 1615)
(string-bytes 1 863874)
(vectors 16 20434)
(vector-slots 8 465587 10211)
(floats 8 124 87)
(intervals 56 716 1127)
(buffers 992 14))