From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Marwan L." via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#55470: [PATCH] Add package-delete-regexp Date: Tue, 17 May 2022 00:25:30 +0100 Message-ID: Reply-To: "Marwan L." Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="AbAjkDmf+m/b6ZVC" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15600"; mail-complaints-to="usenet@ciao.gmane.io" To: 55470@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 17 03:01:31 2022 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 1nqlac-0003oP-3W for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 May 2022 03:01:30 +0200 Original-Received: from localhost ([::1]:46134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqlaa-0007qm-PA for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 16 May 2022 21:01:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqlaB-0007qO-LI for bug-gnu-emacs@gnu.org; Mon, 16 May 2022 21:01:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nqlaB-0005fd-A5 for bug-gnu-emacs@gnu.org; Mon, 16 May 2022 21:01:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nqlaB-0007RU-9J for bug-gnu-emacs@gnu.org; Mon, 16 May 2022 21:01:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Marwan L." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 May 2022 01:01:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55470 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.165274923828542 (code B ref -1); Tue, 17 May 2022 01:01:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 May 2022 01:00:38 +0000 Original-Received: from localhost ([127.0.0.1]:55418 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nqlZl-0007QH-Oh for submit@debbugs.gnu.org; Mon, 16 May 2022 21:00:38 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:43062) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nqk60-0000Yh-2S for submit@debbugs.gnu.org; Mon, 16 May 2022 19:25:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqk5z-0002tG-Ts for bug-gnu-emacs@gnu.org; Mon, 16 May 2022 19:25:47 -0400 Original-Received: from knopi.disroot.org ([178.21.23.139]:34084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqk5x-0007F1-NR for bug-gnu-emacs@gnu.org; Mon, 16 May 2022 19:25:47 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 64CDC42E2B for ; Tue, 17 May 2022 01:25:43 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Original-Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FGvuEFPdzx4b for ; Tue, 17 May 2022 01:25:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1652743541; bh=ujL+2Z1SRjbpS9Tk25mH2r4u/NFZ/ynpbDwA4BN1kIM=; h=Date:From:To:Subject; b=Vx/HhxBmYQd46ySD9BBzfdMbJXaq/6mdgRTOTpDU5LgJJSoVsU9BMmxwHEMNxQRQE nJgDo1VYsAVwyjPckpcLONEvz2AlgdWV9NqA+LpIIAkPIyPBdJyby8oWOADVn9YmhR CNGGTvdVsXeTc1EPd/zd9ROlfimLAh1KUw/2OXg7QOUPnb/pyie+3QL+FIYXXKYO7h cVescvht5tkpuBgz7ekAc7GWA2/AsIMvOwy5/jY540Xrpl4LpkmgVsdHSYWgRFUvEH qf+e2mIeL48WV8Uxh8sBOsUnz9fbKK5dfucTG4DHZ1J2UkzXFxZUPGJ2Ty6C/n6KvT 4ZCQ/I7AkUEzQ== Content-Disposition: inline Received-SPF: pass client-ip=178.21.23.139; envelope-from=techmetx11@disroot.org; helo=knopi.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 16 May 2022 21:00:36 -0400 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" Xref: news.gmane.io gmane.emacs.bugs:232417 Archived-At: --AbAjkDmf+m/b6ZVC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --AbAjkDmf+m/b6ZVC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="package.diff" 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. --AbAjkDmf+m/b6ZVC--