unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 70938@debbugs.gnu.org
Cc: stephen.berman@gmx.net
Subject: bug#70938: 30.0.50; Edebug appropriates overriding-terminal-local-map
Date: Wed, 15 May 2024 17:24:24 +0200	[thread overview]
Message-ID: <87o797yu6v.fsf@web.de> (raw)
In-Reply-To: <87ttj0car8.fsf@web.de> (Michael Heerdegen via's message of "Wed,  15 May 2024 00:02:51 +0200")

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

Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife
of text editors" <bug-gnu-emacs@gnu.org> writes:

> #+begin_src emacs-lisp
> (progn
>   (set-transient-map (let ((m (make-sparse-keymap)))
>                        (define-key m [?^]
>                          (lambda () (interactive) (message "Hmm...")))
>                        m))
>   (let ((overriding-terminal-local-map nil))
>     (recursive-edit)))
> #+end_src

A possible approach that seems to fix the reported bug:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-Fix-Bug-70868-Edebug-appropriates-overriding-ter.patch --]
[-- Type: text/x-diff, Size: 2433 bytes --]

From 7f5db96e7d40fc3f71c82d7a004a21bc7515c81d Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
Date: Wed, 15 May 2024 17:13:35 +0200
Subject: [PATCH] WIP: Fix Bug#70868 Edebug appropriates
 overriding-terminal-local-map

* lisp/subr.el (set-transient-map): Try to make the cleanup code more
reliable in case `overriding-terminal-local-map' gets shadowed: When the
added map is not present there, try to detect whether shadowing is
currently happening.  Delay the cleanup in this case.
---
 lisp/subr.el | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 80c7ffe32bc..2f8809d706e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -6573,12 +6573,25 @@ set-transient-map
          (clearfun (make-symbol "clear-transient-map"))
          (exitfun
           (lambda ()
-            (internal-pop-keymap map 'overriding-terminal-local-map)
-            (remove-hook 'pre-command-hook clearfun)
-            ;; Clear the prompt after exiting.
-            (when message (message ""))
-            (when set-transient-map-timer (cancel-timer set-transient-map-timer))
-            (when on-exit (funcall on-exit)))))
+            (cond
+             ((memq map overriding-terminal-local-map)
+              (internal-pop-keymap map 'overriding-terminal-local-map)
+              (remove-hook 'pre-command-hook clearfun)
+              ;; Clear the prompt after exiting.
+              (when message (message ""))
+              (when set-transient-map-timer (cancel-timer set-transient-map-timer))
+              (when on-exit (funcall on-exit)))
+             (;; FIXME: We rather want something like
+              ;; (variable-references-default-toplevel-value-p
+              ;;  'overriding-terminal-local-map)
+              (eq overriding-terminal-local-map
+                  (default-toplevel-value 'overriding-terminal-local-map))
+              ;; We are probably done:
+              (remove-hook 'pre-command-hook clearfun))
+             ;; If none of these conditions was fulfilled,
+             ;; overriding-terminal-local-map is currently shadowed - keep
+             ;; clearfun in 'pre-command-hook
+             ))))
     ;; Don't use letrec, because equal (in add/remove-hook) could get trapped
     ;; in a cycle. (bug#46326)
     (fset clearfun
--
2.39.2


[-- Attachment #3: Type: text/plain, Size: 83 bytes --]


Comments, corrections, enhancements and better ideas all very welcome.


Michael.

  reply	other threads:[~2024-05-15 15:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 13:24 bug#70938: 30.0.50; Edebug appropriates overriding-terminal-local-map Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 19:59 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 20:15   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 21:23 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 22:02   ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-15 15:24     ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-05-15 18:51       ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-21  9:15         ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-27 14:37           ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-27 15:48             ` Stephen Berman 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=87o797yu6v.fsf@web.de \
    --to=bug-gnu-emacs@gnu.org \
    --cc=70938@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=stephen.berman@gmx.net \
    /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).