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 12:01:03 -0400 Message-ID: References: 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="4683"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74019@debbugs.gnu.org, Juri Linkov To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 28 17:02:44 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 1t5SCZ-0000zk-Go for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Oct 2024 17:02:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5SBX-0008Uu-Ix; Mon, 28 Oct 2024 12:01:39 -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 1t5SBK-0008NI-VS for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2024 12:01:31 -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 1t5SBK-000587-NH for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2024 12:01:26 -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=XOU6RmyBfWp50y+BJLJFJZkxLF1i2FBJi6vQCL/gUcA=; b=vvC++EJ8q/VpWlL5QNMCnmPQuf2RrHBOgkRxjiVBb1pkwi9pjYXNdeVlnqrSXYhZFb8E7MQ5ZroVibVKcg8DlO1vpaU6eo2o1oWKw76FUc/WJqK72kXtOXW/Xh94RHhXprsRlknBqRsltSU0wPrnEXB/4svZlE1Q2rIPU0SIwfhNNkWjbm5/R/YmyoWkxLfJUTK/ifE/f9hpcMrYzXntapo+Kiz8DYwDLCNllFZe4PaI5TA58x4PXMTBxau+Xmlk6hoe9QPOwQWIr7YY0MVnrUKzhVjuj3sK1LCDOU6+R/55wZL7+9/4vE38kDkpp7VKZqMiS6u4YRu0aPVqcdLkQA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t5SBu-0007YE-Kd for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2024 12:02: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 16:02: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.173013130829000 (code B ref 74019); Mon, 28 Oct 2024 16:02:02 +0000 Original-Received: (at 74019) by debbugs.gnu.org; 28 Oct 2024 16:01:48 +0000 Original-Received: from localhost ([127.0.0.1]:54454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5SBf-0007Xd-HF for submit@debbugs.gnu.org; Mon, 28 Oct 2024 12:01:47 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:38149) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5SBd-0007XK-Ik for 74019@debbugs.gnu.org; Mon, 28 Oct 2024 12:01:46 -0400 In-Reply-To: (Stefan Monnier's message of "Mon, 28 Oct 2024 10:21:49 -0400") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1730131263; bh=XOU6RmyBfWp50y+BJLJFJZkxLF1i2FBJi6vQCL/gUcA=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=nNrZ0+xLomKmOBzKk9dy6jUEttRyeqQO4ItswKkuSb5VJmHFZ3f3it4/pBJ/li/09 CQPtvlTQkKnKtSep+RLLS3JjD098sHNXegpZ9Uiio58NrE6E0PB6QKXi5HDkOLsmkq ocol2mh2jWITr+wuLuhVk+kzG61PqjIasLAZKI1Rk2h6NVgVuqaFi5bXjvxPvxAmPd if4eGG84rv2gpdRnGFKo/on7xtZab/rj70dRVZZeire7DwJUbsREXM3ANK2BJXRPC6 k6XEew6T+o/iaLbLdQHV881NJN4fdfneFkikL5jqLroBBzS7fsALr2FDXrcKLM1w0p 8MAfdXRMHtajg== 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:294436 Archived-At: Stefan Monnier writes: >>> Hmm... are we sure here that the `*Completions*`s content is related to >>> the current completion session? I don't think we want to preserve the >>> selection when it came from an unrelated use of completion half an >>> hour earlier. >> >> That's why I'm doing get-buffer-window here - I figure that if >> *Completions* is currently displayed in a window, it's reasonable to >> preserve the selected candidate. >> >> (The selected candidate in that window, I guess - so maybe I should use >> window-point here?) >> >> It still might not be related to the current completion session, since >> the user might have just manually switched buffers to *Completions*, but >> I wasn't sure there was a good way to determine that... any suggestions? > > Indeed, it might not be related. E.g in my setup, `*Completions*` is > placed in a dedicated window&frame that is simply iconified/deiconified > as needed, so your heuristic would fail. (Interesting, is the code for that published somewhere? What's the motivation for that instead of a window?) > I think we need to store in the *Completions* buffer some info about the > completion session for which it was last used. Or set some buffer-local > var that indicates that the corresponding completion session is "done" > (we can do that when we hide the *Completions* buffer, when we exit the > minibuffer or the `completion-in-region-mode`). It would be nice to store info about the completion session, but we don't really have any concrete concept of "a completion session" right now, right? So it's not clear to me how we would keep track of when it starts and ends. Also, I think we sometimes want to avoid reusing *Completions* even within a completion session: if we're using completion in a directory tree containing a file /aaa/aaa, if we select "aaa" while completing on "/a", then "aaa" shouldn't still be selected if we complete on "/aaa/a". Do you think it would be sufficient to set a "done" buffer-local in minibuffer-hide-completions? That seems to be called in all the right places. Or maybe instead of a buffer-local, we could have minibuffer-hide-completions do (goto-char (point-min)) so no completion is selected anymore. Then it becomes harmless to reuse that *Completions* buffer.