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#74019: [PATCH] Optionally preserve selected candidate across *Completions* update Date: Sat, 26 Oct 2024 09:45:14 +0300 Message-ID: <86a5erbbwl.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28425"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74019@debbugs.gnu.org, juri@linkov.net To: Spencer Baugh , Stefan Monnier , Stefan Kangas , Andrea Corallo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 26 08:46:53 2024 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 1t4aZZ-0007Jh-M3 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Oct 2024 08:46:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4aZD-000116-6E; Sat, 26 Oct 2024 02:46:31 -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 1t4aZB-00010x-Px for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2024 02:46:29 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4aZB-0007NK-H6 for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2024 02:46:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=FBcJwYucmhFiJMfr6IUH9zNc5QnumblE2HfqQSzM+Ho=; b=KPDB6OQoOSFTImrn+JywHE5yEUYDC6rspMklSXFH5pyoFidlBJIjzBWfrOICd+MBQUyppFfiFC8ayZABRf2O/3OZGu6SQy42kHxlGgZTx6w9SHJ4fldoA3NatAWwjsc3VIBUaVSAEIdHab3tJ2T8J8CY/MccGZ+ZOOmdiJPERD/dNsSEXDTPKBZlY5LeGd1zyeAZowPUXTDY/abChfcOt8z239NJ2+taPxA+7K2It0ctrsMohx5L2eCtQZG+iGhCXI3T9SXgOtgKkDZAT6+IbqKQLhruGC+ylzt+2XFEzoysoZLDH/Eop6Yigc/6HCtvx4XliHVrRoJ5Oqsfa8NDHA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t4aZi-0003RY-2Y for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2024 02:47:02 -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, 26 Oct 2024 06:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74019 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74019-submit@debbugs.gnu.org id=B74019.172992516313145 (code B ref 74019); Sat, 26 Oct 2024 06:47:02 +0000 Original-Received: (at 74019) by debbugs.gnu.org; 26 Oct 2024 06:46:03 +0000 Original-Received: from localhost ([127.0.0.1]:40384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4aYl-0003Pw-6B for submit@debbugs.gnu.org; Sat, 26 Oct 2024 02:46:03 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4aYi-0003PP-FQ for 74019@debbugs.gnu.org; Sat, 26 Oct 2024 02:46:02 -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 1t4aY2-0007GK-Pj; Sat, 26 Oct 2024 02:45:18 -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=FBcJwYucmhFiJMfr6IUH9zNc5QnumblE2HfqQSzM+Ho=; b=ITJa6DXSN53s ontfIfSGEzbxfUNxtBpKOSa5GNkC+tDNp8AImwKPDsA7VH9JOGcvAYtXdo0Bn7W9Gw8BjSj7c+cZ7 PO+0uPbPJ36M1YMtIDqp3eZL4lO/Ddp1WnBFz4ngbAvUTQEoI5B29AL+/HrhbEZ+EAojURhJ1hfz9 G5ULE3+/1VFxo8fxzVOKTxaNMqj6jb3JyAX8mcGtlw1euY+wbuugj03kscnrcDpit2An9eO2HwYbK SK6lhIBpKDtAY3GEALzLtcBHm21W6H0FEyV8v5xwCbn7cperz4dEWjV+CA5A5K9euYgDJlsLiKnDJ V9gesRMG4/HOpbCM8FJAFQ==; In-Reply-To: (bug-gnu-emacs@gnu.org) 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:294252 Archived-At: > Cc: Juri Linkov > Date: Fri, 25 Oct 2024 17:32:38 -0400 > From: Spencer Baugh via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Add completion-preserve-selection, a defcustom which allows keeping the > same selected candidate after *Completions* is updated by > minibuffer-completion-help. Shouldn't we stop complicating the completion machinery at some point? It is already basically impenetrable, and if someone still can reason about what it does in any specific case, my hat's off to them; I have long ago reached the point where the _only_ way of understanding what's going on is to step with a debugger through the code -- and it doesn't help that some of the code is in Lisp and some in C, so Lisp calls into C, which calls back into Lisp, etc., thus one needs to interrupt the stepping, fire up a different debugger, then go back. Stefan, WDYT? Should we close completion to further development and accept only bugfixes? What do Stefan Kangas and Andrea think? > +(defcustom completion-preserve-selection nil > + "If non-nil, `minibuffer-completion-help' preserves the selected completion candidate. This doc-string line is too long. I also don't like the name: "selection" could be confused to mean the X selection. I'd use "selected-candidates" instead. > +If non-nil, and point is on a completion candidate in the displayed > +*Completions* window, `minibuffer-completion-help' will put point on the > +same candidate after updating *Completions*." This is completely unclear: what does minibuffer-completion-help have to do with updating *Completions*? > + (current-candidate-and-offset > + (when-let* ((window (get-buffer-window "*Completions*" 0))) > + (with-selected-window window > + (when-let* ((beg (completions--start-of-candidate-at (point)))) > + > + (cons (get-text-property beg 'completion--string) (- (point) beg)))))) Why is this done unconditionally? with-selected-window is not a cheap function. > @@ -4905,8 +4928,6 @@ minibuffer-next-completion > (interactive "p") > (let ((auto-choose minibuffer-completion-auto-choose)) > (with-minibuffer-completions-window > - (when completions-highlight-face > - (setq-local cursor-face-highlight-nonselected-window t)) Why is this being moved to a different place?