From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fernando de Morais Newsgroups: gmane.emacs.bugs Subject: bug#72210: 31.0.50; Feature request: multi-category support in `icomplete-fido-kill'. Date: Mon, 02 Sep 2024 13:23:19 -0300 Message-ID: <87r0a258js.fsf@gmail.com> References: <87ttgk16tg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22474"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 72210@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 02 18:26:20 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 1sl9sh-0005ce-F7 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 02 Sep 2024 18:26:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sl9sa-0001jR-3y; Mon, 02 Sep 2024 12:26:12 -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 1sl9sU-0001iR-H1 for bug-gnu-emacs@gnu.org; Mon, 02 Sep 2024 12:26:06 -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 1sl9sU-0000xY-7i for bug-gnu-emacs@gnu.org; Mon, 02 Sep 2024 12:26:06 -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:References:Date:In-Reply-To:From:To:Subject; bh=v0a6a8p7obmTc/AwXLGiLPjiLlJT0PwB5pYOn5yW8Bo=; b=ZupMCjH1QKiaO87eiKFi5Ay3q/i9Wo7YfXGgdp+S/pJktP1LRYvmCoMPTEFrfobOqXI7dAaBEiy8l+1q7d/gRKpZZGPINKKDg9lep6pbq+N9v0CQzzXyC8xPIIEWXbACLtAlZZ2RvzWWiBelqcRdY6procmA9FWmJ0gu2q+Ei3/LeaezwewGWerq8DX1U4gs3EAHzKWTZ3L0l6goE0z2s6k9YvQNz2p/lrCGLFeu3qoR0XDdibKM+kOUouv5dg0GCb+FILl/tOjOa9p3EJj4ZOFrpKimbimeekW0Vy78YaIHy/pldaplOLVYz8jeXGNDzjRYj9MneF/aJ0+nMkmEZw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sl9tT-0004HV-8i for bug-gnu-emacs@gnu.org; Mon, 02 Sep 2024 12:27:07 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Fernando de Morais Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Sep 2024 16:27:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72210 X-GNU-PR-Package: emacs Original-Received: via spool by 72210-submit@debbugs.gnu.org id=B72210.172529442116357 (code B ref 72210); Mon, 02 Sep 2024 16:27:07 +0000 Original-Received: (at 72210) by debbugs.gnu.org; 2 Sep 2024 16:27:01 +0000 Original-Received: from localhost ([127.0.0.1]:50006 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sl9tM-0004Fl-UH for submit@debbugs.gnu.org; Mon, 02 Sep 2024 12:27:01 -0400 Original-Received: from mail-oo1-f54.google.com ([209.85.161.54]:58678) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sl9tL-0004FP-94 for 72210@debbugs.gnu.org; Mon, 02 Sep 2024 12:27:00 -0400 Original-Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5dca990cf58so2760586eaf.1 for <72210@debbugs.gnu.org>; Mon, 02 Sep 2024 09:25:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725294292; x=1725899092; darn=debbugs.gnu.org; h=mime-version:user-agent:references:message-id:date:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=v0a6a8p7obmTc/AwXLGiLPjiLlJT0PwB5pYOn5yW8Bo=; b=hX0393teLe/alt+j+axINA4NQGdnrapPvAPotVYfXTZJsjCia7ID1G6BLBgrfBpZ0d vtvH13JV1FKmyVSxGNZqw/g7Y+MzY8frM0EVoFPuGfWQwUXAg0lz7DQBaeI/foYHbIYS JcDRuflihuMWj5ZrtipSNe0sOIAiWj+GG6DNeiJV0kyZIjVKv6JNOBOZRytgcTgcA9Qa e61y5rUTjyb6VKTxEwyov0ACnZ3igmu2hsfLRJZOU5/gTk5shlaDHlA9lW1txPcfKlzU vew7sWmQSFAsbliqelbFW+hh0wZNDs24Tv8g5hjaupc6ql/opJrY9Lcm9BakGDoMAzO6 gjNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725294292; x=1725899092; h=mime-version:user-agent:references:message-id:date:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=v0a6a8p7obmTc/AwXLGiLPjiLlJT0PwB5pYOn5yW8Bo=; b=EGSIGPez9hCrK9YgPvxQLsYyZT/QdoV7kG7Bbowm1EhqJ2SrlgIEElcF37E1g+e7Ch dzSpiigyakuIz3G/vaZZ9bsEvgvHCN90FIe4gmHchEa+2BG/kyzObfT9VU9VrXK2U/m4 xyHlsfGKZ6cM1gw9xkRHdek+YWyBgYP8MJdUACWglUwB7sUaxVMcdIJm6tSuoS+t1x5Q +vEZJOFrejEhRzXiBbW1vAbO+SWbVa6wrfAWKAib0FsG5RCrSg7dHG9w0H0iY2Ugud4f PpCPUXBlofxOBjZKAXKpL3CXMUqV6h2UHB6dHfkbvijTokNo4WtckcqjQFuCqdB7FLii xPhQ== X-Gm-Message-State: AOJu0YwZ4EyK1XFJAgVg5B2XfDKarFbw+zUuM8PPPDPobB4xQNW+dUOP 4k9flLBOedrc9cWP7R1f2zz8QCDdgFQBKSPtygCDXeEVX/EGcqgMeCGG2w== X-Google-Smtp-Source: AGHT+IG9TO7CxaEZ1koPdtlZa4e2ZkInwNR6UAreIXPKd/4dP9AyNxPWMNJCCGwMqCPUzOrTOsjJqg== X-Received: by 2002:a05:6870:b506:b0:269:2708:afed with SMTP id 586e51a60fabf-27800333f2fmr2833064fac.30.1725294291796; Mon, 02 Sep 2024 09:24:51 -0700 (PDT) Original-Received: from sekai ([2804:14c:da80:83fa::7066]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e5749b51sm7045784b3a.184.2024.09.02.09.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 09:24:50 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sun, 01 Sep 2024 10:46:09 -0400") 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:291110 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Stefan, Stefan Monnier writes: >> `icomplete-fido-kill' works very well, but cannot handle the deletion of >> files or killing buffers when they are behind a multi-category >> ``situation''. Add this would be useful for those of us that combine >> `icomplete' with, e.g., `consult-buffer'. > > Can you provide a recipe? I'm not sufficiently familiar with that code > to really understand the problem you're facing. Sure! Please, install the `consult' package and, in an emacs -Q session, evaluate the following: #+begin_src emacs-lisp (progn (package-initialize) (load-library "consult") (icomplete-vertical-mode t) (keymap-set icomplete-minibuffer-map "C-k" 'icomplete-fido-kill)) #+end_src - Then, ``M-x consult-buffer''; - Type *M (this should turn the `*Messages*' buffer the current candidate); - Then ``C-k'' The following message should appear in the minibuffer: [Sorry, don=E2=80=99t know how to kill things for =E2=80=98multi-category= =E2=80=99] The same happens when we try to use `icomplete-fido-kill' in files listed by `consult-buffer'. The expected result would be for `icomplete-fido-kill' to work normally, killing the buffer, even though it is listed by `consult-buffer'. >> What follows is just the ``hacky'' approach that's currently being used >> in my init: > > Any chance you can make it a patch against `icomplete.el`? Follows attached! This is my first patch, so I might have made mistakes, but I'm here to adjust whatever you deem necessary. --=20 Regards, Fernando de Morais. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-support-for-multi-category-to-icomplete-fido-kil.patch >From 7fd715580d70d1c7cb7dbbe3035a439c4d06c49d Mon Sep 17 00:00:00 2001 From: Fernando de Morais Date: Mon, 2 Sep 2024 13:14:04 -0300 Subject: [PATCH] Add support for multi-category to icomplete-fido-kill * etc/NEWS: Announce the multi-category support in 'icomplete-fido-kill'. * lisp/icomplete.el (icomplete--refine-multi-category): New function. (icomplete-fido-kill): Apply the helper function to refine 'multi-category' to its actual type. --- etc/NEWS | 7 +++++++ lisp/icomplete.el | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1e66f084117..86c2995cf19 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -65,6 +65,13 @@ different values for completion-affecting variables like applies for the styles configuration in 'completion-category-overrides' and 'completion-category-defaults'. +** Icomplete + +--- +*** 'icomplete-fido-kill' now works within multi-category environments. +This function can now delete a file or kill a buffer within a +multi-category environment, such as 'consult-buffer'. + ** Windows +++ diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 2ea5e36fa88..1ef861ff270 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -317,6 +317,16 @@ Return non-nil if something was stepped." ;;;_* Helpers for `fido-mode' (or `ido-mode' emulation) +(defun icomplete--refine-multi-category (target) + "Refine `multi-category' TARGET to its actual type." + (or (let ((mc (get-text-property 0 'multi-category target))) + (cond + ;; The `cdr' of the `multi-category' property can be a buffer object. + ((and (eq (car mc) 'buffer) (buffer-live-p (cdr mc))) + (cons 'buffer (buffer-name (cdr mc)))) + ((stringp (cdr mc)) mc))) + (cons 'general target))) + (defun icomplete-fido-kill () "Kill line or current completion, like `ido-mode'. If killing to the end of line make sense, call `kill-line', @@ -330,8 +340,10 @@ require user confirmation." (if (< (point) end) (call-interactively 'kill-line) (let* ((all (completion-all-sorted-completions)) - (thing (car all)) - (cat (icomplete--category)) + (refined-pair (when (eq 'multi-category (icomplete--category)) + (icomplete--refine-multi-category (car all)))) + (cat (or (car-safe refined-pair) (icomplete--category))) + (thing (or (cdr-safe refined-pair) (car all))) (action (cl-case cat (buffer -- 2.46.0 --=-=-=--