Subject: 30.1.90; todo-mode item insertion bug (followup bug)
From: Stephen Berman <[email-masked]>
To: [email-masked]
Date: Tue, 20 May 2025 10:58:40 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

0. HOME=/tmp/${USER} emacs -Q  (start Emacs in a clean environment)
1. Type `M-x todo-show' and at the prompt type "test RET test RET test
   RET" to initialize the Todo file "test" with the category "test"
   containing the item "test".  The current buffer displays that
   category in todo-mode.
2. (Sanity check) In the current buffer with point on the item type `e'
   to begin an item editing command; the echo area now displays the
   prompt "Press a key (so far ‘e’): e=>edit h=>header m=>multiline
   y=>diary k=>nonmarking d=>date t=>time".  Type `C-g' to cancel the
   command.
3. Now type `i i' and at the prompt "test2 RET RET" to create the item
   "test2" with priority 1.
4. Now (immediately after step 3, without typing any key in between)
   type `e' to begin an item editing command for item "test2":
=> The echo area displays the message "‘e’ is not a valid remaining item
   insertion key".  Typing `e' again now displays the item editing
   prompt.

The bug in step 4 (`e' at first not being recognized as a valid Todo
mode command key) is due to commit 7f80070232, which provided a fix for
bug#70937.  It turns out this fix was incomplete; the following patch
fills in the gap:

diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 27678328b4a..2bd8b89b58b 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -5821,7 +5821,13 @@ todo-insert-item--next-param
       (if (memq last '(default copy))
 	  (progn
 	    (setq params0 nil)
-            (funcall gen-and-exec))
+            (funcall gen-and-exec)
+	    ;; Since the item insertion command is now done, unset
+	    ;; transient map to ensure the next Todo mode key is
+	    ;; recognized (bug#xxxxx).  (Only for "default" and "copy"
+	    ;; parameters: for others, `last' may not yet be the final
+	    ;; parameter, so the map must still be evaluated.)
+	    (setq map nil))
         (let ((key (funcall key-of last)))
 	  (funcall add-to-prompt key (make-symbol
                                       (concat (symbol-name last) ":GO!")))

Since this fixes a bug introduced in Emacs 30.1, I
think it should be committed to the emacs-30 branch; is that ok?

In GNU Emacs 30.1.90 (build 2, x86_64-pc-linux-gnu, GTK+ Version
 3.24.49, cairo version 1.18.4) of 2025-05-20 built on strobelfs2
Repository revision: 328b316764f0b06f7b8c774e9855ff2426a13bfe
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: Linux From Scratch r12.3-20

Configured using:
 'configure -C 'CFLAGS=-Og -g3' PKG_CONFIG_PATH=/opt/qt6/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB