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: Sat, 31 Aug 2024 10:57:47 +0300 Message-ID: <86ttf1cef8.fsf@gnu.org> References: <87ttgk16tg.fsf@gmail.com> <86bk2l6hoo.fsf@gnu.org> <86sev34ln5.fsf@gnu.org> 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="35505"; mail-complaints-to="usenet@ciao.gmane.io" Cc: fernandodemorais.jf@gmail.com, 72210@debbugs.gnu.org To: joaotavora@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 31 09:58:24 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 1skJ04-00094i-Bg for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 31 Aug 2024 09:58:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1skIzs-0000Uu-5Y; Sat, 31 Aug 2024 03:58: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 1skIzm-0000Sq-3x for bug-gnu-emacs@gnu.org; Sat, 31 Aug 2024 03:58:08 -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 1skIzk-0004q8-Ib for bug-gnu-emacs@gnu.org; Sat, 31 Aug 2024 03:58:05 -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:In-Reply-To:From:Date:To:Subject; bh=4WPiKMDy7Q5VlIbPF87gGGUHKrh8FMiEmaDOl8AJExg=; b=KgYHp5mzU+faNs1HeoO2DnSCtwieE3uyeIhhNzG3HYg/MiXNSjcIs5bl0GOpOWnUnUkei7idCvF47CVENJxwr25tASqp7gLCD4Rf42QH8NdJqSLER9lh4FzlKsSZK99613j5Y8ZLYsIUMmpPvgIP6MU6Rm7X/t1lMtNLQsySBwnYymcSHVQNmz4DotWMukzOcFYgvsqzqj7Nv2wE53pil+6FhYcy32K5wC0duleaC7d+jkNVaUEzmxh4LPglwhe5qIDa1gLQNmyoDqodzWrgsxjCye9VoAb6HgzKq4VrT1t8b7QqsiVr60nA2u5+zEYzNb5e2ZoMmChp/USFyKbnrA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1skJ0g-00067N-Aw for bug-gnu-emacs@gnu.org; Sat, 31 Aug 2024 03:59: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: Sat, 31 Aug 2024 07:59: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.172509114123511 (code B ref 72210); Sat, 31 Aug 2024 07:59:02 +0000 Original-Received: (at 72210) by debbugs.gnu.org; 31 Aug 2024 07:59:01 +0000 Original-Received: from localhost ([127.0.0.1]:53840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1skJ0f-000678-30 for submit@debbugs.gnu.org; Sat, 31 Aug 2024 03:59:01 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1skJ0d-00066r-Kv for 72210@debbugs.gnu.org; Sat, 31 Aug 2024 03:59:00 -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 1skIzc-0004mi-HR; Sat, 31 Aug 2024 03:57:56 -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=4WPiKMDy7Q5VlIbPF87gGGUHKrh8FMiEmaDOl8AJExg=; b=LRoahVYoCPCLeO7l6aeD Pj4T0dTlipmNObwqEQhQ9NFmU3MEa8j399M3xYBM8RJNgNq8TC8U+j53voVK+NW/D07mDVXaoplJc Kt7ENuHtf/1BXQxNAHxjZhiE/usVbbjolq/GxAcji16MQWxoC65JGqcb5XkZC8+xzt5C00MM3M/uM RQJDQETNgD/x8MIFuw4EBsn8mwDInAbPdKEVvM2dcagO34CIlgerfgOeLhree9wKJiDq/h3tCWd30 qiSS0ev12jIs1a48R7w2j2WyzGyLQ+V6P4N+58HCXJofgea8qTEMhI1Laz6rhpCGmDyzrFuFVS7Oj gF4yYJjNUtYzbA==; In-Reply-To: <86sev34ln5.fsf@gnu.org> (message from Eli Zaretskii on Sat, 17 Aug 2024 11:08:14 +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:290977 Archived-At: Ping! Ping! João, please respond. > Cc: fernandodemorais.jf@gmail.com, 72210@debbugs.gnu.org > Date: Sat, 17 Aug 2024 11:08:14 +0300 > From: Eli Zaretskii > > Ping! João, any comments to this issue? > > > Cc: 72210@debbugs.gnu.org > > Date: Thu, 25 Jul 2024 10:42:47 +0300 > > From: Eli Zaretskii > > > > > 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? > > > > > > > > > > > >