From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii 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 13:48:47 +0300 Message-ID: <83jzy419bk.fsf@gnu.org> References: <8635574n10.fsf@mail.linkov.net> <868rema032.fsf@mail.linkov.net> <83r0se4bwf.fsf@gnu.org> <87pm7xkqsd.fsf@catern.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14326"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62700@debbugs.gnu.org, sbaugh@janestreet.com, juri@linkov.net To: sbaugh@catern.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 22 12:49:14 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 1pqAnq-0003X8-3V for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Apr 2023 12:49:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqAnf-0007ir-Qn; Sat, 22 Apr 2023 06:49:03 -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 1pqAne-0007iZ-Gk for bug-gnu-emacs@gnu.org; Sat, 22 Apr 2023 06:49: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 1pqAne-0002dE-8V for bug-gnu-emacs@gnu.org; Sat, 22 Apr 2023 06:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pqAnd-0003su-NA for bug-gnu-emacs@gnu.org; Sat, 22 Apr 2023 06:49:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Apr 2023 10:49:01 +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.168216052114890 (code B ref 62700); Sat, 22 Apr 2023 10:49:01 +0000 Original-Received: (at 62700) by debbugs.gnu.org; 22 Apr 2023 10:48:41 +0000 Original-Received: from localhost ([127.0.0.1]:41922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqAnI-0003s6-Mb for submit@debbugs.gnu.org; Sat, 22 Apr 2023 06:48:41 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqAnE-0003rn-O2 for 62700@debbugs.gnu.org; Sat, 22 Apr 2023 06:48:39 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqAn6-0002VQ-Qd; Sat, 22 Apr 2023 06:48:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=h48zYfQzJPW0xao/LfkX4/BzQlZfSiP39iFdYHCTUtc=; b=mGBS/ZNsXM8v IXHbTzuuJeI1nJGCpCrbkB66Z5YeVBINO9wc4Klkyq5hkPx1HYtPU2QQWFL5iF8+UE9apsaVc1Xh5 Ft46AMnYMNgoT+QajhkjU/d/y69XD3RfEaP5IYspetEDFwY3DVzrETTFGSdEZx+7R6RqtwL4E3E8r O0Q7ZYCSWAMGCrGIFp+T6roz1/IXUYWf8tq/8dzCveMj0IYhx0FNJUKXp4yuGx2zpLdEmz6ENi07j iJJCQHUETGOThgnrYoVl3rLVE5MZhH0YH60rq9vPTsf7Rta8PgJcmK8rqzUNdhlazNRUqECS2u20I q7y3gmzUyABSJ6UXy4Fvsw==; Original-Received: from [87.69.77.57] (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 1pqAn6-0000R8-AV; Sat, 22 Apr 2023 06:48:28 -0400 In-Reply-To: <87pm7xkqsd.fsf@catern.com> (sbaugh@catern.com) 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:260455 Archived-At: > 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?