unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Pieter van Oostrum <pieter@vanoostrum.org>
To: 39903@debbugs.gnu.org
Subject: bug#39903: 28.0.50; Feature request: another filter for Package Menu
Date: Wed, 4 Mar 2020 15:53:46 +0100	[thread overview]
Message-ID: <24159.49402.837723.45546@cochabamba.vanoostrum.org> (raw)

[-- 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]

             reply	other threads:[~2020-03-04 14:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-04 14:53 Pieter van Oostrum [this message]
2020-03-05 14:24 ` bug#39903: 28.0.50; Feature request: another filter for Package Menu 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24159.49402.837723.45546@cochabamba.vanoostrum.org \
    --to=pieter@vanoostrum.org \
    --cc=39903@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).