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: Sat, 20 Jul 2024 11:22:51 -0300 Message-ID: <87ttgk16tg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13214"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 72210@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 20 16:26:26 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 1sVB2X-0003Ft-Nn for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 20 Jul 2024 16:26:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVB2D-0001EI-Ha; Sat, 20 Jul 2024 10:26:05 -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 1sVB2A-0001BA-HF for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2024 10:26: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 1sVB29-00059i-Oj for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2024 10:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sVB2A-0005Jm-3M for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2024 10:26:02 -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: Sat, 20 Jul 2024 14:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 72210 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172148552020369 (code B ref -1); Sat, 20 Jul 2024 14:26:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Jul 2024 14:25:20 +0000 Original-Received: from localhost ([127.0.0.1]:53732 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sVB1T-0005IS-I4 for submit@debbugs.gnu.org; Sat, 20 Jul 2024 10:25:19 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:33156) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sVB1R-0005II-VN for submit@debbugs.gnu.org; Sat, 20 Jul 2024 10:25:18 -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 1sVB1R-0000zU-AK for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2024 10:25:17 -0400 Original-Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVB1P-00050e-21 for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2024 10:25:17 -0400 Original-Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1fc52394c92so24610055ad.1 for ; Sat, 20 Jul 2024 07:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721485510; x=1722090310; darn=gnu.org; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=N64nzn8ajtInNbpUjpgb5OT8vxU1ClwcWtUKAaGQOFM=; b=g3AeA1qwoXtkMLlvWTFPS4l6+d4Yf/yWUFTkof2idMsyWWWKnT1BvgaBgnNzkQRxPc OBNjn718tW1i6y5q6IDQLX8qWZ57cPYFWvaupvPcuAx0beYybZHBVro4B6kg7QlXF/S5 ypOaUmQN4fStsa9OSqzD2/steP0G28x1tR4Kr2ljExP0yq/i7rVDTysB4ix5647IzUYD SWUJC+KdCPus3X80TS9RkI7HpAu6g9HIm49BgWsCRoJtA6msgjrpT6YvLepbjNXbq8Cq QrfPkkgsre49v3Cctuj+nV22PGZCT8ZRK2Dl7nj9+hoynlQOoSXjekXx0kmwZqppvckE htIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721485510; x=1722090310; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N64nzn8ajtInNbpUjpgb5OT8vxU1ClwcWtUKAaGQOFM=; b=RLwGZiEfVigbPvrhUoYgkEKxF0qXsHqpHeuyEOTufHgZkiJTYfB2vgPxAlqdCy0LHd 3nMS75I0qutcdJlFoZoiYcQnKxW4MPG8/gP14jlPBqNA3ZkWHBaRAbrhhP4Skb0Ef/go 9huNB8R3bkpcR5vOaQDlglDno+XQ34X9aPriKzLyUN3UxsNFzNHtHHmTixFuI2i+3Fc2 eY9mHhgqPeken7Zy8EP/e2IRusp5l47LN4l9+rqJ/zgjpMnWoorS4I3RX8zsIUeEOVqU E4zfg2OGMLJLcilyrmdkF1ab87NQE0yyQeNufs0gZIKtV7XjCXJKECLT8J6H9UI7RVPN 3LSA== X-Gm-Message-State: AOJu0Yza3z4qRckOQRVMY0uOR+cppX7QF/ZTA9M0nJubq+zNzYT8hmza v4wpvhhEwSTceb2HV56I0tcQ0Iq19r0he7vOMAqbp06NooZi/gYd77uTRA== X-Google-Smtp-Source: AGHT+IHTtSt15bVwEaz8+FrsDqlfXiij6jjCAsxURfXWxGu2XZ4WAH58+SPPtkQruoq+orVX6whZDQ== X-Received: by 2002:a17:902:ecc5:b0:1fa:221b:a7ef with SMTP id d9443c01a7336-1fd7461f2e1mr31363435ad.41.1721485509746; Sat, 20 Jul 2024 07:25:09 -0700 (PDT) Original-Received: from sekai ([2804:14c:da80:83fa::499c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd6f4647f5sm22441185ad.252.2024.07.20.07.25.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jul 2024 07:25:09 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=fernandodemorais.jf@gmail.com; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:289041 Archived-At: 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. -- Regards, Fernando de Morais.