bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68995: [PATCH] 30.0.50; electric-pair-mode and read-char-from-minibu


From: Stefan Monnier
Subject: bug#68995: [PATCH] 30.0.50; electric-pair-mode and read-char-from-minibuffer
Date: Fri, 09 Feb 2024 14:10:23 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii [2024-02-09 08:47:57] wrote:

>> From: Paul Nelson <ultrono@gmail.com>
>> Date: Thu, 8 Feb 2024 23:52:50 +0100
>> 
>> Steps to reproduce:
>> 
>> 1. Emacs -Q
>> 2. M-x electric-pair-mode
>> 3. M-: (read-char-from-minibuffer "test: ")
>> 4. Hit "(".
>> 
>> The minibuffer then reads "()"; to get "(" accepted, we need to backspace.
>> 
>> If we instead hit ")", then we get the error "No matching parenthesis found".
>> 
>> I noticed this bug because it complicates using zap-to-char with
>> electric-pair-mode.
>> 
>> The bug was introduced in 68dd520e39eccb1be9366add1e3298318e5010de, in
>> response to https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65805.  In
>> that commit, the line that remaps self-insert-command was commented.
>> Uncommenting that line fixes the issue.
>
> Adding Stefan who made the offending commit.

I pushed the patch below which should fix both problems.


        Stefan


diff --git a/lisp/subr.el b/lisp/subr.el
index e53ef505522..9e92a4c457f 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3726,11 +3723,11 @@ read-char-from-minibuffer
          (this-command this-command)
          (result (minibuffer-with-setup-hook
                     (lambda ()
+                      (setq-local post-self-insert-hook nil)
                       (add-hook 'post-command-hook
                                 (lambda ()
-                                  ;; FIXME: Should we use `<='?
-                                  (if (= (1+ (minibuffer-prompt-end))
-                                         (point-max))
+                                  (if (<= (1+ (minibuffer-prompt-end))
+                                          (point-max))
                                        (exit-minibuffer)))
                                 nil 'local))
                    ;; Disable text conversion if it is enabled.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]