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#72210: 31.0.50; Feature request: multi-category support in `icomplete-fido-kill'. Date: Thu, 25 Jul 2024 10:42:47 +0300 Message-ID: <86bk2l6hoo.fsf@gnu.org> References: <87ttgk16tg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5717"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72210@debbugs.gnu.org To: Fernando de Morais , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 25 09:44:05 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 1sWt8u-0001Oe-VA for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Jul 2024 09:44:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWt8o-0000Xk-J9; Thu, 25 Jul 2024 03:43:58 -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 1sWt8l-0000XE-L9 for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 03:43:55 -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 1sWt8l-00026u-CR for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 03:43:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sWt8s-0005hf-7O for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 03:44: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: Thu, 25 Jul 2024 07:44:02 +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.172189338521843 (code B ref 72210); Thu, 25 Jul 2024 07:44:02 +0000 Original-Received: (at 72210) by debbugs.gnu.org; 25 Jul 2024 07:43:05 +0000 Original-Received: from localhost ([127.0.0.1]:35435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sWt7w-0005gF-IS for submit@debbugs.gnu.org; Thu, 25 Jul 2024 03:43:04 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:59846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sWt7v-0005fe-7G for 72210@debbugs.gnu.org; Thu, 25 Jul 2024 03:43:03 -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 1sWt7i-0001fq-K9; Thu, 25 Jul 2024 03:42:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=kXDay9McJHDKaeiHlnDkfvI7uE8fbv6eD623HbORUVU=; b=ge+hBOUc6V7zKdzvg5Ln //uYZL2WY9t9eKtMAoTjREiOwUhwrAyvPsraGL1mdyZbMNEU9n4PCE3cDvTY+ICUKfFCszGRPCArA vMJjGyJv1bkjsvTzD3WhnpYvswSb3hF3kerX3C3POEMgu+bS74+Z3GjsqB5/ym/cM4FIabgyAlJqv NvFnP2wz/yRZFxomsbzjmoPFTCUNAr5KbSk3q2+ySgvZtiRebQ9bcpu/Op07mVD2wiLHAoas4NFej AFZKYH+ypj1fvXhSBVJfeqrKore5rooAgA8pIPdWuNIcP8pVCQOu4VNmHjMOIa24vF++5r92I+OIr nAR5kqD8UpmJug==; In-Reply-To: <87ttgk16tg.fsf@gmail.com> (message from Fernando de Morais on Sat, 20 Jul 2024 11:22:51 -0300) 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:289284 Archived-At: > From: Fernando de Morais > Date: Sat, 20 Jul 2024 11:22:51 -0300 > > Dear maintainers, > > `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'. > > What follows is just the ``hacky'' approach that's currently being used > in my init: > > #+begin_src emacs-lisp > ;; Stolen from Embark > (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', > otherwise kill the currently selected completion candidate. > Exactly what killing entails is dependent on the things being > completed. If completing files, it means delete the file. If > completing buffers it means kill the buffer. Both actions > require user confirmation." > (interactive) > (let ((end (icomplete--field-end))) > (if (< (point) end) > (call-interactively 'kill-line) > (let* ((all (completion-all-sorted-completions)) > ;; Actual changes ( > (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 > (lambda () > (when (yes-or-no-p (concat "Kill buffer " thing "? ")) > (kill-buffer thing)))) > ((project-file file) > (lambda () > (let* ((dir (file-name-directory > (icomplete--field-string))) > (path (expand-file-name thing dir))) > (when (yes-or-no-p (concat "Delete file " path "? ")) > (delete-file path) t)))) > (t > (error "Sorry, don't know how to kill things for `%s'" > cat))))) > (when (let (;; Allow `yes-or-no-p' to work and don't let it > ;; `icomplete-exhibit' anything. > (enable-recursive-minibuffers t) > (icomplete-mode nil)) > (funcall action)) > (completion--cache-all-sorted-completions > (icomplete--field-beg) > (icomplete--field-end) > (cdr all))) > (message nil))))) > #+end_src > > Thank you for any consideration on the matter. João, any comments?