* bug#55470: [PATCH] Add package-delete-regexp
@ 2022-05-16 23:25 Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-17 17:48 ` Lars Ingebrigtsen
2022-05-18 23:17 ` Philip Kaludercic
0 siblings, 2 replies; 8+ messages in thread
From: Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-05-16 23:25 UTC (permalink / raw)
To: 55470
[-- Attachment #1: Type: text/plain, Size: 346 bytes --]
This function allows you to delete packages, with names that match the
regexp. This is makes operations like deleting multiple packages that
begin with the same namespace (^company.*, ^treemacs.*, etc.) much
easier to do
The function will also tell you how much packages it will delete (in a
temporary buffer) and prompt for a Yes or No answer
[-- Attachment #2: package.diff --]
[-- Type: text/plain, Size: 1498 bytes --]
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index f356a2bf60..a166b0ef47 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2400,6 +2400,33 @@ If NOSAVE is non-nil, the package is not removed from
(message "Package `%s' deleted."
(package-desc-full-name pkg-desc))))))
+(defun package-delete-regexp (pkg-regexp &optional force nosave)
+ "Delete packages matching the regexp PKG-REGEXP
+This will use `package-delete' to delete packages"
+ (interactive
+ (let ((pkg-regexp (read-string "Delete packages (regexp): ")))
+ (list pkg-regexp)))
+
+ ;;; Search through every package name and match it with the user's regexp
+ ;;; and filter out the nil's
+ (let ((pkg-list (remq nil
+ (mapcar
+ (lambda (elem)
+ (if (string-match pkg-regexp (package-desc-full-name (nth 1 elem)))
+ (nth 1 elem)))
+ (package--alist)))))
+ (if (length> pkg-list 0)
+ (with-output-to-temp-buffer "Package Deletion"
+ (pop-to-buffer "Package Deletion")
+ (princ "This operation will delete these following packages: \n")
+ (dolist (elem pkg-list)
+ (princ (format "%s\n" (package-desc-full-name elem))))
+ (if (y-or-n-p "Delete? ")
+ (dolist (elem pkg-list)
+ (package-delete elem force nosave)))
+ (kill-current-buffer))
+ (message "No packages found"))))
+
;;;###autoload
(defun package-reinstall (pkg)
"Reinstall package PKG.
^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#55470: [PATCH] Add package-delete-regexp
2022-05-16 23:25 bug#55470: [PATCH] Add package-delete-regexp Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-05-17 17:48 ` Lars Ingebrigtsen
2022-07-11 13:20 ` Lars Ingebrigtsen
2022-05-18 23:17 ` Philip Kaludercic
1 sibling, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-17 17:48 UTC (permalink / raw)
To: Marwan L.; +Cc: 55470
"Marwan L." <techmetx11@disroot.org> writes:
> This function allows you to delete packages, with names that match the
> regexp. This is makes operations like deleting multiple packages that
> begin with the same namespace (^company.*, ^treemacs.*, etc.) much
> easier to do
>
> The function will also tell you how much packages it will delete (in a
> temporary buffer) and prompt for a Yes or No answer
Thanks; makes sense to me. The patch is longer than the limit for
"trivial" changes, so we'd need for the copyright to be assigned to the
FSF before accepting it. Would you be willing to sign such paperwork?
If so, below is the form to get started:
Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.
Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
[What is the name of the program or package you're contributing to?]
Emacs
[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]
[Do you have an employer who might have a basis to claim to own
your changes? Do you attend a school which might make such a claim?]
[For the copyright registration, what country are you a citizen of?]
[What year were you born?]
[Please write your email address here.]
[Please write your postal address here.]
[Which files have you changed so far, and which new files have you written
so far?]
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#55470: [PATCH] Add package-delete-regexp
2022-05-17 17:48 ` Lars Ingebrigtsen
@ 2022-07-11 13:20 ` Lars Ingebrigtsen
2022-08-09 15:48 ` Lars Ingebrigtsen
0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-11 13:20 UTC (permalink / raw)
To: Marwan L.; +Cc: 55470
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Thanks; makes sense to me. The patch is longer than the limit for
> "trivial" changes, so we'd need for the copyright to be assigned to the
> FSF before accepting it. Would you be willing to sign such paperwork?
This was a month ago, but I don't think I got a response on this?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#55470: [PATCH] Add package-delete-regexp
2022-07-11 13:20 ` Lars Ingebrigtsen
@ 2022-08-09 15:48 ` Lars Ingebrigtsen
0 siblings, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-09 15:48 UTC (permalink / raw)
To: Marwan L.; +Cc: 55470
Lars Ingebrigtsen <larsi@gnus.org> writes:
>> Thanks; makes sense to me. The patch is longer than the limit for
>> "trivial" changes, so we'd need for the copyright to be assigned to the
>> FSF before accepting it. Would you be willing to sign such paperwork?
>
> This was a month ago, but I don't think I got a response on this?
And there was no response to this in a month, so it doesn't sound like
we'll be making any progress here, and I'm therefore closing this bug
report.
If progress can be made, please respond to the debbugs address and we'll
reopen.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#55470: [PATCH] Add package-delete-regexp
2022-05-16 23:25 bug#55470: [PATCH] Add package-delete-regexp Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-17 17:48 ` Lars Ingebrigtsen
@ 2022-05-18 23:17 ` Philip Kaludercic
2022-05-19 12:04 ` Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 1 reply; 8+ messages in thread
From: Philip Kaludercic @ 2022-05-18 23:17 UTC (permalink / raw)
To: Marwan L.; +Cc: 55470
"Marwan L." <techmetx11@disroot.org> writes:
> This function allows you to delete packages, with names that match the
> regexp. This is makes operations like deleting multiple packages that
> begin with the same namespace (^company.*, ^treemacs.*, etc.) much
> easier to do
What is the advantage of a separate function for deleting packages
compared to marking packages in the *Packages* buffer using "/ n" (that
also accepts a regular expression)?
> The function will also tell you how much packages it will delete (in a
> temporary buffer) and prompt for a Yes or No answer
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#55470: [PATCH] Add package-delete-regexp
2022-05-18 23:17 ` Philip Kaludercic
@ 2022-05-19 12:04 ` Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-19 14:26 ` Philip Kaludercic
0 siblings, 1 reply; 8+ messages in thread
From: Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-05-19 12:04 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: 55470
On Wed, May 18, 2022 at 11:17:26PM +0000, Philip Kaludercic wrote:
> "Marwan L." <techmetx11@disroot.org> writes:
>
> > This function allows you to delete packages, with names that match the
> > regexp. This is makes operations like deleting multiple packages that
> > begin with the same namespace (^company.*, ^treemacs.*, etc.) much
> > easier to do
>
> What is the advantage of a separate function for deleting packages
> compared to marking packages in the *Packages* buffer using "/ n" (that
> also accepts a regular expression)?
It depends on how much packages you have to go through. If you have tons
of packages to mark deletion on, then it will most likely involve
holding d (wish you could do C-u 100 d) and then doing x
`M-x list-packages` will also automatically fetch the latest list of
packages from your package archives, which is unnecessary
There's a prefix argument that disables fetching, but I didn't know that
before making this function nor this patch
You are free to close this patch if you want to
>
> > The function will also tell you how much packages it will delete (in a
> > temporary buffer) and prompt for a Yes or No answer
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#55470: [PATCH] Add package-delete-regexp
2022-05-19 12:04 ` Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-05-19 14:26 ` Philip Kaludercic
2022-05-19 18:15 ` Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 8+ messages in thread
From: Philip Kaludercic @ 2022-05-19 14:26 UTC (permalink / raw)
To: Marwan L.; +Cc: 55470
"Marwan L." <techmetx11@disroot.org> writes:
> On Wed, May 18, 2022 at 11:17:26PM +0000, Philip Kaludercic wrote:
>> "Marwan L." <techmetx11@disroot.org> writes:
>>
>> > This function allows you to delete packages, with names that match the
>> > regexp. This is makes operations like deleting multiple packages that
>> > begin with the same namespace (^company.*, ^treemacs.*, etc.) much
>> > easier to do
>>
>> What is the advantage of a separate function for deleting packages
>> compared to marking packages in the *Packages* buffer using "/ n" (that
>> also accepts a regular expression)?
>
> It depends on how much packages you have to go through. If you have tons
> of packages to mark deletion on, then it will most likely involve
> holding d (wish you could do C-u 100 d) and then doing x
Apparently the prefix argument does not work, though you can do the same
with a macro. Maybe adding a "t" to toggle the selection, though this
would be a very specific use-case.
What do you think about extending the package-menu-filter commands with
a way to mark all packages instead of filtering?
> `M-x list-packages` will also automatically fetch the latest list of
> packages from your package archives, which is unnecessary
>
> There's a prefix argument that disables fetching, but I didn't know that
> before making this function nor this patch
There is also M-x package-list-packages-no-fetch.
> You are free to close this patch if you want to
No, that is not my intention, I just wanted to clarify a point.
>>
>> > The function will also tell you how much packages it will delete (in a
>> > temporary buffer) and prompt for a Yes or No answer
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#55470: [PATCH] Add package-delete-regexp
2022-05-19 14:26 ` Philip Kaludercic
@ 2022-05-19 18:15 ` Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 8+ messages in thread
From: Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-05-19 18:15 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: 55470
On Thu, May 19, 2022 at 02:26:17PM +0000, Philip Kaludercic wrote:
> "Marwan L." <techmetx11@disroot.org> writes:
>
> > On Wed, May 18, 2022 at 11:17:26PM +0000, Philip Kaludercic wrote:
> >> "Marwan L." <techmetx11@disroot.org> writes:
> >>
> >> > This function allows you to delete packages, with names that match the
> >> > regexp. This is makes operations like deleting multiple packages that
> >> > begin with the same namespace (^company.*, ^treemacs.*, etc.) much
> >> > easier to do
> >>
> >> What is the advantage of a separate function for deleting packages
> >> compared to marking packages in the *Packages* buffer using "/ n" (that
> >> also accepts a regular expression)?
> >
> > It depends on how much packages you have to go through. If you have tons
> > of packages to mark deletion on, then it will most likely involve
> > holding d (wish you could do C-u 100 d) and then doing x
>
> Apparently the prefix argument does not work, though you can do the same
> with a macro. Maybe adding a "t" to toggle the selection, though this
> would be a very specific use-case.
>
> What do you think about extending the package-menu-filter commands with
> a way to mark all packages instead of filtering?
Good idea. I haven't thought of that, Maybe I should have done that
instead of writing another function
>
> > `M-x list-packages` will also automatically fetch the latest list of
> > packages from your package archives, which is unnecessary
> >
> > There's a prefix argument that disables fetching, but I didn't know that
> > before making this function nor this patch
>
> There is also M-x package-list-packages-no-fetch.
Slightly longer name, but still okay
>
> > You are free to close this patch if you want to
>
> No, that is not my intention, I just wanted to clarify a point.
Oh, sorry.
>
> >>
> >> > The function will also tell you how much packages it will delete (in a
> >> > temporary buffer) and prompt for a Yes or No answer
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-08-09 15:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-16 23:25 bug#55470: [PATCH] Add package-delete-regexp Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-17 17:48 ` Lars Ingebrigtsen
2022-07-11 13:20 ` Lars Ingebrigtsen
2022-08-09 15:48 ` Lars Ingebrigtsen
2022-05-18 23:17 ` Philip Kaludercic
2022-05-19 12:04 ` Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-19 14:26 ` Philip Kaludercic
2022-05-19 18:15 ` Marwan L. via Bug reports for GNU Emacs, the Swiss army knife of text editors
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).