From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Aug 2021 20:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 49931@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162836861629722 (code B ref -1); Sat, 07 Aug 2021 20:37:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 Aug 2021 20:36:56 +0000 Received: from localhost ([127.0.0.1]:53210 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCT3u-0007jI-C9 for submit@debbugs.gnu.org; Sat, 07 Aug 2021 16:36:56 -0400 Received: from lists.gnu.org ([209.51.188.17]:46364) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCQ03-0002wc-AG for submit@debbugs.gnu.org; Sat, 07 Aug 2021 13:20:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCQ03-0001yX-3X for bug-gnu-emacs@gnu.org; Sat, 07 Aug 2021 13:20:43 -0400 Received: from w1.tutanota.de ([81.3.6.162]:50584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCPzz-0008RU-Uq for bug-gnu-emacs@gnu.org; Sat, 07 Aug 2021 13:20:42 -0400 Received: from w3.tutanota.de (unknown [192.168.1.164]) by w1.tutanota.de (Postfix) with ESMTP id EE6D8FA03AD for ; Sat, 7 Aug 2021 17:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1628356835; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=wY+RVIQvmvo6ltC9eQgT7S2VGu68vZxW0Nn4YYb9kgE=; b=XznsJhLP0Cn2RoJupxwX+KDy5aUkjQ0rI3RDqE/xm9Ft9TY3kD8G9uoipav4teBf mXdGS9D9HCtH3oQUFrrdQ0XAam7pmyYLJjfonAwc6aa0digGyDDj4eie6M3MIHL7MU5 EPfFJU3bZtlVwaCBpvW6koGrLDdrkOaHi1wyDBmQ35BDPpEWloTJPsSG3HKIfeDs9et WgU6ibmyvpnkucLNajohyPfqDvykcnr4NzpDNuQ/52OB8Ve13eMxwUl5KLb3wqO6ZHA MvPihhP/On3/V8+OWmkLXA0LthUqfwHAJHTubsgN/T3lFt7k9iO0W6BRIjzXQ/nPhnF m67ajSUJKw== Date: Sat, 7 Aug 2021 19:20:35 +0200 (CEST) From: Visuwesh Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=81.3.6.162; envelope-from=visuwesh@tutanota.com; helo=w1.tutanota.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Mailman-Approved-At: Sat, 07 Aug 2021 16:36:53 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) When one edits the minibuffer content after the creation of *Completions* buffer, `choose-completion' incorrectly submits the wrong string to the command upon selecting a candidate.=C2=A0 To reproduce, 1. Start emacs -Q. 2. Type the following key sequence: C-h f emacs- TAB. 3. Type a. 4. Select `emacs-bzr-get-version' from the *Completions* buffer. 5. "user-error: Symbol=E2=80=99s function definition is void: emacs-bzr-get-versiona" is shown in the echo area. What I expected to happen: I expected `choose-completion' to submit "emacs-bzr-get-version" to describe-function, not "emacs-bzr-get-versiona". Regards. [=C2=A0 P.S. Please add me to the CCs since I'm not subscribed to the maili= ng list.=C2=A0 ] In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, c= airo version 1.16.0) Repository revision: 0b049fe71d73f6885a3c81ea31829e3befc18933 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: NixOS 21.11 (Porcupine) Configured using: 'configure --prefix=3D/nix/store/6gh7ijbrfaahs78syqhjc6f2y7gi76h2-emacs-git-20210806.0 --disable-build-details --with-modules --with-x-toolkit=3Dgtk3 --with-xft --with-cairo' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: =C2=A0 value of $EMACSLOADPATH: =C2=A0 value of $EMACSNATIVELOADPATH: /nix/store/ld3lv1bbi9zx15k3h5hni467gy= qxckjr-emacs-packages-deps/share/emacs/native-lisp:: =C2=A0 value of $LANG: en_GB.UTF-8 =C2=A0 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: =C2=A0 tooltip-mode: t =C2=A0 global-eldoc-mode: t =C2=A0 eldoc-mode: t =C2=A0 electric-indent-mode: t =C2=A0 mouse-wheel-mode: t =C2=A0 tool-bar-mode: t =C2=A0 menu-bar-mode: t =C2=A0 file-name-shadow-mode: t =C2=A0 global-font-lock-mode: t =C2=A0 font-lock-mode: t =C2=A0 blink-cursor-mode: t =C2=A0 auto-composition-mode: t =C2=A0 auto-encryption-mode: t =C2=A0 auto-compression-mode: t =C2=A0 line-number-mode: t =C2=A0 indent-tabs-mode: t =C2=A0 transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map text-property-search seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date subr-x thingatpt help-fns radix-tree help-mode cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 59485 9215) (symbols 48 6917 1) (strings 32 21260 1804) (string-bytes 1 666531) (vectors 16 14618) (vector-slots 8 188838 7589) (floats 8 21 50) (intervals 56 398 0) (buffers 992 11)) From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Aug 2021 05:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Visuwesh Cc: 49931@debbugs.gnu.org Received: via spool by 49931-submit@debbugs.gnu.org id=B49931.162839968221098 (code B ref 49931); Sun, 08 Aug 2021 05:15:01 +0000 Received: (at 49931) by debbugs.gnu.org; 8 Aug 2021 05:14:42 +0000 Received: from localhost ([127.0.0.1]:53487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCb90-0005UE-1J for submit@debbugs.gnu.org; Sun, 08 Aug 2021 01:14:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38744) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCb8w-0005Tz-Js for 49931@debbugs.gnu.org; Sun, 08 Aug 2021 01:14:41 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54198) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCb8r-00087E-13; Sun, 08 Aug 2021 01:14:33 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3002 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCb8p-0004ba-OY; Sun, 08 Aug 2021 01:14:32 -0400 Date: Sun, 08 Aug 2021 08:14:35 +0300 Message-Id: <83tuk0h610.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (bug-gnu-emacs@gnu.org) References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sat, 7 Aug 2021 19:20:35 +0200 (CEST) > From: Visuwesh via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > When one edits the minibuffer content after the creation of > *Completions* buffer, `choose-completion' incorrectly submits the wrong > string to the command upon selecting a candidate.  To reproduce, > > 1. Start emacs -Q. > 2. Type the following key sequence: C-h f emacs- TAB. > 3. Type a. > 4. Select `emacs-bzr-get-version' from the *Completions* buffer. > 5. "user-error: Symbol’s function definition is void: > emacs-bzr-get-versiona" is shown in the echo area. > > What I expected to happen: > > I expected `choose-completion' to submit "emacs-bzr-get-version" to > describe-function, not "emacs-bzr-get-versiona". You expected Emacs to ignore what you type? Why? What you type after TAB is used to narrow the list of candidates when you type the next TAB, or continue typing after the first TAB completed some of the name for you. This is the intended behavior. From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Aug 2021 07:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 49931@debbugs.gnu.org Received: via spool by 49931-submit@debbugs.gnu.org id=B49931.162840616032093 (code B ref 49931); Sun, 08 Aug 2021 07:03:02 +0000 Received: (at 49931) by debbugs.gnu.org; 8 Aug 2021 07:02:40 +0000 Received: from localhost ([127.0.0.1]:53571 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCcpU-0008LZ-87 for submit@debbugs.gnu.org; Sun, 08 Aug 2021 03:02:40 -0400 Received: from w1.tutanota.de ([81.3.6.162]:55836) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCcpR-0008LI-DU for 49931@debbugs.gnu.org; Sun, 08 Aug 2021 03:02:38 -0400 Received: from w3.tutanota.de (unknown [192.168.1.164]) by w1.tutanota.de (Postfix) with ESMTP id 99119FBF4D5; Sun, 8 Aug 2021 07:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1628406151; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=D6j+kCkcOdbTkPFG92UC6Ofrma6JhrYlP0jkK5ilovs=; b=nH086KkFoGN5laPd+e5jzoN5iJG6uo87KBc5a9lmi87z12HiU+kCR52kVsB5bLTj Kp18kD0WQt/WuyungjDBBI5KnsJjszhWHUANKSMfuGiR0pY4OO5sQiL/Kj4iyud1nU7 ZPjKFDa88PM/P1W1IMuuAHJ1jz/faw0ZPy9I+BLuaai5b2SHM4+jFFRZwTaz7/3GLe9 DyyjsRXi27KfL+pAtOl4M9QDpW5gWszOUHtj5puVaqEvFojZMzCVYd1s6n0o2xS1WT4 O2IOqmXm3/9tsNJ+VfkkskUHB7hfiBVbDCJIu5bF/AZyVl0nyjDX1UlsgjJVdnnhHfP 71mMMDeLRw== Date: Sun, 8 Aug 2021 09:02:31 +0200 (CEST) From: Visuwesh Message-ID: In-Reply-To: <83tuk0h610.fsf@gnu.org> References: <83tuk0h610.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 8=C2=A0 Aug 2021, 10:44 by eliz@gnu.org: >> Date: Sat, 7 Aug 2021 19:20:35 +0200 (CEST) >> From: Visuwesh via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> >> When one edits the minibuffer content after the creation of >> Completions* buffer, `choose-completion' incorrectly submits the wrong >> string to the command upon selecting a candidate.=C2=A0 To reproduce, >> >> >> 1. Start emacs -Q. >> 2. Type the following key sequence: C-h f emacs- TAB. >> 3. Type a. >> 4. Select `emacs-bzr-get-version' from the *Completions* buffer. >> 5. "user-error: Symbol=E2=80=99s function definition is void: >> emacs-bzr-get-versiona" is shown in the echo area. >> >> >> What I expected to happen: >> >> >> I expected `choose-completion' to submit "emacs-bzr-get-version" to >> describe-function, not "emacs-bzr-get-versiona". >> >> > You expected Emacs to ignore what you type? Yes, I expected Emacs to ignore 'a'. > Why? The name `choose-completion' leads one to think that the candidate will be chosen regardless of whatever is in the minibuffer but that is not the case.=C2=A0 I think the current behaviour is not intuitive. > What you type after TAB is used to narrow the list of candidates when > you type the next TAB, or continue typing after the first TAB > completed some of the name for you. This is the intended behavior. I do understand how the standard behaviour is supposed to be.=C2=A0 But I believe the current behaviour is unnatural.=C2=A0 When I am offered clickable text in a buffer which are advertised to complete the command when clicked, I expect that to happen.=C2=A0 In my case, the text visible in the *Completions* buffer did not have an extra 'a' but upon choosing, it did.=C2=A0 I think this is misleading. From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Aug 2021 07:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Visuwesh Cc: 49931@debbugs.gnu.org Received: via spool by 49931-submit@debbugs.gnu.org id=B49931.1628406866721 (code B ref 49931); Sun, 08 Aug 2021 07:15:01 +0000 Received: (at 49931) by debbugs.gnu.org; 8 Aug 2021 07:14:26 +0000 Received: from localhost ([127.0.0.1]:53586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCd0s-0000BZ-Ar for submit@debbugs.gnu.org; Sun, 08 Aug 2021 03:14:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46958) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCd0p-0000BK-Tg for 49931@debbugs.gnu.org; Sun, 08 Aug 2021 03:14:24 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55454) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCd0k-0008Mj-HN; Sun, 08 Aug 2021 03:14:18 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2735 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCd0k-0004LW-4f; Sun, 08 Aug 2021 03:14:18 -0400 Date: Sun, 08 Aug 2021 10:14:22 +0300 Message-Id: <83o8a8h0hd.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Visuwesh on Sun, 8 Aug 2021 09:02:31 +0200 (CEST)) References: <83tuk0h610.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sun, 8 Aug 2021 09:02:31 +0200 (CEST) > From: Visuwesh > Cc: 49931@debbugs.gnu.org > > Yes, I expected Emacs to ignore 'a'. > > > Why? > > The name `choose-completion' leads one to think that the candidate > will be chosen regardless of whatever is in the minibuffer but that is > not the case.  I think the current behaviour is not intuitive. > > > What you type after TAB is used to narrow the list of candidates when > > you type the next TAB, or continue typing after the first TAB > > completed some of the name for you. This is the intended behavior. > > I do understand how the standard behaviour is supposed to be.  But I > believe the current behaviour is unnatural.  When I am offered > clickable text in a buffer which are advertised to complete the > command when clicked, I expect that to happen.  In my case, the text > visible in the *Completions* buffer did not have an extra 'a' but upon > choosing, it did.  I think this is misleading. I think your expectations are incorrect, because they are based on assumptions that are generally false in Emacs. In particular, depending on the context of the completion, typing more stuff after selecting a candidate is what is actually needed, so ignoring that would break valid use cases. Therefore I think we will have to agree to disagree on this one. I see no bug in the behavior you described. If it looks misleading to you, you will have to get used to it. From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Aug 2021 07:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 49931 <49931@debbugs.gnu.org> Received: via spool by 49931-submit@debbugs.gnu.org id=B49931.16284078812322 (code B ref 49931); Sun, 08 Aug 2021 07:32:02 +0000 Received: (at 49931) by debbugs.gnu.org; 8 Aug 2021 07:31:21 +0000 Received: from localhost ([127.0.0.1]:53614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCdHF-0000bO-0R for submit@debbugs.gnu.org; Sun, 08 Aug 2021 03:31:21 -0400 Received: from w1.tutanota.de ([81.3.6.162]:33512) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCdHB-0000b7-Po for 49931@debbugs.gnu.org; Sun, 08 Aug 2021 03:31:18 -0400 Received: from w3.tutanota.de (unknown [192.168.1.164]) by w1.tutanota.de (Postfix) with ESMTP id 65BF0FBF5C6; Sun, 8 Aug 2021 07:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1628407872; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=ionveQS8PWQEgBvYJLZHacbjqgcuPAju55MmR8fcqIo=; b=BxU72uSOuLRx8363nW/zWcNSuOAPzC26FkkW4UGQ3Ac3G1Jdx8WmQ7xfgjCBoW1Y LXyduF6ysJq7OQxGunsxTEYB8Mt4r7EGpVqm9XakhUtFbG84oteXPcPDx2X7JhnvBLf CoNjIJwI5lPB2/LsoOP0tuJbCK3Xqvx7NOE3N+f57M2EkYyNnN4cg2zaCRxRXQFc+y+ +lPiRYiYEx6C3yeM9oJr+eZhoCh/z8FR55i9wpjbzWnrVolEHO3e/qTWDQwy5NiI5gR VM2AdpjeLbqBFsMINXMsbNCIOnJ+5meugv3HThzOV+O2+bljc6BTaadTmsZ3Rg5gOPT +3R/7H5oUA== Date: Sun, 8 Aug 2021 09:31:12 +0200 (CEST) From: Visuwesh Message-ID: In-Reply-To: <83o8a8h0hd.fsf@gnu.org> References: <83tuk0h610.fsf@gnu.org> <83o8a8h0hd.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 8 Aug 2021, 12:44 by eliz@gnu.org: > In particular, depending on the context of the completion, typing > more stuff after selecting a candidate is what is actually needed, so > ignoring that would break valid use cases. Indeed, this makes sense when selecting a candidate that does not exit the minibuffer, like `find-file'.=C2=A0 I, for one, do not think that the current behaviour of `choose-completion' wherein it completely ignores whatever typed after the creation of the *Completions* buffer is unexpected when it comes to commands like `describe-function' which exits the minibuffer upon selecting the candidate. > Therefore I think we will have to agree to disagree on this one. I > see no bug in the behavior you described. If it looks misleading to > you, you will have to get used to it. If the above still does not convince you, then we will have to agree to disagree. From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Aug 2021 08:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Visuwesh Cc: 49931@debbugs.gnu.org Received: via spool by 49931-submit@debbugs.gnu.org id=B49931.16284107546910 (code B ref 49931); Sun, 08 Aug 2021 08:20:02 +0000 Received: (at 49931) by debbugs.gnu.org; 8 Aug 2021 08:19:14 +0000 Received: from localhost ([127.0.0.1]:53651 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCe1a-0001nN-Dm for submit@debbugs.gnu.org; Sun, 08 Aug 2021 04:19:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52848) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCe1Y-0001n8-Dq for 49931@debbugs.gnu.org; Sun, 08 Aug 2021 04:19:12 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56570) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCe1T-0004Rr-1j; Sun, 08 Aug 2021 04:19:07 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2817 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCe1S-0000vQ-L6; Sun, 08 Aug 2021 04:19:06 -0400 Date: Sun, 08 Aug 2021 11:19:10 +0300 Message-Id: <83mtpsgxhd.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Visuwesh on Sun, 8 Aug 2021 09:31:12 +0200 (CEST)) References: <83tuk0h610.fsf@gnu.org> <83o8a8h0hd.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sun, 8 Aug 2021 09:31:12 +0200 (CEST) > From: Visuwesh > Cc: 49931 <49931@debbugs.gnu.org> > > 8 Aug 2021, 12:44 by eliz@gnu.org: > > > In particular, depending on the context of the completion, typing > > more stuff after selecting a candidate is what is actually needed, so > > ignoring that would break valid use cases. > > Indeed, this makes sense when selecting a candidate that does not exit > the minibuffer, like `find-file'.  I, for one, do not think that the > current behaviour of `choose-completion' wherein it completely ignores > whatever typed after the creation of the *Completions* buffer is > unexpected when it comes to commands like `describe-function' which > exits the minibuffer upon selecting the candidate. Even though the command exits the minibuffer, the stuff you typed before selection shouldn't necessarily be ignored, since you could be completing on stuff that doesn't yield complete function names. > > Therefore I think we will have to agree to disagree on this one. I > > see no bug in the behavior you described. If it looks misleading to > > you, you will have to get used to it. > > If the above still does not convince you, then we will have to agree > to disagree. Yes. From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Aug 2021 07:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Visuwesh Cc: 49931@debbugs.gnu.org Received: via spool by 49931-submit@debbugs.gnu.org id=B49931.162858025814577 (code B ref 49931); Tue, 10 Aug 2021 07:25:02 +0000 Received: (at 49931) by debbugs.gnu.org; 10 Aug 2021 07:24:18 +0000 Received: from localhost ([127.0.0.1]:58325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDM7W-0003n3-Be for submit@debbugs.gnu.org; Tue, 10 Aug 2021 03:24:18 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:58177) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDM7U-0003mc-E1 for 49931@debbugs.gnu.org; Tue, 10 Aug 2021 03:24:17 -0400 Received: (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 498F424000D; Tue, 10 Aug 2021 07:24:08 +0000 (UTC) From: Juri Linkov Organization: LINKOV.NET References: Date: Tue, 10 Aug 2021 10:07:25 +0300 In-Reply-To: (Visuwesh via's message of "Sat, 7 Aug 2021 19:20:35 +0200 (CEST)") Message-ID: <874kbydr7m.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > When one edits the minibuffer content after the creation of > *Completions* buffer, `choose-completion' incorrectly submits the wrong > string to the command upon selecting a candidate.  To reproduce, > > 1. Start emacs -Q. > 2. Type the following key sequence: C-h f emacs- TAB. > 3. Type a. > 4. Select `emacs-bzr-get-version' from the *Completions* buffer. > 5. "user-error: Symbol’s function definition is void: > emacs-bzr-get-versiona" is shown in the echo area. > > What I expected to happen: > > I expected `choose-completion' to submit "emacs-bzr-get-version" to > describe-function, not "emacs-bzr-get-versiona". The same problem was reported in https://debbugs.gnu.org/34517#14 that also contains a possible solution, still unimplemented. From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Aug 2021 09:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 49931 <49931@debbugs.gnu.org> Received: via spool by 49931-submit@debbugs.gnu.org id=B49931.162858607023534 (code B ref 49931); Tue, 10 Aug 2021 09:02:02 +0000 Received: (at 49931) by debbugs.gnu.org; 10 Aug 2021 09:01:10 +0000 Received: from localhost ([127.0.0.1]:58428 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDNdG-00067W-FF for submit@debbugs.gnu.org; Tue, 10 Aug 2021 05:01:10 -0400 Received: from w1.tutanota.de ([81.3.6.162]:48378) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDNdC-00066s-A6 for 49931@debbugs.gnu.org; Tue, 10 Aug 2021 05:01:09 -0400 Received: from w3.tutanota.de (unknown [192.168.1.164]) by w1.tutanota.de (Postfix) with ESMTP id BA451FA02EB; Tue, 10 Aug 2021 09:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1628586059; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=yAi7GaoM8VSHfcNfDa+xFu8bqWjTJx8mWCmDnujZkiM=; b=SlPKfuNIPRFGQ/cPvbe6FOX07GoBa8NcmONySsolgXA+xxmW3fqje95lZMiGzduH +kLBV4uqdxdUO1qSTKp9RF1BEIVyyWzDBjmr5le2t0wf/iJjraHcKY0QQGrBscOLI9U lTwPwB8KdV0Zislt9Mi3INSCoZXeyFoQXPFgAymKOjLyQdGhIVN6lmlddijfkHlXFXI C3PdmU4L+crgqRI6ChuVrU7S1hm/Nod67JRv9VdVG57uaAaQ6YE4aTfHzbNOMyk5Wk8 savoLNlJgIZ/xklZtIVGHJwuvxQHOxlMRSWMec6VWvos4sGR1Hc/vgrwhpLK3uNKDod fCk/wVMorA== Date: Tue, 10 Aug 2021 11:00:59 +0200 (CEST) From: Visuwesh Message-ID: In-Reply-To: <874kbydr7m.fsf@mail.linkov.net> References: <874kbydr7m.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 10 Aug 2021, 12:37 by juri@linkov.net: >> When one edits the minibuffer content after the creation of >> *Completions* buffer, `choose-completion' incorrectly submits the wrong >> string to the command upon selecting a candidate.=C2=A0 To reproduce, >> >> 1. Start emacs -Q. >> 2. Type the following key sequence: C-h f emacs- TAB. >> 3. Type a. >> 4. Select `emacs-bzr-get-version' from the *Completions* buffer. >> 5. "user-error: Symbol=E2=80=99s function definition is void: >> emacs-bzr-get-versiona" is shown in the echo area. >> >> What I expected to happen: >> >> I expected `choose-completion' to submit "emacs-bzr-get-version" to >> describe-function, not "emacs-bzr-get-versiona". >> > > The same problem was reported in https://debbugs.gnu.org/34517#14 > that also contains a possible solution, still unimplemented. > Thanks for linking me that bug report.=C2=A0 I tried searching for similar = terms in=C2=A0 bug-gnu-emacs and emacs-devel but the hits were too much for me to go through them.=C2=A0 Stefan's explanation made things clear. From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Mar 2022 19:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 49931@debbugs.gnu.org Received: via spool by 49931-submit@debbugs.gnu.org id=B49931.164711242132562 (code B ref 49931); Sat, 12 Mar 2022 19:14:02 +0000 Received: (at 49931) by debbugs.gnu.org; 12 Mar 2022 19:13:41 +0000 Received: from localhost ([127.0.0.1]:40870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nT7BN-0008T8-Bu for submit@debbugs.gnu.org; Sat, 12 Mar 2022 14:13:41 -0500 Received: from relay11.mail.gandi.net ([217.70.178.231]:40571) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nT7BL-0008Se-6N for 49931@debbugs.gnu.org; Sat, 12 Mar 2022 14:13:40 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 1BA2C100002; Sat, 12 Mar 2022 19:13:31 +0000 (UTC) From: Juri Linkov Organization: LINKOV.NET References: <874kbydr7m.fsf@mail.linkov.net> Date: Sat, 12 Mar 2022 20:49:58 +0200 In-Reply-To: <874kbydr7m.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 10 Aug 2021 10:07:25 +0300") Message-ID: <86ilsj574h.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit [This is continuation of the unfinished fix from bug#34517] >> Stefan, please advise shouldn't selecting a completion from the >> *Completions* buffer clear the minibuffer's content before >> inserting the selected completion? > > No, for example when you complete file name "C-x C-f ~/.e TAB" the > *Completions* buffer will only show ".emacs" so we should clear the > minibuffer before inserting ".emacs" because that would lose the leading > "~/". There are other circumstances where trailing text needs to > be preserved. Another example that occurred to me is shell-command M-! minibuffer where TAB can complete on commands and file names. > The completion code handles this with `completion-base-position` which > holds the beginning and end of the text that should be replaced when you > choose an item in *Completions*. > >>> 0. emacs -Q >>> 1. ‘C-h f TAB’ displays a list of completions >>> 2. type a nonexistent function name, i.e. some random text >>> in the minibuffer, e.g. “blabla” > > The *Completions* content is now "out of date" compared to the minibuffer. > >>> 3. click on an existing valid completion in the *Completions* buffer, >>> e.g. on “append” > > completion-base-position was set at step (1) to cover the empty text > after the prompt, so this empty text (which is now right in front of > "blabla") is replaced with "append" resulting in "appendblabla". > > Obviously, the result is not what we want. > Now sure how to change which part, tho. Maybe instead of > completion-base-position we should store the prefix and suffix strings, > so when you select an entry from *Completions* we just clear the > minibuffer and replace it with (concat prefix selection suffix)? Now I tried this, and it works correctly. But not sure how to make this change as backward-compatible as possible. One variant would be to save '("prefix" "suffix") instead of '(10 11) in 'completion-base-position' but this might fail in some existing code. So maybe better to add a new variable 'completion-base-affixes'. Then whether to use 'completion-base-position' or 'completion-base-affixes' could be defined by the new user option 'completion-use-base-affixes'. Then it can be used in the new command from emacs-devel: ``` (defun minibuffer-completion-choose (&optional arg) "Run `choose-completion' from the minibuffer in its scrolling window." (interactive "P") (with-minibuffer-scroll-window (let ((completion-use-base-affixes t)) (choose-completion nil arg)))) ``` --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=completion-base-affixes.patch diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 0262424b87..4cc050ff86 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2290,6 +2290,8 @@ minibuffer-completion-help (let* ((start (or start (minibuffer--completion-prompt-end))) (end (or end (point-max))) (string (buffer-substring start end)) + (base-prefix (buffer-substring (minibuffer--completion-prompt-end) start)) + (base-suffix (buffer-substring end (point-max))) (md (completion--field-metadata start)) (completions (completion-all-completions string @@ -2405,11 +2407,16 @@ minibuffer-completion-help ;; completion-all-completions does not give us the ;; necessary information. end)) + (setq-local completion-base-affixes (list base-prefix base-suffix)) (setq-local completion-list-insert-choice-function (let ((ctable minibuffer-completion-table) (cpred minibuffer-completion-predicate) (cprops completion-extra-properties)) (lambda (start end choice) + (if (and (stringp start) (stringp end)) + (progn + (delete-region (minibuffer-prompt-end) (point-max)) + (insert start choice end)) (unless (or (zerop (length prefix)) (equal prefix (buffer-substring-no-properties @@ -2418,7 +2425,7 @@ minibuffer-completion-help start))) (message "*Completions* out of date")) ;; FIXME: Use `md' to do quoting&terminator here. - (completion--replace start end choice) + (completion--replace start end choice)) (let* ((minibuffer-completion-table ctable) (minibuffer-completion-predicate cpred) (completion-extra-properties cprops) diff --git a/lisp/simple.el b/lisp/simple.el index 9601e6cd76..bf9d8c8830 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9072,6 +9072,19 @@ completion-base-position where the completion should be inserted and END (if non-nil) is the end of the text to replace. If END is nil, point is used instead.") +(defvar completion-base-affixes nil + "Base context of the text corresponding to the shown completions. +This variable is used in the *Completions* buffers. +Its value is a list of the form (PREFIX SUFFIX) where PREFIX is the text +before the place where completion should be inserted and SUFFIX is the text +after the completion.") + +(defcustom completion-use-base-affixes nil + "Non-nil means to restore original prefix and suffix in the minibuffer." + :type 'boolean + :version "29.1" + :group 'completion) + (defvar completion-list-insert-choice-function #'completion--replace "Function to use to insert the text chosen in *Completions*. Called with three arguments (BEG END TEXT), it should replace the text @@ -9164,6 +9181,7 @@ choose-completion (with-current-buffer (window-buffer (posn-window (event-start event))) (let ((buffer completion-reference-buffer) (base-position completion-base-position) + (base-affixes completion-base-affixes) (insert-function completion-list-insert-choice-function) (completion-no-auto-exit (if arg t completion-no-auto-exit)) (choice @@ -9184,7 +9202,8 @@ choose-completion (with-current-buffer buffer (choose-completion-string choice buffer - (or base-position + (or (and completion-use-base-affixes base-affixes) + base-position ;; If all else fails, just guess. (list (choose-completion-guess-base-position choice))) insert-function))))) @@ -9357,9 +9377,11 @@ completion-setup-function (buffer-substring (minibuffer-prompt-end) (point))))))) (with-current-buffer standard-output (let ((base-position completion-base-position) + (base-affixes completion-base-affixes) (insert-fun completion-list-insert-choice-function)) (completion-list-mode) (setq-local completion-base-position base-position) + (setq-local completion-base-affixes base-affixes) (setq-local completion-list-insert-choice-function insert-fun)) (setq-local completion-reference-buffer mainbuf) (if base-dir (setq default-directory base-dir)) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 13 14:13:54 2022 Received: (at control) by debbugs.gnu.org; 13 Mar 2022 18:13:54 +0000 Received: from localhost ([127.0.0.1]:43262 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nTSj3-00066h-Q2 for submit@debbugs.gnu.org; Sun, 13 Mar 2022 14:13:54 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:51379) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nTSj0-00066B-7O; Sun, 13 Mar 2022 14:13:51 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 7BA581C0004; Sun, 13 Mar 2022 18:13:41 +0000 (UTC) From: Juri Linkov To: Daniel Mendler Subject: Re: bug#48356: 28.0.50; choose-completion discards the suffix after the completion boundary Organization: LINKOV.NET References: <18593691-8b7a-facf-68e1-e9d0c106897b@daniel-mendler.de> Date: Sun, 13 Mar 2022 19:56:50 +0200 In-Reply-To: <18593691-8b7a-facf-68e1-e9d0c106897b@daniel-mendler.de> (Daniel Mendler's message of "Tue, 11 May 2021 19:23:13 +0200") Message-ID: <865yoh91nh.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control Cc: 48356@debbugs.gnu.org, Stefan Monnier , JD Smith X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain forcemerge 48356 49931 thanks > When selecting a candidate the suffix after the completion boundary is > discarded by `choose-completion`/`choose-completion-string`. > `choose-completion` is invoked when a candidate in the *Completions* > buffer is selected with the mouse or RET. > > For example when completing a file path "~/emacs/master/li|/calc", where > "|" is the cursor, and then the candidate "lisp" is selected in the > *Completions* buffer, the result is "~/emacs/master/lisp/". The prefix > "~/emacs/master/" is prepended to the selected candidate, but the suffix > "/calc" is discarded. > > `choose-completion-string` contains logic which checks if the resulting > string equals the car of the completion boundary. In that case the > minibuffer is not exited. Strange, in your test case above, the minibuffer is not exited already. > I propose the following change to the existing logic: When > selecting a candidate with `choose-completion` and a suffix is present, > the minibuffer should not be exited (completion continues) and the > suffix is preserved. Here is a better patch than was posted to bug#49931 to preserve the suffix. It correctly handles at least three different cases: 1. When manually adding a suffix in the minibuffer after completions were displayed, choose-completion discards that suffix. 2. In file name completion in the above case the suffix is preserved. 3. 'M-! command filename TAB' and choosing a completion preserves both prefix and suffix. This works only after customizing 'completion-use-base-affixes' to t: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=completion-base-affixes.patch diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 36b8d80841..5685f078ad 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2227,6 +2312,8 @@ minibuffer-completion-help (let* ((last (last completions)) (base-size (or (cdr last) 0)) (prefix (unless (zerop base-size) (substring string 0 base-size))) + (base-prefix (buffer-substring (minibuffer--completion-prompt-end) (+ start base-size))) + (base-suffix (buffer-substring (point) (point-max))) (all-md (completion--metadata (buffer-substring-no-properties start (point)) base-size md @@ -2320,11 +2407,18 @@ minibuffer-completion-help ;; completion-all-completions does not give us the ;; necessary information. end)) + (setq-local completion-base-affixes (list base-prefix base-suffix)) (setq-local completion-list-insert-choice-function (let ((ctable minibuffer-completion-table) (cpred minibuffer-completion-predicate) (cprops completion-extra-properties)) (lambda (start end choice) + (if (and (stringp start) (stringp end)) + (progn + (delete-minibuffer-contents) + (insert start choice) + ;; Keep point after completion before suffix + (save-excursion (insert end))) (unless (or (zerop (length prefix)) (equal prefix (buffer-substring-no-properties @@ -2333,7 +2427,7 @@ minibuffer-completion-help start))) (message "*Completions* out of date")) ;; FIXME: Use `md' to do quoting&terminator here. - (completion--replace start end choice) + (completion--replace start end choice)) (let* ((minibuffer-completion-table ctable) (minibuffer-completion-predicate cpred) (completion-extra-properties cprops) diff --git a/lisp/simple.el b/lisp/simple.el index accc119e2b..52cf54c563 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9071,6 +9075,19 @@ completion-base-position where the completion should be inserted and END (if non-nil) is the end of the text to replace. If END is nil, point is used instead.") +(defvar completion-base-affixes nil + "Base context of the text corresponding to the shown completions. +This variable is used in the *Completions* buffers. +Its value is a list of the form (PREFIX SUFFIX) where PREFIX is the text +before the place where completion should be inserted and SUFFIX is the text +after the completion.") + +(defcustom completion-use-base-affixes nil + "Non-nil means to restore original prefix and suffix in the minibuffer." + :type 'boolean + :version "29.1" + :group 'completion) + (defvar completion-list-insert-choice-function #'completion--replace "Function to use to insert the text chosen in *Completions*. Called with three arguments (BEG END TEXT), it should replace the text @@ -9151,6 +9168,7 @@ next-completion (with-current-buffer (window-buffer (posn-window (event-start event))) (let ((buffer completion-reference-buffer) (base-position completion-base-position) + (base-affixes completion-base-affixes) (insert-function completion-list-insert-choice-function) (choice (save-excursion @@ -9184,7 +9203,8 @@ choose-completion (with-current-buffer buffer (choose-completion-string choice buffer - (or base-position + (or (and completion-use-base-affixes base-affixes) + base-position ;; If all else fails, just guess. (list (choose-completion-guess-base-position choice))) insert-function))))) @@ -9344,9 +9372,11 @@ completion-setup-function (buffer-substring (minibuffer-prompt-end) (point))))))) (with-current-buffer standard-output (let ((base-position completion-base-position) + (base-affixes completion-base-affixes) (insert-fun completion-list-insert-choice-function)) (completion-list-mode) (setq-local completion-base-position base-position) + (setq-local completion-base-affixes base-affixes) (setq-local completion-list-insert-choice-function insert-fun)) (setq-local completion-reference-buffer mainbuf) (if base-dir (setq default-directory base-dir)) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 05 14:28:36 2022 Received: (at control) by debbugs.gnu.org; 5 Apr 2022 18:28:36 +0000 Received: from localhost ([127.0.0.1]:56154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbnuu-0003an-H3 for submit@debbugs.gnu.org; Tue, 05 Apr 2022 14:28:36 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:49709) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbnus-0003aW-Oo for control@debbugs.gnu.org; Tue, 05 Apr 2022 14:28:35 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id CCA7220002 for ; Tue, 5 Apr 2022 18:28:27 +0000 (UTC) From: Juri Linkov To: control@debbugs.gnu.org Subject: Re: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Organization: LINKOV.NET References: <874kbydr7m.fsf@mail.linkov.net> Date: Tue, 05 Apr 2022 21:28:04 +0300 In-Reply-To: <874kbydr7m.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 10 Aug 2021 10:07:25 +0300") Message-ID: <86bkxfjsgb.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) unmerge 49931 quit From unknown Sun Jun 15 01:09:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49931: 28.0.50; `choose-completion' submits incorrect string when minibuffer content changes after creation of the *Completions* buffer Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Apr 2022 19:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 49931@debbugs.gnu.org Received: via spool by 49931-submit@debbugs.gnu.org id=B49931.164918659928796 (code B ref 49931); Tue, 05 Apr 2022 19:24:02 +0000 Received: (at 49931) by debbugs.gnu.org; 5 Apr 2022 19:23:19 +0000 Received: from localhost ([127.0.0.1]:56250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbolq-0007UL-S7 for submit@debbugs.gnu.org; Tue, 05 Apr 2022 15:23:19 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:37977) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbolp-0007U2-No; Tue, 05 Apr 2022 15:23:18 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 2E9E1200007; Tue, 5 Apr 2022 19:23:09 +0000 (UTC) From: Juri Linkov Organization: LINKOV.NET References: <874kbydr7m.fsf@mail.linkov.net> <86ilsj574h.fsf@mail.linkov.net> Date: Tue, 05 Apr 2022 21:54:27 +0300 In-Reply-To: <86ilsj574h.fsf@mail.linkov.net> (Juri Linkov's message of "Sat, 12 Mar 2022 20:49:58 +0200") Message-ID: <86wng3icnw.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) close 49931 29.0.50 thanks >>>> 3. click on an existing valid completion in the *Completions* buffer, >>>> e.g. on “append” >> >> completion-base-position was set at step (1) to cover the empty text >> after the prompt, so this empty text (which is now right in front of >> "blabla") is replaced with "append" resulting in "appendblabla". >> >> Obviously, the result is not what we want. >> Now sure how to change which part, tho. Maybe instead of >> completion-base-position we should store the prefix and suffix strings, >> so when you select an entry from *Completions* we just clear the >> minibuffer and replace it with (concat prefix selection suffix)? > > Now I tried this, and it works correctly. But not sure how to make > this change as backward-compatible as possible. One variant > would be to save '("prefix" "suffix") instead of '(10 11) > in 'completion-base-position' but this might fail in some existing code. > > So maybe better to add a new variable 'completion-base-affixes'. > Then whether to use 'completion-base-position' > or 'completion-base-affixes' could be defined by the new user option > 'completion-use-base-affixes'. Now this patched is pushed to master, and the bug report is closed.