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#63785: 29.0.91; Clearing package list filters also clears flags Date: Mon, 29 May 2023 19:48:45 +0300 Message-ID: References: <87y1l7b3iy.fsf@gmail.com> Reply-To: Eshel Yaron 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="37754"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 63785@debbugs.gnu.org To: Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 29 18:49:16 2023 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 1q3g3X-0009c8-LW for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 May 2023 18:49:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3g3L-0007PL-KZ; Mon, 29 May 2023 12:49: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 1q3g3K-0007PD-0l for bug-gnu-emacs@gnu.org; Mon, 29 May 2023 12:49:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q3g3J-0002jr-Oq for bug-gnu-emacs@gnu.org; Mon, 29 May 2023 12:49:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q3g3J-0001NA-LV for bug-gnu-emacs@gnu.org; Mon, 29 May 2023 12:49: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: Mon, 29 May 2023 16:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63785 X-GNU-PR-Package: emacs Original-Received: via spool by 63785-submit@debbugs.gnu.org id=B63785.16853789355263 (code B ref 63785); Mon, 29 May 2023 16:49:01 +0000 Original-Received: (at 63785) by debbugs.gnu.org; 29 May 2023 16:48:55 +0000 Original-Received: from localhost ([127.0.0.1]:59015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3g3C-0001Mo-Pl for submit@debbugs.gnu.org; Mon, 29 May 2023 12:48:55 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:58012 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3g39-0001Mf-GD for 63785@debbugs.gnu.org; Mon, 29 May 2023 12:48:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1685378930; bh=9aUwbvusIjzXWEAqLuzIKH7UKITsqXHnMRmfYQG5JuE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=uU+E3F4hPmZrRpo+jBflVn8tRTfXIU3rfS14sZl3f+KE6T04Qyqdv6oxAXrRHFdHR Agpgdsk8f1Mf0Smkf1VkwgTacxbTfe6m1dNVuh5hJ+qoCiQ1n5EcBZpg/1P5NRW1Pl BK3fyZyNBvZTrtU4DA8QUjTcWB9Cd0PJ6GNtmnYcNiZKoshb0djTx48foWGEhvPxX4 6wAZ/Eomac87IbPFEkfi6mO2zIgWqX5EuMuJXip+v98A5qX69Sz79KHmybYGS26upW O6lYb8P3SLieUgjLGmnq3FF7JHybJo+/Htktlpyc8SEIjcHBk6DHhzenJJCXfke0aM iambl46EeYPsw== In-Reply-To: <87y1l7b3iy.fsf@gmail.com> (Robert Pluim's message of "Mon, 29 May 2023 16:44:53 +0200") 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:262600 Archived-At: --=-=-= Content-Type: text/plain Robert Pluim writes: > M-x list-packages > / n ack ;; navigate to the line for 'ack' > i ;; 'ack' has the 'I' flag > / / ;; 'ack' no longer has the I flag > > This makes it harder to do 'search for foo, mark, > search for bar, mark, install', you have to remember to execute the > action after each mark command. > That's an interesting issue, it can be a bit tricky because while filtering for "bar", "foo" is no longer anywhere to be found in the buffer. So AFAIU to solve this Emacs needs to maintain something like a buffer-local association between list entry (package) ids and the tags they were given. This sounds like something that applies more broadly to other `tabulated-list-mode` derivatives as well. The attached patch adds a `tabulated-list-maintain-tags` variable and enables it in `package-menu-mode`. With it I can search and mark foo, then search and mark bar, and then install both, as you say. WDYT? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Maintain-tags-when-filtering-packages.patch >From d94febc93f840a28187cd9e3831be0deb0fa4c61 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Mon, 29 May 2023 19:23:12 +0300 Subject: [PATCH] Maintain tags when filtering packages Allow 'tabulated-list-mode' derivatives to maintain tags when repopulating the buffer. Enable this option in 'package-menu-mode'. * lisp/emacs-lisp/tabulated-list.el (tabulated-list-tags-alist) (tabulated-list-maintain-tags): New buffer-local variables. (tabulated-list-put-tag): Associate entries with tags in 'tabulated-list-tags-alist'. (tabulated-list-print): Restore tags if 'tabulated-list-maintain-tags' is non-nil. * lisp/emacs-lisp/package.el (package-menu-mode): Enable 'tabulated-list-maintain-tags'. (Bug#63785) --- lisp/emacs-lisp/package.el | 1 + lisp/emacs-lisp/tabulated-list.el | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 69595601bc8..a050f405ba0 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -3145,6 +3145,7 @@ package-menu-mode ("Description" 0 package-menu--description-predicate)]) (setq tabulated-list-padding 2) (setq tabulated-list-sort-key (cons "Status" nil)) + (setq tabulated-list-maintain-tags t) (add-hook 'tabulated-list-revert-hook #'package-menu--refresh nil t) (tabulated-list-init-header) (setq revert-buffer-function 'package-menu--refresh-contents) diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index ddac6ed1746..e1922279039 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -167,6 +167,12 @@ tabulated-list-sort-key non-nil, means to invert the resulting sort.") (put 'tabulated-list-sort-key 'permanent-local t) +(defvar-local tabulated-list-tags-alist nil + "Association between entry ids and their tags in the current buffer.") + +(defvar-local tabulated-list-maintain-tags nil + "When non-nil, maintain tags when repopulating the current tabulated list.") + (defsubst tabulated-list-get-id (&optional pos) "Return the entry ID of the Tabulated List entry at POS. The value is an ID object from `tabulated-list-entries', or nil. @@ -200,6 +206,8 @@ tabulated-list-put-tag (make-string (- tabulated-list-padding width) ?\s)) (truncate-string-to-width tag tabulated-list-padding)))) (delete-region beg (+ beg tabulated-list-padding))))) + (when-let ((id (tabulated-list-get-id))) + (setf (alist-get id tabulated-list-tags-alist) tag)) (if advance (forward-line))) @@ -497,6 +505,14 @@ tabulated-list-print (setq entries (cdr entries))) (when update (delete-region (point) (point-max))) + (when tabulated-list-maintain-tags + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (when-let ((id (tabulated-list-get-id)) + (tag (alist-get id tabulated-list-tags-alist))) + (tabulated-list-put-tag tag)) + (forward-line)))) (set-buffer-modified-p nil) ;; If REMEMBER-POS was specified, move to the "old" location. (if saved-pt -- 2.40.1 --=-=-=--