From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65805: 30.0.50; quoted-insert doesn't work in zap-to-char Date: Wed, 13 Sep 2023 13:48:34 -0400 Message-ID: References: <834jk6yqbh.fsf@gnu.org> <86msxx3nw9.fsf@mail.linkov.net> <86pm2mtatn.fsf@mail.linkov.net> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33835"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , Filipp Gunbin , 65805@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 13 19:51:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qgU1C-0008bE-CQ for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Sep 2023 19:51:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgU13-0001ni-2L; Wed, 13 Sep 2023 13:51:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgU0x-0001lC-6a for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 13:50:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgU0v-0003RU-4Z for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 13:50:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgU10-0000i5-Ar for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 13:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Sep 2023 17:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65805 X-GNU-PR-Package: emacs Original-Received: via spool by 65805-submit@debbugs.gnu.org id=B65805.16946274052655 (code B ref 65805); Wed, 13 Sep 2023 17:51:02 +0000 Original-Received: (at 65805) by debbugs.gnu.org; 13 Sep 2023 17:50:05 +0000 Original-Received: from localhost ([127.0.0.1]:35962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgU04-0000gl-LN for submit@debbugs.gnu.org; Wed, 13 Sep 2023 13:50:05 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:52989) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgTzw-0000g4-A7 for 65805@debbugs.gnu.org; Wed, 13 Sep 2023 13:50:02 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 7EE1680551; Wed, 13 Sep 2023 13:49:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1694627384; bh=RJ5GPaB+ShfX8zBowhJwK2TnN540SIzgCiy4d/iTgh4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=in6jOXwfyd3Z99w29UNpmiA/ATVA1WqDsmGDiUUtjd9fIWEeiRQB2dDYVXjC3rApc BeRCZlgjwyd9kRHmJHV49fx1sTytxNxx7XFVRTq1Cru4dvmx/zkk1LCDRtZ2T74mot 3axKvC7D33SiIbHG6NRZXPTH9l4vdwdRziOH/7KZVyb5c5mw9EZux7LmffxARPNi+J 5tvlg5qdY8toQ+zPHmhYJTxCqa2nPncrNdTiHrFxyARB7owxnOspKehqHho+mN0Vd4 UPvzrhi55jP3xzvF6dGa6jqCQsYeRlz88hz0BVyp/flq/wgh/rBpxI2ryamA4zJuvc F5g2UCfhD6GEw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2408F803A6; Wed, 13 Sep 2023 13:49:44 -0400 (EDT) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0F5591203C7; Wed, 13 Sep 2023 13:49:44 -0400 (EDT) In-Reply-To: <86pm2mtatn.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 13 Sep 2023 19:39:32 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270342 Archived-At: >> `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. Yes, I tested `C-y` as well :-) Tho the ideal behavior when doing things like "C-y inserts a string of length > 1" is unclear. > @@ -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? I think it's still needed (RET would otherwise cause exit with an empty minibuffer, and hence no "char"). > @@ -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. Thank you. > Maybe this bug number should be mentioned in the comments. [ Or maybe I should have bothered to `C-x v h` :-( ] > Interesting that [remap self-insert-command] is applied even to the > commands explicitly bound to 'self-insert-command' in the same keymap. Indeed, the command remapping doesn't pay attention to "in which keymap did I find this binding". We could try and refine it, but it could be a lot of work, I think. > I see no way to override this. So 'read-char-from-minibuffer-insert-char' > can't be replaced with 'self-insert-command'. Exactly. We could use something like: (defalias 'read-char-from-minibuffer-insert-char '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'. Indeed, that's one option. But I was thinking that maybe we should try and signal an error. Do the users really expect that yanking a string into that prompt will end up picking just the first char of that string? Stefan