unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, Filipp Gunbin <fgunbin@fastmail.fm>,
	65805@debbugs.gnu.org
Subject: bug#65805: 30.0.50; quoted-insert doesn't work in zap-to-char
Date: Wed, 13 Sep 2023 19:39:32 +0300	[thread overview]
Message-ID: <86pm2mtatn.fsf@mail.linkov.net> (raw)
In-Reply-To: <jwvr0n9dggy.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 07 Sep 2023 13:48:31 -0400")

>> I have a patch where exit-minibuffer in read-char-from-minibuffer-map
>> is bound to a new command that ensures that the minibuffer contains
>> exactly 1 character before exiting.  But need more testing to see
>> what is better.
>
> `read-char-from-minibuffer` usually doesn't require the user to use an
> explicit key to exit (because it tries to mimic `read-char`).

I don't remember how I got into a situation that required typing RET
to exit the minibuffer.  Probably pasted a character into the minibuffer
with C-y.  I see that your patch handles this now.

@@ -3499,7 +3499,7 @@ read-char-from-minibuffer-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
 
-    (define-key map [remap self-insert-command] #'read-char-from-minibuffer-insert-char)
+    ;; (define-key map [remap self-insert-command] #'read-char-from-minibuffer-insert-char)
     (define-key map [remap exit-minibuffer] #'read-char-from-minibuffer-insert-other)

Maybe remapping exit-minibuffer is not needed anymore too?

@@ -3530,7 +3530,7 @@ read-char-from-minibuffer-insert-other
 such key, this command discard all minibuffer input and displays
 an error message."
   (interactive)
-  (when (minibufferp)
+  (when (minibufferp) ;;FIXME: Why?

Because of bug#45029.  Maybe this bug number should be mentioned
in the comments.

@@ -3578,6 +3578,10 @@ read-char-from-minibuffer
                                         (interactive)
                                         (let ((help-form msg)) ; lexically bound msg
                                           (help-form-show)))))
+                        ;; FIXME: We use `read-char-from-minibuffer-insert-char'
+                        ;; here only as a kind of alias of `self-insert-command'
+                        ;; to prevent those keys from being remapped to
+                        ;; `read-char-from-minibuffer-insert-other'.
                         (dolist (char chars)
                           (define-key map (vector char)
                                       #'read-char-from-minibuffer-insert-char))
                         (define-key map [remap self-insert-command]
                                     #'read-char-from-minibuffer-insert-other)

Interesting that [remap self-insert-command] is applied even to the
commands explicitly bound to 'self-insert-command' in the same keymap.
I see no way to override this.  So 'read-char-from-minibuffer-insert-char'
can't be replaced with 'self-insert-command'.

@@ -3589,7 +3593,15 @@ read-char-from-minibuffer
                 read-char-from-minibuffer-map))
          ;; Protect this-command when called from pre-command-hook (bug#45029)
          (this-command this-command)
-         (result (progn
+         (result (minibuffer-with-setup-hook
+		     (lambda ()
+		       (add-hook 'post-command-hook
+				 (lambda ()
+				   ;; FIXME: Should we use `<='?
+				   (if (= (1+ (minibuffer-prompt-end))
+					  (point-max))
+                                       (exit-minibuffer)))
+				 nil 'local))

I think we should use `<=' to handle the case when a string with
more than 1 character is pasted with 'C-y'.  This still requires
some special-handling like I intended to do in a new command that
exits the minibuffer where it should remove extra characters to
leave only one: either the first or the last one.  Perhaps leaving
the first character makes more sense.





  reply	other threads:[~2023-09-13 16:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07 14:53 bug#65805: 30.0.50; quoted-insert doesn't work in zap-to-char Filipp Gunbin
2023-09-07 15:07 ` Eli Zaretskii
2023-09-07 16:47   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-07 17:13     ` Juri Linkov
2023-09-07 17:48       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-13 16:39         ` Juri Linkov [this message]
2023-09-13 17:48           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-14  6:45             ` Juri Linkov
2023-09-10  7:17     ` Eli Zaretskii
2023-09-10 23:14       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 11:44         ` Eli Zaretskii
2023-09-12 17:00           ` Stefan Monnier 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=86pm2mtatn.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=65805@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=fgunbin@fastmail.fm \
    --cc=monnier@iro.umontreal.ca \
    /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).