From unknown Sat Jun 21 05:05:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68688: 30.0.50; next-line-completion doesn't work with multiline completions Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jan 2024 14:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 68688@debbugs.gnu.org Cc: Juri Linkov X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17061074705079 (code B ref -1); Wed, 24 Jan 2024 14:45:02 +0000 Received: (at submit) by debbugs.gnu.org; 24 Jan 2024 14:44:30 +0000 Received: from localhost ([127.0.0.1]:44843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSeUP-0001Jq-Nf for submit@debbugs.gnu.org; Wed, 24 Jan 2024 09:44:30 -0500 Received: from lists.gnu.org ([2001:470:142::17]:40406) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSeUN-0001JM-RJ for submit@debbugs.gnu.org; Wed, 24 Jan 2024 09:44:28 -0500 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 1rSeUD-0006kZ-5p for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 09:44:17 -0500 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSeUA-0006nh-Gl for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 09:44:16 -0500 From: Spencer Baugh Date: Wed, 24 Jan 2024 09:44:10 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1706107451; bh=shIzGsShtopvlz1VFc0DBaCtsMe+FZiYG68g+nmk73o=; h=From:To:Cc:Subject:Date; b=UCJca/Czr1N0WtI1PKf65LLgtvl3xR6S/sHlU4wWlsceMh6gSjF8b5vVQOl0RNwM1 67cb7uVizttFxJRYpT+FF26XaOMJ2x/YVCOdpYtGCUl83h/Z5GulbwrTw5vsWSJx2/ EZAev1ixn0oZ6i+G0t3TTb+O3q+vRBIo5NAWx9EyYum+VImyxhvDNF0m8Fc8jxcnNV YHpNavrYBUKDJaLzaqNznvX+vdk03qF8xH48/3iVi2zBNHYf/NN449V42IJZuxJ/XZ Dq5UJSMG61sUKMSAs9/Mo3HAvVIvGgX+ZFbjywR7r4q4fwr/0NpKSKKrw21hNY8wqJ w+vD1nehlIMtQ== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) 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: -0.1 (/) 1. emacs -Q 2. (completing-read ": " '("foo\nfoo" "bar\nbar")) 3. M-g M-c to switch to *Completions* 4. to switch between completions 5. Note that point stays on the first completion no matter how many times you hit . It looks like this is because the relevant part of next-line-completion just runs forward-line until point is on a completion - it doesn't do anything to make sure that point is on a *different* completion. In GNU Emacs 30.0.50 (build 20, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2023-12-27 built on igm-qws-u22796a Repository revision: b9c0ce0a400f18e1bba4e3491c94994d73ef9405 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.9 (Green Obsidian) Configured using: 'configure -C 'CFLAGS=-O0 -g3' --with-gif=ifavailable --with-x-toolkit=lucid' Configured features: CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t minibuffer-regexp-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-extra shortdoc text-property-search comp-common rx help-fns radix-tree help-mode cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-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 nadvice seq simple cl-generic indonesian philippine 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 emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo x-toolkit xinput2 x multi-tty move-toolbar make-network-process emacs) Memory information: ((conses 16 77798 11426) (symbols 48 10074 0) (strings 32 25127 2339) (string-bytes 1 732356) (vectors 16 11366) (vector-slots 8 167679 11150) (floats 8 102 23) (intervals 56 404 18) (buffers 984 13)) From unknown Sat Jun 21 05:05:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68688: 30.0.50; next-line-completion doesn't work with multiline completions Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jan 2024 15:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 68688@debbugs.gnu.org Cc: Juri Linkov Received: via spool by 68688-submit@debbugs.gnu.org id=B68688.170611175124884 (code B ref 68688); Wed, 24 Jan 2024 15:56:01 +0000 Received: (at 68688) by debbugs.gnu.org; 24 Jan 2024 15:55:51 +0000 Received: from localhost ([127.0.0.1]:46340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSfbS-0006TF-JE for submit@debbugs.gnu.org; Wed, 24 Jan 2024 10:55:51 -0500 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:33855) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSfbR-0006T0-0D for 68688@debbugs.gnu.org; Wed, 24 Jan 2024 10:55:49 -0500 From: Spencer Baugh In-Reply-To: (Spencer Baugh's message of "Wed, 24 Jan 2024 09:44:10 -0500") References: Date: Wed, 24 Jan 2024 10:55:37 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1706111737; bh=Go1TLPv9Dtbzdk7N8Undjm+h70GIXvDKFxbcnxne/aw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=IyzJBfWaB2pkmKEd9pKlJMowQUSjlWfVZI7qvXtpBKyMmLI2+NTjRr66EB3F9S5N+ ebr0ctAeDdeDXuQ1lA71IumXQKBDguvif6bU7HgMMn5OzeezdL4AVaFEWNeLvHGKAa 9igrigbSEv3htC8c23+4P8Y0wOZngtmd9Rb5vcv4EkjC/4eAqYVIdjiYaIQT3GIfOq ts9SQWskqhr0c+TWeHNB0CUTF/lpo6Q0nQ93ibaZKmsYP8yAYkMJJJCrcj6/rZFc1c ZlSbOtvD/7Q5kX6eNDcCiot8e8m8KHvI6whcOhlFIC82J0lJP9N8sX/WZYpWzdv3yW H/cUCgcbkeAJg== 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 (-) --=-=-= Content-Type: text/plain Patch which fixes this attached. It simply adds an additional loop around forward-line which runs until we leave the completion at point. BTW, I think we should have some helper functions for "get start of completion candidate or point-min" and "get end of completion candidate or point-max", or possibly "move to start of candidate" and "move to end of candidate"; it's pretty hard to get right. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Fix-next-line-completion-for-multi-line-completions.patch >From ffe03b3fe8fb805f5e4eb0a2ea956d573272e74a Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 24 Jan 2024 10:52:40 -0500 Subject: [PATCH] Fix next-line-completion for multi-line completions Previously it would not move out of a multi-line completion, and now it will. * lisp/simple.el (next-line-completion): Move out of the completion before going forward lines. (bug#68688) --- lisp/simple.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lisp/simple.el b/lisp/simple.el index 313241a7d34..35fd76b8d1a 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9937,6 +9937,17 @@ next-line-completion (while (> n 0) (setq found nil pos nil column (current-column) line (line-number-at-pos)) + ;; If in a completion and not at the end, move lines forward + ;; until we leave it or reach the end. + (when (and (get-text-property (point) 'mouse-face) + (not (eobp)) + (get-text-property (1+ (point)) 'mouse-face)) + (let ((end (or (next-single-property-change (point) 'mouse-face) (point-max)))) + (while (and + (< (point) end) + (eq (forward-line 1) 0) + (not (eobp)) + (eq (move-to-column column) column))))) (while (and (not found) (eq (forward-line 1) 0) (not (eobp)) @@ -9961,6 +9972,15 @@ next-line-completion (while (< n 0) (setq found nil pos nil column (current-column) line (line-number-at-pos)) + ;; If in a completion and not at the start, move lines backward + ;; until we leave it or reach the start. + (when (and (get-text-property (point) 'mouse-face) + (not (bobp)) + (get-text-property (1- (point)) 'mouse-face)) + (let ((start (previous-single-property-change (point) 'mouse-face))) + (while (and (> (point) start) + (eq (forward-line -1) 0) + (eq (move-to-column column) column))))) (while (and (not found) (eq (forward-line -1) 0) (eq (move-to-column column) column)) -- 2.39.3 --=-=-=-- From unknown Sat Jun 21 05:05:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68688: 30.0.50; next-line-completion doesn't work with multiline completions Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jan 2024 16:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: 68688@debbugs.gnu.org Received: via spool by 68688-submit@debbugs.gnu.org id=B68688.17061150389284 (code B ref 68688); Wed, 24 Jan 2024 16:51:01 +0000 Received: (at 68688) by debbugs.gnu.org; 24 Jan 2024 16:50:38 +0000 Received: from localhost ([127.0.0.1]:46429 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSgST-0002Pg-KZ for submit@debbugs.gnu.org; Wed, 24 Jan 2024 11:50:38 -0500 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:56173) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSgSR-0002PQ-6g for 68688@debbugs.gnu.org; Wed, 24 Jan 2024 11:50:36 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id C60771BF203; Wed, 24 Jan 2024 16:50:22 +0000 (UTC) From: Juri Linkov In-Reply-To: (Spencer Baugh's message of "Wed, 24 Jan 2024 10:55:37 -0500") Organization: LINKOV.NET References: Date: Wed, 24 Jan 2024 18:45:08 +0200 Message-ID: <86ttn23ckr.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net 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 (-) > Patch which fixes this attached. Thanks for fixing the multi-line case. Could you please add a test in minibuffer-tests.el. Maybe easier is to replace '("aa" "ab" "ac") with '("aa" "a\nb" "ac"). Or a new test would be better, I don't know. > It simply adds an additional loop around forward-line which runs > until we leave the completion at point. Alternatively without a loop maybe simpler would be just to move to the end of the current completion before calling forward-line? > BTW, I think we should have some helper functions for "get start of > completion candidate or point-min" and "get end of completion candidate > or point-max", or possibly "move to start of candidate" and "move to end > of candidate"; it's pretty hard to get right. Completely agreed. We need more helper functions for all 4 functions: previous-completion, next-completion, previous-line-completion, next-line-completion. BTW, do you think that these parts below are not needed anymore since you implemented a hidden placeholder at the top in case of no header? diff --git a/lisp/simple.el b/lisp/simple.el index 692c0dacefc..ca3599e6cb3 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9913,11 +9913,11 @@ first-completion "Move to the first item in the completions buffer." (interactive) (goto-char (point-min)) - (if (get-text-property (point) 'mouse-face) - (unless (get-text-property (point) 'first-completion) - (let ((inhibit-read-only t)) - (add-text-properties (point) (min (1+ (point)) (point-max)) - '(first-completion t)))) + (if t ;; (get-text-property (point) 'mouse-face) + ;; (unless (get-text-property (point) 'first-completion) + ;; (let ((inhibit-read-only t)) + ;; (add-text-properties (point) (min (1+ (point)) (point-max)) + ;; '(first-completion t)))) (when-let ((pos (next-single-property-change (point) 'mouse-face))) (goto-char pos)))) @@ -9950,13 +9950,13 @@ next-completion (let ((tabcommand (member (this-command-keys) '("\t" [backtab]))) pos) (catch 'bound - (when (and (bobp) - (> n 0) - (get-text-property (point) 'mouse-face) - (not (get-text-property (point) 'first-completion))) - (let ((inhibit-read-only t)) - (add-text-properties (point) (1+ (point)) '(first-completion t))) - (setq n (1- n))) + ;; (when (and (bobp) + ;; (> n 0) + ;; (get-text-property (point) 'mouse-face) + ;; (not (get-text-property (point) 'first-completion))) + ;; (let ((inhibit-read-only t)) + ;; (add-text-properties (point) (1+ (point)) '(first-completion t))) + ;; (setq n (1- n))) (while (> n 0) (setq pos (point)) @@ -10019,13 +10019,13 @@ next-line-completion Also see the `completion-auto-wrap' variable." (interactive "p") (let (line column pos found) - (when (and (bobp) - (> n 0) - (get-text-property (point) 'mouse-face) - (not (get-text-property (point) 'first-completion))) - (let ((inhibit-read-only t)) - (add-text-properties (point) (1+ (point)) '(first-completion t))) - (setq n (1- n))) + ;; (when (and (bobp) + ;; (> n 0) + ;; (get-text-property (point) 'mouse-face) + ;; (not (get-text-property (point) 'first-completion))) + ;; (let ((inhibit-read-only t)) + ;; (add-text-properties (point) (1+ (point)) '(first-completion t))) + ;; (setq n (1- n))) (if (get-text-property (point) 'mouse-face) ;; If in a completion, move to the start of it. From unknown Sat Jun 21 05:05:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68688: 30.0.50; next-line-completion doesn't work with multiline completions Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jan 2024 18:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 68688@debbugs.gnu.org Received: via spool by 68688-submit@debbugs.gnu.org id=B68688.170612087230338 (code B ref 68688); Wed, 24 Jan 2024 18:28:01 +0000 Received: (at 68688) by debbugs.gnu.org; 24 Jan 2024 18:27:52 +0000 Received: from localhost ([127.0.0.1]:46557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rShya-0007tE-48 for submit@debbugs.gnu.org; Wed, 24 Jan 2024 13:27:52 -0500 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:53901) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rShyY-0007sz-Iu for 68688@debbugs.gnu.org; Wed, 24 Jan 2024 13:27:51 -0500 From: Spencer Baugh In-Reply-To: <86ttn23ckr.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 24 Jan 2024 18:45:08 +0200") References: <86ttn23ckr.fsf@mail.linkov.net> Date: Wed, 24 Jan 2024 13:27:39 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1706120859; bh=YsUIHvlZG1j7ws2lXU7A2O1SLrULjCPuogMZ7inoYUg=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=TTtMGGoFEPoMk2IsnjaOng/WlyBo3YxCjojZFue2ABg07PcfxgMC0mb+Pa1r30Rf6 c8B6Mhy3uit1pB5rhe5x1cDjWkOv/9cCJfAQS+MN6PokFRaeZQJb1SlNrx/zncgxie 4Zc3CciNn+0jATpfsNoRqtWlWjOJNlvKwH3u812b+ePTHmCKTUAcr/5QYAVI51ulZB wQEN7czoiGtOB6eK63PcSisV8l9O5559dFMZj3eIooY+OFB1EARgiigjztKS+39miY vY76/V2R95ND6rxcgFBASQGQtBGsnt/2XWgxaejSbM5/yZFR+LTmxq0dZMGrC0Lqa4 EDTNcxi0oT1Zg== 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 (-) --=-=-= Content-Type: text/plain Juri Linkov writes: >> Patch which fixes this attached. > > Thanks for fixing the multi-line case. Could you please > add a test in minibuffer-tests.el. Maybe easier is > to replace '("aa" "ab" "ac") with '("aa" "a\nb" "ac"). > Or a new test would be better, I don't know. Sure. New test is easier since "a\nb" sorts before "aa", so adding the newline changes the test results. >> It simply adds an additional loop around forward-line which runs >> until we leave the completion at point. > > Alternatively without a loop maybe simpler would be just to move > to the end of the current completion before calling forward-line? I was unsure whether that would work correctly in all cases. But it seems to pass tests, so let's just try it. If it does break, the bug report will give us some new test cases :) >> BTW, I think we should have some helper functions for "get start of >> completion candidate or point-min" and "get end of completion candidate >> or point-max", or possibly "move to start of candidate" and "move to end >> of candidate"; it's pretty hard to get right. > > Completely agreed. We need more helper functions for all 4 functions: > previous-completion, next-completion, previous-line-completion, > next-line-completion. Cool, I made two helpers in the latest version of my patch. Using only in next-line-completion for now, but we can use it more in the other completion function. > BTW, do you think that these parts below are not needed anymore > since you implemented a hidden placeholder at the top > in case of no header? Yes, I think all the code for 'first-completion can be removed. Updated patch for next-line-completion: --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Fix-next-line-completion-for-multi-line-completions.patch >From cbc8bdc1386a4bc9c420d8ab06b844c6f6928c35 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 24 Jan 2024 10:52:40 -0500 Subject: [PATCH] Fix next-line-completion for multi-line completions Previously it would not move out of a multi-line completion, and now it will. * lisp/simple.el (next-line-completion): Move to the completion start or end before going forward or backward lines. (bug#68688) --- lisp/simple.el | 20 +++++++++++++++++--- test/lisp/minibuffer-tests.el | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 692c0dacefc..4ffe159dc88 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9940,6 +9940,20 @@ previous-completion (interactive "p") (next-completion (- n))) +(defun completion--move-to-candidate-start () + "If in a completion candidate, move point to its start." + (when (and (get-text-property (point) 'mouse-face) + (not (bobp)) + (get-text-property (1- (point)) 'mouse-face)) + (goto-char (previous-single-property-change (point) 'mouse-face)))) + +(defun completion--move-to-candidate-end () + "If in a completion candidate, move point to its end." + (when (and (get-text-property (point) 'mouse-face) + (not (eobp)) + (get-text-property (1+ (point)) 'mouse-face)) + (goto-char (or (next-single-property-change (point) 'mouse-face) (point-max))))) + (defun next-completion (n) "Move to the next item in the completions buffer. With prefix argument N, move N items (negative N means move @@ -10029,9 +10043,7 @@ next-line-completion (if (get-text-property (point) 'mouse-face) ;; If in a completion, move to the start of it. - (when (and (not (bobp)) - (get-text-property (1- (point)) 'mouse-face)) - (goto-char (previous-single-property-change (point) 'mouse-face))) + (completion--move-to-candidate-start) ;; Try to move to the previous completion. (setq pos (previous-single-property-change (point) 'mouse-face)) (if pos @@ -10046,6 +10058,7 @@ next-line-completion (while (> n 0) (setq found nil pos nil column (current-column) line (line-number-at-pos)) + (completion--move-to-candidate-end) (while (and (not found) (eq (forward-line 1) 0) (not (eobp)) @@ -10070,6 +10083,7 @@ next-line-completion (while (< n 0) (setq found nil pos nil column (current-column) line (line-number-at-pos)) + (completion--move-to-candidate-start) (while (and (not found) (eq (forward-line -1) 0) (eq (move-to-column column) column)) diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index c1fe3032cb5..d104858b0d0 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -465,6 +465,20 @@ completion-auto-wrap-test (previous-line-completion 4) (should (equal "ac" (get-text-property (point) 'completion--string)))))) +(ert-deftest completion-next-line-multline-test () + (let ((completion-auto-wrap t)) + (completing-read-with-minibuffer-setup + '("a\na" "a\nb" "ac") + (insert "a") + (minibuffer-completion-help) + (switch-to-completions) + (goto-char (point-min)) + (next-line-completion 5) + (should (equal "a\nb" (get-text-property (point) 'completion--string))) + (goto-char (point-min)) + (previous-line-completion 5) + (should (equal "a\nb" (get-text-property (point) 'completion--string)))))) + (ert-deftest completions-header-format-test () (let ((completion-show-help nil) (completions-header-format nil)) -- 2.39.3 --=-=-=-- From unknown Sat Jun 21 05:05:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68688: 30.0.50; next-line-completion doesn't work with multiline completions Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Jan 2024 07:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: 68688@debbugs.gnu.org Received: via spool by 68688-submit@debbugs.gnu.org id=B68688.17061691088524 (code B ref 68688); Thu, 25 Jan 2024 07:52:02 +0000 Received: (at 68688) by debbugs.gnu.org; 25 Jan 2024 07:51:48 +0000 Received: from localhost ([127.0.0.1]:47222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSuWa-0002DP-Au for submit@debbugs.gnu.org; Thu, 25 Jan 2024 02:51:48 -0500 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:55371) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSuWY-0002DB-1Y for 68688@debbugs.gnu.org; Thu, 25 Jan 2024 02:51:47 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 7454A1BF206; Thu, 25 Jan 2024 07:51:33 +0000 (UTC) From: Juri Linkov In-Reply-To: (Spencer Baugh's message of "Wed, 24 Jan 2024 13:27:39 -0500") Organization: LINKOV.NET References: <86ttn23ckr.fsf@mail.linkov.net> Date: Thu, 25 Jan 2024 09:48:59 +0200 Message-ID: <86sf2l7t04.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net 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 (-) >> Alternatively without a loop maybe simpler would be just to move >> to the end of the current completion before calling forward-line? > > I was unsure whether that would work correctly in all cases. But it > seems to pass tests, so let's just try it. If it does break, the bug > report will give us some new test cases :) It might fail on a multi-column and at the same time multi-line layout. But currently this is just a hypothetical case. I remember there was an idea to use tabulated-list-mode in the completions buffer that could simplify next-completion but at the cost of breaking backward compatibility with existing commands that rely on text properties. >> Completely agreed. We need more helper functions for all 4 functions: >> previous-completion, next-completion, previous-line-completion, >> next-line-completion. > > Cool, I made two helpers in the latest version of my patch. Using only > in next-line-completion for now, but we can use it more in the other > completion function. Using helpers more would be nice. >> BTW, do you think that these parts below are not needed anymore >> since you implemented a hidden placeholder at the top >> in case of no header? > > Yes, I think all the code for 'first-completion can be removed. > > Updated patch for next-line-completion: Thanks for the patch. Now pushed to master. From unknown Sat Jun 21 05:05:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68688: 30.0.50; next-line-completion doesn't work with multiline completions Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Jan 2024 17:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: 68688@debbugs.gnu.org Received: via spool by 68688-submit@debbugs.gnu.org id=B68688.170620538618064 (code B ref 68688); Thu, 25 Jan 2024 17:57:02 +0000 Received: (at 68688) by debbugs.gnu.org; 25 Jan 2024 17:56:26 +0000 Received: from localhost ([127.0.0.1]:49148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rT3xh-0004hI-Mn for submit@debbugs.gnu.org; Thu, 25 Jan 2024 12:56:26 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:38759) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rT3xZ-0004gm-VI for 68688@debbugs.gnu.org; Thu, 25 Jan 2024 12:56:18 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id BDE4160007; Thu, 25 Jan 2024 17:56:04 +0000 (UTC) From: Juri Linkov In-Reply-To: <86sf2l7t04.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 25 Jan 2024 09:48:59 +0200") Organization: LINKOV.NET References: <86ttn23ckr.fsf@mail.linkov.net> <86sf2l7t04.fsf@mail.linkov.net> Date: Thu, 25 Jan 2024 19:52:19 +0200 Message-ID: <86msst5mi4.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net 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 (-) While testing, I found an old bug where group lines prevented from moving horizontally, such as moving from aa2 to ac2: > Group 1 aa1 aa2 aa3 aa4 > Group 2 ab1 > Group 3 ac1 ac2 The fix was very simple, and I updated the group test as well. From unknown Sat Jun 21 05:05:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68688: 30.0.50; next-line-completion doesn't work with multiline completions Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Feb 2024 07:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: 68688@debbugs.gnu.org Received: via spool by 68688-submit@debbugs.gnu.org id=B68688.170746335128851 (code B ref 68688); Fri, 09 Feb 2024 07:23:01 +0000 Received: (at 68688) by debbugs.gnu.org; 9 Feb 2024 07:22:31 +0000 Received: from localhost ([127.0.0.1]:41441 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYLDS-0007VG-Oe for submit@debbugs.gnu.org; Fri, 09 Feb 2024 02:22:30 -0500 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]:39771) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYLDQ-0007UE-Uf; Fri, 09 Feb 2024 02:22:29 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 5C9E560004; Fri, 9 Feb 2024 07:22:06 +0000 (UTC) From: Juri Linkov In-Reply-To: <86sf2l7t04.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 25 Jan 2024 09:48:59 +0200") Organization: LINKOV.NET References: <86ttn23ckr.fsf@mail.linkov.net> <86sf2l7t04.fsf@mail.linkov.net> Date: Fri, 09 Feb 2024 09:19:20 +0200 Message-ID: <86zfwai0mt.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net 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 68688 30.0.50 thanks >> Updated patch for next-line-completion: > > Thanks for the patch. Now pushed to master. It seems this bug report could be closed now.