diff options
| author | Philip Kaludercic | 2023-03-14 11:50:31 +0100 |
|---|---|---|
| committer | Philip Kaludercic | 2023-03-27 00:05:59 +0200 |
| commit | fca7e120d2bec5045aa42acbe2e027609dfe0a8d (patch) | |
| tree | 88036052a9b2fd161cb1458859a482ec04b2675e | |
| parent | 082870c0d7870ff5fd13d4c95f248b29f55cc393 (diff) | |
| download | emacs-fca7e120d2bec5045aa42acbe2e027609dfe0a8d.tar.gz emacs-fca7e120d2bec5045aa42acbe2e027609dfe0a8d.zip | |
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.
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package-vc.el | 12 |
2 files changed, 20 insertions, 0 deletions
| @@ -245,6 +245,14 @@ following to your init file: | |||
| 245 | (add-hook 'help-fns-describe-function-functions | 245 | (add-hook 'help-fns-describe-function-functions |
| 246 | #'shortdoc-help-fns-examples-function) | 246 | #'shortdoc-help-fns-examples-function) |
| 247 | 247 | ||
| 248 | ** Package | ||
| 249 | |||
| 250 | --- | ||
| 251 | *** New user option 'package-vc-register-as-project'. | ||
| 252 | When non-nil, it will automatically register every package as a | ||
| 253 | project, that you can quickly select using 'project-switch-project' | ||
| 254 | ('C-x p p'). | ||
| 255 | |||
| 248 | 256 | ||
| 249 | * New Modes and Packages in Emacs 30.1 | 257 | * New Modes and Packages in Emacs 30.1 |
| 250 | 258 | ||
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." | |||
| 115 | vc-handled-backends)) | 115 | vc-handled-backends)) |
| 116 | :version "29.1") | 116 | :version "29.1") |
| 117 | 117 | ||
| 118 | (defcustom package-vc-register-as-project t | ||
| 119 | "Non-nil means that packages should be registered as projects." | ||
| 120 | :type 'boolean | ||
| 121 | :version "30.1") | ||
| 122 | |||
| 118 | (defvar package-vc-selected-packages) ; pacify byte-compiler | 123 | (defvar package-vc-selected-packages) ; pacify byte-compiler |
| 119 | 124 | ||
| 120 | ;;;###autoload | 125 | ;;;###autoload |
| @@ -559,6 +564,8 @@ and return nil if it cannot reasonably guess." | |||
| 559 | (and url (alist-get url package-vc-heuristic-alist | 564 | (and url (alist-get url package-vc-heuristic-alist |
| 560 | nil nil #'string-match-p))) | 565 | nil nil #'string-match-p))) |
| 561 | 566 | ||
| 567 | (declare-function project-remember-projects-under "project" (dir &optional recursive)) | ||
| 568 | |||
| 562 | (defun package-vc--clone (pkg-desc pkg-spec dir rev) | 569 | (defun package-vc--clone (pkg-desc pkg-spec dir rev) |
| 563 | "Clone the package PKG-DESC whose spec is PKG-SPEC into the directory DIR. | 570 | "Clone the package PKG-DESC whose spec is PKG-SPEC into the directory DIR. |
| 564 | REV specifies a specific revision to checkout. This overrides the `:branch' | 571 | REV specifies a specific revision to checkout. This overrides the `:branch' |
| @@ -580,6 +587,11 @@ attribute in PKG-SPEC." | |||
| 580 | (or (and (not (eq rev :last-release)) rev) branch)) | 587 | (or (and (not (eq rev :last-release)) rev) branch)) |
| 581 | (error "Failed to clone %s from %s" name url)))) | 588 | (error "Failed to clone %s from %s" name url)))) |
| 582 | 589 | ||
| 590 | (when package-vc-register-as-project | ||
| 591 | (let ((default-directory dir)) | ||
| 592 | (require 'project) | ||
| 593 | (project-remember-projects-under dir))) | ||
| 594 | |||
| 583 | ;; Check out the latest release if requested | 595 | ;; Check out the latest release if requested |
| 584 | (when (eq rev :last-release) | 596 | (when (eq rev :last-release) |
| 585 | (if-let ((release-rev (package-vc--release-rev pkg-desc))) | 597 | (if-let ((release-rev (package-vc--release-rev pkg-desc))) |