From fca7e120d2bec5045aa42acbe2e027609dfe0a8d Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Tue, 14 Mar 2023 11:50:31 +0100 Subject: [PATCH] Add option to register packages as projects * lisp/emacs-lisp/package-vc.el (package-vc-register-as-project): Add new option. (project-remember-projects-under): Declare function for usage in 'package-vc--clone'. (package-vc--clone): Respect 'package-vc-register-as-project'. * etc/NEWS: Document the feature. --- etc/NEWS | 8 ++++++++ lisp/emacs-lisp/package-vc.el | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 6c558553c58..9e45b1d80b2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -245,6 +245,14 @@ following to your init file: (add-hook 'help-fns-describe-function-functions #'shortdoc-help-fns-examples-function) +** Package + +--- +*** New user option 'package-vc-register-as-project'. +When non-nil, it will automatically register every package as a +project, that you can quickly select using 'project-switch-project' +('C-x p p'). + * New Modes and Packages in Emacs 30.1 diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index 253b35f1f1a..ba3a75851ca 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -115,6 +115,11 @@ the `clone' function." vc-handled-backends)) :version "29.1") +(defcustom package-vc-register-as-project t + "Non-nil means that packages should be registered as projects." + :type 'boolean + :version "30.1") + (defvar package-vc-selected-packages) ; pacify byte-compiler ;;;###autoload @@ -559,6 +564,8 @@ and return nil if it cannot reasonably guess." (and url (alist-get url package-vc-heuristic-alist nil nil #'string-match-p))) +(declare-function project-remember-projects-under "project" (dir &optional recursive)) + (defun package-vc--clone (pkg-desc pkg-spec dir rev) "Clone the package PKG-DESC whose spec is PKG-SPEC into the directory DIR. REV specifies a specific revision to checkout. This overrides the `:branch' @@ -580,6 +587,11 @@ attribute in PKG-SPEC." (or (and (not (eq rev :last-release)) rev) branch)) (error "Failed to clone %s from %s" name url)))) + (when package-vc-register-as-project + (let ((default-directory dir)) + (require 'project) + (project-remember-projects-under dir))) + ;; Check out the latest release if requested (when (eq rev :last-release) (if-let ((release-rev (package-vc--release-rev pkg-desc))) -- 2.39.2