unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#39903: 28.0.50; Feature request: another filter for Package Menu
@ 2020-03-04 14:53 Pieter van Oostrum
  2020-03-05 14:24 ` Pieter van Oostrum
  2020-03-05 14:51 ` Stefan Kangas
  0 siblings, 2 replies; 8+ messages in thread
From: Pieter van Oostrum @ 2020-03-04 14:53 UTC (permalink / raw)
  To: 39903

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 1424 bytes --]

This is a request for a new filter in Package Menu.

Motivation: The command `package-menu-mark-upgrades' in the "*Packages*"
buffer marks all packages that have new versions. Both the new versions
are marked for installation (I) and the old versions for deletion (D).

However, it is not so easy to inspect which packages will be
affected. Currently the only simple ways are to do an `isearch' in the
"*Packages*" buffer for "^[^ ]", or to do an `occur' for the same
regexp. The latter gives an overview of all packages involved, but
requires an indirection step to get into the "*Packages*" buffer, for
example to unmark a package.

The attached file adds a new command to filter the "*Packages*"
buffer to show only the packages with a non-empty mark, i.e. the same as
the above `occur' command would show, but then without the extra
indirection.

My proposal is to bind it to "/m", and to add a menu entry.

This function is dependent on commit aea12d4903 (Bug#38424), which
introduces other filters. Contrary to the other filters, this filter
keeps the marks intact. Otherwise it would not be useful.
(Other filters clear the marks, because the marks are not part of the
data structure that builds the package list, but only of the
representation in the buffer.)

If this filter is accepted, I will make it into a full-blown patch with
documentation, etc.) The current format is fit to be included in the `init' file.


[-- Attachment #2: package-filter.el --]
[-- Type: application/octet-stream, Size: 1312 bytes --]

(defun package-menu--filter-marked ()
  "Filter \"*Packages*\" buffer by non-empty upgrade mark.
Unlike other filters, this leaves the marks intact."
  (interactive)
  (package--ensure-package-menu-mode)
  (widen)
  (let (found-entries mark pkg-id entry marks)
    (save-excursion
      (goto-char (point-min))
      (while (not (eobp))
        (setq mark (char-after))
        (unless (eq mark ?\s)
	  (setq pkg-id (tabulated-list-get-id))
          (setq entry (package-menu--print-info-simple pkg-id))
	  (push entry found-entries)
	  ;; remember the mark
	  (push (cons pkg-id mark) marks))
        (forward-line))
      (if found-entries
          (progn
            (setq tabulated-list-entries found-entries)
            (package-menu--display t nil)
	    ;; redo the marks, but we must remember the marks!!
	    (goto-char (point-min))
	    (while (not (eobp))
	      (setq mark (cdr (assq (tabulated-list-get-id) marks)))
	      (tabulated-list-put-tag (char-to-string mark) t)))
	(user-error "No packages found")))))

(eval-after-load 'package
  (progn
    (define-key package-menu-mode-map "/m" 'package-menu--filter-marked)
    (easy-menu-add-item
     package-menu-mode-menu
     '("Filter Packages")
     ["Filter Marked" package-menu--filter-marked :help "Filter packages marked for upgrade"])))


[-- Attachment #3: .signature --]
[-- Type: text/plain, Size: 223 bytes --]


-- 
Pieter van Oostrum <pieter@vanoostrum.org>
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]


-- 
Pieter van Oostrum <pieter@vanoostrum.org>
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-05-09 16:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04 14:53 bug#39903: 28.0.50; Feature request: another filter for Package Menu Pieter van Oostrum
2020-03-05 14:24 ` Pieter van Oostrum
2020-03-05 14:51 ` Stefan Kangas
2020-03-05 15:19   ` Pieter van Oostrum
2020-03-05 22:24     ` Pieter van Oostrum
2020-05-09 15:38       ` Stefan Kangas
2020-05-09 15:51         ` Eli Zaretskii
2020-05-09 16:22           ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).