From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: sbaugh@catern.com Newsgroups: gmane.emacs.bugs Subject: bug#62700: 29.0.60; minibuffer-{previous,next,choose}-completion behave unintuitively when point is not at end of buffer Date: Sat, 22 Apr 2023 12:57:57 +0000 (UTC) Message-ID: <87ildokraj.fsf@catern.com> References: <8635574n10.fsf@mail.linkov.net> <868rema032.fsf@mail.linkov.net> <83r0se4bwf.fsf@gnu.org> <87pm7xkqsd.fsf@catern.com> <83jzy419bk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23427"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 62700@debbugs.gnu.org, sbaugh@janestreet.com, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 22 14:59:41 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 1pqCq4-0005v0-Hu for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Apr 2023 14:59:41 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqCpV-0006uc-TB; Sat, 22 Apr 2023 08:59: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 1pqCpS-0006uI-Uj for bug-gnu-emacs@gnu.org; Sat, 22 Apr 2023 08:59:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqCpS-0003TR-Eb for bug-gnu-emacs@gnu.org; Sat, 22 Apr 2023 08:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pqCpS-0001sT-3T for bug-gnu-emacs@gnu.org; Sat, 22 Apr 2023 08:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Apr 2023 12:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62700 X-GNU-PR-Package: emacs Original-Received: via spool by 62700-submit@debbugs.gnu.org id=B62700.16821682857136 (code B ref 62700); Sat, 22 Apr 2023 12:59:02 +0000 Original-Received: (at 62700) by debbugs.gnu.org; 22 Apr 2023 12:58:05 +0000 Original-Received: from localhost ([127.0.0.1]:42091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqCoW-0001r2-Hp for submit@debbugs.gnu.org; Sat, 22 Apr 2023 08:58:04 -0400 Original-Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]:1714) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqCoV-0001qY-6M for 62700@debbugs.gnu.org; Sat, 22 Apr 2023 08:58:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=o9GfvmhB9cmqkLgSYNnC97jdm43TK53IS7RkLLFhnl0=; b=iWN5Z8BWG8nEmRkmGeokY+gG4USK1zOhL3nsgre9aFS6O0yI/SZr+IhFr1rZfl/VRRxp SxjwMIV7TsDfrnxWkcJPcS01H8tgMuKYGc0R5wa4Jg1l4AiDm3tAepcyImsvSrcIJDbUZR n1fV7puR8a5cc5YG0NdsgFT6N3hpnqRn5+FW/MuumGvSW5VtsIXOZ0/+wERUB1a22+Y07t K146LZ20wBNxCNHfj0RcAeLeRMwXMIf8ZuiwxRKcOLMkFDIJtc6ib1sWEW1LJc3p3T7Sal F6QlSo+pPvmVvqLWSMR/8G5QNKfAe02bNrqSKxBcKb+CIA9vbr6bflFMSxC1BB9w== Original-Received: by filterdrecv-68f8d557c9-x9fxp with SMTP id filterdrecv-68f8d557c9-x9fxp-1-6443D9D5-E 2023-04-22 12:57:57.61863529 +0000 UTC m=+5145870.235180732 Original-Received: from earth.catern.com (unknown) by geopod-ismtpd-25 (SG) with ESMTP id pEmkYM5pRLWeTjJkkpGsdA Sat, 22 Apr 2023 12:57:57.425 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver= Original-Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id C226860066; Sat, 22 Apr 2023 08:57:56 -0400 (EDT) In-Reply-To: <83jzy419bk.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 22 Apr 2023 13:48:47 +0300") X-SG-EID: ZgbRq7gjGrt0q/Pjvxk7wM0yQFRdOkTJAtEbkjCkHbK2YcYSFaIwyx10ir8l0EB0cFpLRcLdQwPtlWfqfYqyJ9mFvZhuSXU9KkS4UcYi0mcFKoPjuDbCp5ho+25F4D5ADTxlCb21w6s93o7KCjfwS2lxsReASNKEz1x7XNfiNFr0TKLBqyaEQklcIsUu4KZBiZ4+hj4HMOo1ZPRegALILQ== X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== 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:260471 Archived-At: Eli Zaretskii writes: >> From: sbaugh@catern.com >> Date: Fri, 21 Apr 2023 18:56:35 +0000 (UTC) >> Cc: Spencer Baugh , 62700@debbugs.gnu.org, >> juri@linkov.net >> >> >> Ah, I thought Eli still wanted a backport version because this changes >> >> code which has been on Emacs 29 for over a year. >> > >> > Indeed, that's what I would like to see on the release branch. Mainly >> > because even if this is deemed a bug, it happens in a relatively rare >> > situation, so I'd like to avoid risking breakage in code which affects >> > other situations. >> >> Here's the backport for the release branch. > > Thanks, but I'd like to make this still safer for the release branch: > >> --- a/lisp/minibuffer.el >> +++ b/lisp/minibuffer.el >> @@ -4464,13 +4464,21 @@ minibuffer-next-completion >> When `minibuffer-completion-auto-choose' is non-nil, then also >> insert the selected completion to the minibuffer." >> (interactive "p") >> - (let ((auto-choose minibuffer-completion-auto-choose)) >> + (let* ((auto-choose minibuffer-completion-auto-choose) >> + ;; Backported fix for bug#62700 >> + (md (completion--field-metadata (minibuffer--completion-prompt-end))) >> + (base-suffix >> + (if (eq (alist-get 'category (cdr md)) 'file) >> + (buffer-substring (save-excursion (search-forward "/" nil t) (point)) >> + (point-max)) >> + ""))) >> (with-minibuffer-completions-window >> (when completions-highlight-face >> (setq-local cursor-face-highlight-nonselected-window t)) >> (next-completion (or n 1)) >> (when auto-choose >> - (let ((completion-use-base-affixes t)) >> + (let ((completion-use-base-affixes t) >> + (completion-base-affixes (list (car completion-base-affixes) base-suffix))) >> (choose-completion nil t t)))))) > > Here, the values used only when minibuffer-completion-auto-choose is > non-nil should be computed only when that variable is non-nil, > preferably inside the '(when auto-choose' clause. > >> @@ -4489,9 +4497,17 @@ minibuffer-choose-completion >> If NO-QUIT is non-nil, insert the completion at point to the >> minibuffer, but don't quit the completions window." >> (interactive "P") >> - (with-minibuffer-completions-window >> - (let ((completion-use-base-affixes t)) >> - (choose-completion nil no-exit no-quit)))) >> + ;; Backported fix for bug#62700 >> + (let* ((md (completion--field-metadata (minibuffer--completion-prompt-end))) >> + (base-suffix >> + (if (eq (alist-get 'category (cdr md)) 'file) >> + (buffer-substring (save-excursion (search-forward "/" nil t) (point)) >> + (point-max)) >> + ""))) >> + (with-minibuffer-completions-window >> + (let ((completion-use-base-affixes t) >> + (completion-base-affixes (list (car completion-base-affixes) base-suffix))) >> + (choose-completion nil no-exit no-quit))))) > > And here we seem to be modifying code that is not only for when > minibuffer-completion-auto-choose is non-nil, or what am I missing? The bug happens regardless of the value of minibuffer-completion-auto-choose. It doesn't relate to minibuffer-completion-auto-choose.