From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh 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: Fri, 02 Jun 2023 20:58:52 -0400 Message-ID: References: <8635574n10.fsf@mail.linkov.net> <868rema032.fsf@mail.linkov.net> <83r0se4bwf.fsf@gnu.org> <87pm7xkqsd.fsf@catern.com> <83jzy419bk.fsf@gnu.org> <874jourckv.fsf@catern.com> <83lei6mxa0.fsf@gnu.org> <86wn1jutxv.fsf@mail.linkov.net> <83zg6eby5t.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3271"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 62700@debbugs.gnu.org, sbaugh@catern.com, Juri Linkov To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 03 02:59:21 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 1q5Fc1-0000hy-Ew for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Jun 2023 02:59:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5Fbn-0003W9-AH; Fri, 02 Jun 2023 20:59:07 -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 1q5Fbj-0003VZ-0R for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 20:59:04 -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 1q5Fbi-0002eV-GA for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 20:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q5Fbi-0005Xt-CU for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 20:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Jun 2023 00: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.168575394121310 (code B ref 62700); Sat, 03 Jun 2023 00:59:02 +0000 Original-Received: (at 62700) by debbugs.gnu.org; 3 Jun 2023 00:59:01 +0000 Original-Received: from localhost ([127.0.0.1]:41054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5Fbg-0005Xd-Rx for submit@debbugs.gnu.org; Fri, 02 Jun 2023 20:59:01 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:50191) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5Fbe-0005XO-5d for 62700@debbugs.gnu.org; Fri, 02 Jun 2023 20:58:59 -0400 In-Reply-To: <83zg6eby5t.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 08 May 2023 19:11:58 +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:262789 Archived-At: --=-=-= Content-Type: text/plain It turns out my patch doesn't fully fix the issue, when doing completion at the end of a file path. For example: 1. C-x C-f ~/src/emacs/emacs-29/lisp/.el 2. TAB to trigger completion, moving point to before .el 3. M- 4. The filenames are inserted before the .el, so one gets for example ~/src/emacs/emacs-29/lisp/abbrev.el.el The attached patch for the Emacs 29 branch fixes this remaining case. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Handle-point-in-last-file-path-component-in-minibuff.patch >From 33f9cfa6afb7ae232ed6d5bbc4692a463f57a7a8 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Fri, 2 Jun 2023 20:57:32 -0400 Subject: [PATCH] Handle point in last file path component in minibuffer completion This is a followup to commit e338a8ac41d4a9fd798dda90275abe75ac071335 (Handle point not at EOB in minibuffer-choose-completion). That added a heuristic, but the heuristic was insufficient: It still had the original wrong behavior when completing the last file path component (i.e., the completion category is 'file and there's no / after point). This patch makes the heuristic cover that case too. * lisp/minibuffer.el (minibuffer-next-completion) (minibuffer-choose-completion): If in file completion and there's no / after point, clear what's after point when we complete. (Bug#62700) --- lisp/minibuffer.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 298f3f8728d..a873e5f9747 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -4498,8 +4498,9 @@ minibuffer-next-completion (base-suffix (if (eq (alist-get 'category (cdr md)) 'file) (with-current-buffer buf - (buffer-substring (save-excursion (search-forward "/" nil t) (point)) - (point-max))) + (buffer-substring + (save-excursion (or (search-forward "/" nil t) (point-max))) + (point-max))) "")) (completion-base-affixes (list (car completion-base-affixes) base-suffix))) (choose-completion nil t t)))))) @@ -4524,8 +4525,9 @@ minibuffer-choose-completion (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)) + (buffer-substring + (save-excursion (or (search-forward "/" nil t) (point-max))) + (point-max)) ""))) (with-minibuffer-completions-window (let ((completion-use-base-affixes t) -- 2.39.3 --=-=-=--