From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74019: [PATCH] Optionally preserve selected candidate across *Completions* update Date: Mon, 28 Oct 2024 09:57:38 -0400 Message-ID: References: <86a5erbbwl.fsf@gnu.org> Reply-To: Spencer Baugh Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23692"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: juri@linkov.net, Andrea Corallo , Stefan Monnier , 74019@debbugs.gnu.org, Stefan Kangas To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 28 14:59:03 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 1t5QGp-0005ss-Nu for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Oct 2024 14:59:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5QGL-00011W-Hi; Mon, 28 Oct 2024 09:58:29 -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 1t5QGK-00011G-34 for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2024 09:58:28 -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 1t5QGI-0007E1-Jl for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2024 09:58:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=NrFGLeKKICd/BVwk9omXMq5lKJ9VMbAP63hRs7AVWYE=; b=p+0hNC4piBfzJwj0Xuv2vz60NI7JsZBu/wQumiiCzXAkVl/25CYyA39wtcuPRwry74WL8LCBWWoCrBCNXIjK2PGpzNApdD8nAbIkwLp6ugQI57RUwb55shEe8RSMWgJEekJKgxD/bgSO0KzlNIhUBUr0ngs+ywEti/MCwCutqFMuHcK+u/wOmvXboI1O8MEfoky75C0aOJAvLW/inlexJdYxtR7pzgtflj5oNQkvgRLtKoklM0Mbpb40diGW8MSiJBKCKYAFgMOkZ5lTKtAfG1bXqmqqE+85ICuexaqxqHOwyvlW50x7GDfgwJw/wnVY1WGnSjVMLR3ZM0Ctyzfj+g==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t5QGs-0001v9-OW for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2024 09: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: Mon, 28 Oct 2024 13:59: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.17301239027305 (code B ref 74019); Mon, 28 Oct 2024 13:59:02 +0000 Original-Received: (at 74019) by debbugs.gnu.org; 28 Oct 2024 13:58:22 +0000 Original-Received: from localhost ([127.0.0.1]:54241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5QGD-0001tk-U9 for submit@debbugs.gnu.org; Mon, 28 Oct 2024 09:58:22 -0400 Original-Received: from mxout6.mail.janestreet.com ([64.215.233.21]:43375) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5QGB-0001tX-MA for 74019@debbugs.gnu.org; Mon, 28 Oct 2024 09:58:20 -0400 In-Reply-To: <86a5erbbwl.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 26 Oct 2024 09:45:14 +0300") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1730123858; bh=NrFGLeKKICd/BVwk9omXMq5lKJ9VMbAP63hRs7AVWYE=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=obtvypK+zu1G8GOFwmNQfLE2fBtvY4veX4ax/tqz139QaToARROgKA4DHB/qi51zp EWSDPNsCp2f2vZhB48/ibF+80Kc0/GtUn4aDFllvTtmpAENA1UIdv95s5IkVfxlXqS 9lfvSclwLmzOkood4qVE877vyGb+/7S4u2/NOSueiVByWL2de6L2m2SisADNqeGrE7 K4s6WbRC+yLpWiyGO/5O1+tasJcbd0N0qgOZG49KQGM3EWk+5HIm8cidsczUDrh0nE SYBIJlzWPEg09QaZHJ7LxYFqYe/zgVPXYFQDUvuM9xRcH9ra0Ra2vGHGomurTkuG1H XgpFJ2DPyY8XQ== 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:294423 Archived-At: Eli Zaretskii writes: >> 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? FWIW, this patch is a very surface-level improvement to the default completion UI, it doesn't deal with the deeper complicated parts of the completion machinery. >> +(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. Will change. >> +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*? That's fair. minibuffer-completion-help is the function which updates *Completions*, but a user doesn't necessarily know that. Will clarify in next version. >> + (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. Will avoid the with-selected-window in the next version - a with-current-buffer is sufficient. >> @@ -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? See my reply to Stefan.