From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71716: [PATCH] Add new completion-preview-insert-{word, sexp} commands Date: Sat, 22 Jun 2024 16:05:05 +0200 Message-ID: References: <87a5jd8hqh.fsf@gmail.com> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28168"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 71716@debbugs.gnu.org To: Jules Tamagnan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 22 16:06:28 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 1sL1Ns-00075Z-Bs for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Jun 2024 16:06:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sL1NT-00057J-VC; Sat, 22 Jun 2024 10:06:03 -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 1sL1NS-00056u-DB for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 10:06:02 -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 1sL1NS-0004LU-1z for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 10:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sL1NR-0006a4-Lo for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 10:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Jun 2024 14:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71716 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71716-submit@debbugs.gnu.org id=B71716.171906511025217 (code B ref 71716); Sat, 22 Jun 2024 14:06:01 +0000 Original-Received: (at 71716) by debbugs.gnu.org; 22 Jun 2024 14:05:10 +0000 Original-Received: from localhost ([127.0.0.1]:47130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sL1Mc-0006Ye-6p for submit@debbugs.gnu.org; Sat, 22 Jun 2024 10:05:10 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:41646 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sL1Ma-0006YU-1E for 71716@debbugs.gnu.org; Sat, 22 Jun 2024 10:05:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1719065107; bh=piQZDADCfgtkJJbJxC19ihJgRimuiVcK035E0yWnvxs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=CkwmE0G8kWzh5BkeF8ixJ8oB5ANzfcV1qLP1PXdGt1qbbDc+aZRY2vIbF/krplKQs 0EyD3DRDy2v8cXF1CPASVj8Aw9YEH4XnQLll0NJl07MYcyGzp/FzzZVrqj4vE7gtbq Fh+NwBYR9XPuEDd4U3OksdV4jk8bt2fNIdXz0MDiA3zvcrLCIWg0x+ePyTxjnMxEKT WuMeoJROB2d9qdRfa31PEOu2rZucJYT0sSJPKPQLMkyO7k4Clh5DrRjlSGNGGev7g1 209vcm5i8ywfYcOZmN0dBnbpvqu8hfylog8y5BwZfgW4TAXr2arTD3b6eTISrv3M2K h8cCdiryUFPOA== In-Reply-To: <87a5jd8hqh.fsf@gmail.com> (Jules Tamagnan's message of "Sat, 22 Jun 2024 02:11:18 -0700") 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:287706 Archived-At: Hi Jules, Jules Tamagnan writes: > Tags: patch Thanks for the feature request and for the patch. > * Problem > > Oftentimes when completing a value a user wants a small part of a > completion but not the entire thing. This happens frequently when > iterating on shell commands or on similar lines of > code. completion-preview can help with this by quickly suggesting a > sensible completion pulled from any completion-at-point function. The > problem is that accepting a full completion is often inefficient because > one might only want the first part of that completion. This leads to a > lot of deletions after the fact. > > * Solution > > Allow inserting of partial completions when using > completion-preview. We currently have completion-preview-complete (M-i) for that: it inserts the common part (prefix) of all completion candidates. > For this I've added two new commands completion-preview-insert-word > and completion-preview-insert-sexp which will insert the next word or > sexp in the completion. That sounds interesting. The ELPA package capf-autosuggest.el provided a similar feature, IIRC. I'd like to get a better understanding of the use case though: when would you use one of these commands instead of completion-preview-complete? > For consistency with completion-preview-insert I've refactored the > code so that these three commands share a common code path. Good idea, but there are two issues with the current implementation: 1. AFAICT, unlike completion-preview-insert, these new commands should preserve (the rest of) the completion preview. So instead of dismissing the preview by disabling completion-preview-active-mode and then relying on the subsequent post-command-hook to recreate the preview, I think these commands should modify (e.g. remove a word from the start of) the after-string property of the preview overlay, and inhibit a subsequent update of the preview, like we do in completion-preview-complete. That way we avoid recomputing the completion candidates, which may lead to a flicker in this case. 2. The temporary buffer where the motion command is executed has a different major mode than the original buffer, so they might have different notions of words/sexps. > * Notes > > - I've added new tests for this and ensured that previous ones continue > to pass. > - I've signed the copyright assignments and have contributed to emacs > previously. That's great, thanks. Eshel