aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2022-11-05 13:11:28 +0200
committerEli Zaretskii2022-11-05 13:11:28 +0200
commit22fb5397defc14c3dbdb48ba7f2f06cb7329be9d (patch)
tree961dd3e467b8d74f3ae73bfb6d41660cec46d6e4
parent8721e87a6ec0874057f83f54498a0e3a64475a53 (diff)
downloademacs-22fb5397defc14c3dbdb48ba7f2f06cb7329be9d.tar.gz
emacs-22fb5397defc14c3dbdb48ba7f2f06cb7329be9d.zip
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend) (package-vc-selected-packages, package-vc--archive-spec-alist) (package-vc--archive-data-alist, package-vc--query-spec) (package-vc--read-archive-data, package-vc-commit) (package-vc--main-file, package-vc--generate-description-file) (package-vc--build-documentation, package-vc--unpack-1) (package-vc--guess-backend, package-vc--clone) (package-vc--unpack, package-vc-update, package-vc--release-rev) (package-vc-install, package-vc-checkout) (package-vc-link-directory, package-vc-refresh) (package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
-rw-r--r--lisp/emacs-lisp/package-vc.el194
1 files changed, 99 insertions, 95 deletions
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index aae33096c9e..96cf7bb4666 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -109,9 +109,10 @@
109(defcustom package-vc-default-backend 'Git 109(defcustom package-vc-default-backend 'Git
110 "Default VC backend used when cloning a package repository. 110 "Default VC backend used when cloning a package repository.
111If no repository type was specified or could be guessed by 111If no repository type was specified or could be guessed by
112`package-vc-heuristic-alist', the VC backend denoted by this 112`package-vc-heuristic-alist', this is the default VC backend
113symbol is used. The value must be a member of 113used as fallback. The value must be a member of
114`vc-handled-backends' that implements the `clone' function." 114`vc-handled-backends' and the named backend must implement
115the `clone' function."
115 :type `(choice ,@(mapcar (lambda (b) (list 'const b)) 116 :type `(choice ,@(mapcar (lambda (b) (list 'const b))
116 vc-handled-backends)) 117 vc-handled-backends))
117 :version "29.1") 118 :version "29.1")
@@ -135,13 +136,12 @@ symbol is used. The value must be a member of
135 136
136;;;###autoload 137;;;###autoload
137(defcustom package-vc-selected-packages '() 138(defcustom package-vc-selected-packages '()
138 "List of packages to ensure being installed. 139 "List of packages that must be installed.
139Each entry of the list is of the form (NAME . SPEC), where NAME 140Each member of the list is of the form (NAME . SPEC), where NAME
140is a symbol designating the package and SPEC is one of: 141is a symbol designating the package and SPEC is one of:
141 142
142- the value nil, if any package version is to be installed, 143- nil, if any package version can be installed;
143- a string, if a specific revision, as designating by the string 144- a version string, if that specific revision is to be installed;
144 is to be installed,
145- a property list of the form described in 145- a property list of the form described in
146 `package-vc-archive-spec-alist', giving a package 146 `package-vc-archive-spec-alist', giving a package
147 specification. 147 specification.
@@ -149,7 +149,7 @@ is a symbol designating the package and SPEC is one of:
149This user option differs from `package-selected-packages' in that 149This user option differs from `package-selected-packages' in that
150it is meant to be specified manually. You can also use the 150it is meant to be specified manually. You can also use the
151function `package-vc-selected-packages' to apply the changes." 151function `package-vc-selected-packages' to apply the changes."
152 :type '(alist :tag "List of ensured packages" 152 :type '(alist :tag "List of packages you want to be installed"
153 :key-type (symbol :tag "Package") 153 :key-type (symbol :tag "Package")
154 :value-type 154 :value-type
155 (choice (const :tag "Any revision" nil) 155 (choice (const :tag "Any revision" nil)
@@ -166,54 +166,47 @@ function `package-vc-selected-packages' to apply the changes."
166 166
167(defvar package-vc--archive-spec-alist nil 167(defvar package-vc--archive-spec-alist nil
168 "List of package specifications for each archive. 168 "List of package specifications for each archive.
169The list maps package names as string to plist. Valid keys 169The list maps each package name, as a string, to a plist.
170include 170Valid keys and the corresponding value types are:
171 171
172 `:url' (string) 172 `:url' (string)
173 The URL of the repository used to fetch the package source.
173 174
174The URL of the repository used to fetch the package source. 175 `:branch' (string)
176 If given, the name of the branch to checkout after cloning the directory.
175 177
176 `:branch' (string) 178 `:lisp-dir' (string)
179 The repository-relative name of the directory to use for loading the Lisp
180 sources. If not given, the value defaults to the root directory
181 of the repository.
177 182
178If given, the branch to check out after cloning the directory. 183 `:main-file' (string)
184 The main file of the project, relevant to gather package metadata.
185 If not given, the assumed default is the package name with \".el\"
186 appended to it.
179 187
180 `:lisp-dir' (string) 188 `:vc-backend' (symbol)
181 189 A symbol of the VC backend to use for cloning the package. The
182The repository-relative directory to use for loading the Lisp 190 value ought to be a member of `vc-handled-backends'. If omitted,
183sources. If not given, the value defaults to the root directory 191 `vc-clone' will fall back onto the archive default or on
184of the repository. 192 `package-vc-default-backend'.
185
186 `:main-file' (string)
187
188The main file of the project, relevant to gather package
189metadata. If not given, the assumed default is the package named
190with \".el\" concatenated to the end.
191
192 `:vc-backend' (symbol)
193
194A symbol indicating what the VC backend to use for cloning a
195package. The value ought to be a member of
196`vc-handled-backends'. If missing, `vc-clone' will fall back
197onto the archive default or `package-vc-default-backend'.
198 193
199All other values are ignored.") 194All other values are ignored.")
200 195
201(defvar package-vc--archive-data-alist nil 196(defvar package-vc--archive-data-alist nil
202 "List of package specification archive metadata. 197 "List of package specification metadata for archives.
203Each element of the list has the form (ARCHIVE . PLIST), where 198Each element of the list has the form (ARCHIVE . PLIST), where
204PLIST keys are one of: 199PLIST keys are one of:
205 200
206 `:version' (integer) 201 `:version' (integer)
207 202 Indicates the version of the file formatting, to be compared
208Indicating the version of the file formatting, to be compared 203 with `package-vc--elpa-packages-version'.
209with `package-vc--elpa-packages-version'.
210 204
211 `:vc-backend' (symbol) 205 `:vc-backend' (symbol)
212 206 A symbol of the default VC backend to use if a package specification
213A symbol indicating what the default VC backend to use if a 207 does not indicate a backend. The value ought to be a member of
214package specification does not indicate anything. The value 208 `vc-handled-backends'. If omitted, `vc-clone' will fall back on
215ought to be a member of `vc-handled-backends'. If missing, 209 `package-vc-default-backend'.
216`vc-clone' will fall back onto `package-vc-default-backend'.
217 210
218All other values are ignored.") 211All other values are ignored.")
219 212
@@ -230,16 +223,15 @@ name for PKG-DESC."
230 nil nil #'string=)) 223 nil nil #'string=))
231 224
232(define-inline package-vc--query-spec (pkg-desc prop) 225(define-inline package-vc--query-spec (pkg-desc prop)
233 "Query the property PROP for the package specification for PKG-DESC. 226 "Query the property PROP for the package specification of PKG-DESC.
234If no package specification can be determined, the function will 227If no package specification can be determined, the function will
235return nil." 228return nil."
236 (inline-letevals (pkg-desc prop) 229 (inline-letevals (pkg-desc prop)
237 (inline-quote (plist-get (package-vc--desc->spec ,pkg-desc) ,prop)))) 230 (inline-quote (plist-get (package-vc--desc->spec ,pkg-desc) ,prop))))
238 231
239(defun package-vc--read-archive-data (archive) 232(defun package-vc--read-archive-data (archive)
240 "Update `package-vc--archive-spec-alist' with the contents of ARCHIVE. 233 "Update `package-vc--archive-spec-alist' for ARCHIVE.
241This function is meant to be used as a hook for 234This function is meant to be used as a hook for `package--read-archive-hook'."
242`package--read-archive-hook'."
243 (let ((contents-file (expand-file-name 235 (let ((contents-file (expand-file-name
244 (format "archives/%s/elpa-packages.eld" archive) 236 (format "archives/%s/elpa-packages.eld" archive)
245 package-user-dir))) 237 package-user-dir)))
@@ -279,10 +271,10 @@ asynchronously."
279(add-hook 'package-refresh-contents-hook #'package-vc--download-and-read-archives 20) 271(add-hook 'package-refresh-contents-hook #'package-vc--download-and-read-archives 20)
280 272
281(defun package-vc-commit (pkg) 273(defun package-vc-commit (pkg)
282 "Extract the commit of a development package PKG." 274 "Return the last commit of a development package PKG."
283 (cl-assert (package-vc-p pkg)) 275 (cl-assert (package-vc-p pkg))
284 ;; FIXME: vc should be extended to allow querying the commit of a 276 ;; FIXME: vc should be extended to allow querying the commit of a
285 ;; directory (as is possible when dealing with git repositores). 277 ;; directory (as is possible when dealing with git repositories).
286 ;; This should be a fallback option. 278 ;; This should be a fallback option.
287 (cl-loop with dir = (package-desc-dir pkg) 279 (cl-loop with dir = (package-desc-dir pkg)
288 for file in (directory-files dir t "\\.el\\'" t) 280 for file in (directory-files dir t "\\.el\\'" t)
@@ -301,7 +293,7 @@ asynchronously."
301 "0")) 293 "0"))
302 294
303(defun package-vc--main-file (pkg-desc) 295(defun package-vc--main-file (pkg-desc)
304 "Return the main file for PKG-DESC." 296 "Return the name of the main file for PKG-DESC."
305 (cl-assert (package-vc-p pkg-desc)) 297 (cl-assert (package-vc-p pkg-desc))
306 (let ((pkg-spec (package-vc--desc->spec pkg-desc))) 298 (let ((pkg-spec (package-vc--desc->spec pkg-desc)))
307 (or (plist-get pkg-spec :main-file) 299 (or (plist-get pkg-spec :main-file)
@@ -315,8 +307,7 @@ asynchronously."
315 (plist-get pkg-spec :lisp-dir)))))) 307 (plist-get pkg-spec :lisp-dir))))))
316 308
317(defun package-vc--generate-description-file (pkg-desc pkg-file) 309(defun package-vc--generate-description-file (pkg-desc pkg-file)
318 "Generate a package description file for PKG-DESC. 310 "Generate a package description file for PKG-DESC and write it to PKG-FILE."
319The output is written out into PKG-FILE."
320 (let ((name (package-desc-name pkg-desc))) 311 (let ((name (package-desc-name pkg-desc)))
321 ;; Infer the subject if missing. 312 ;; Infer the subject if missing.
322 (unless (package-desc-summary pkg-desc) 313 (unless (package-desc-summary pkg-desc)
@@ -360,7 +351,9 @@ The output is written out into PKG-FILE."
360(declare-function org-export-to-file "ox" (backend file)) 351(declare-function org-export-to-file "ox" (backend file))
361 352
362(defun package-vc--build-documentation (pkg-desc file) 353(defun package-vc--build-documentation (pkg-desc file)
363 "Build documentation FILE for PKG-DESC." 354 "Build documentation FILE for PKG-DESC.
355FILE can be an Org file, indicated by its \".org\" extension,
356otherwise it's assumed to be an Info file."
364 (let ((pkg-dir (package-desc-dir pkg-desc))) 357 (let ((pkg-dir (package-desc-dir pkg-desc)))
365 (when (string-match-p "\\.org\\'" file) 358 (when (string-match-p "\\.org\\'" file)
366 (require 'ox) 359 (require 'ox)
@@ -373,7 +366,7 @@ The output is written out into PKG-FILE."
373 file pkg-dir))) 366 file pkg-dir)))
374 367
375(defun package-vc--unpack-1 (pkg-desc pkg-dir) 368(defun package-vc--unpack-1 (pkg-desc pkg-dir)
376 "Install PKG-DESC that is already located in PKG-DIR." 369 "Install PKG-DESC that is already checked-out in PKG-DIR."
377 ;; In case the package was installed directly from source, the 370 ;; In case the package was installed directly from source, the
378 ;; dependency list wasn't know beforehand, and they might have 371 ;; dependency list wasn't know beforehand, and they might have
379 ;; to be installed explicitly. 372 ;; to be installed explicitly.
@@ -443,14 +436,14 @@ The output is written out into PKG-FILE."
443(defun package-vc--guess-backend (url) 436(defun package-vc--guess-backend (url)
444 "Guess the VC backend for URL. 437 "Guess the VC backend for URL.
445This function will internally query `package-vc-heuristic-alist' 438This function will internally query `package-vc-heuristic-alist'
446and return nil if no reasonable guess can be made." 439and return nil if it cannot reasonably guess."
447 (and url (alist-get url package-vc-heuristic-alist 440 (and url (alist-get url package-vc-heuristic-alist
448 nil nil #'string-match-p))) 441 nil nil #'string-match-p)))
449 442
450(defun package-vc--clone (pkg-desc pkg-spec dir rev) 443(defun package-vc--clone (pkg-desc pkg-spec dir rev)
451 "Clone the source of a package into a directory DIR. 444 "Clone the package PKG-DESC whose spec is PKG-SPEC into the directory DIR.
452The package is described by a package descriptions PKG-DESC and a 445REV specifies a specific revision to checkout. This overrides the `:branch'
453package specification PKG-SPEC." 446attribute in PKG-SPEC."
454 (pcase-let* ((name (package-desc-name pkg-desc)) 447 (pcase-let* ((name (package-desc-name pkg-desc))
455 ((map :url :branch) pkg-spec)) 448 ((map :url :branch) pkg-spec))
456 449
@@ -477,11 +470,10 @@ package specification PKG-SPEC."
477 470
478(defun package-vc--unpack (pkg-desc pkg-spec &optional rev) 471(defun package-vc--unpack (pkg-desc pkg-spec &optional rev)
479 "Install the package described by PKG-DESC. 472 "Install the package described by PKG-DESC.
480PKG-SPEC is a package specification is a property list describing 473PKG-SPEC is a package specification, a property list describing
481how to fetch and build the package PKG-DESC. See 474how to fetch and build the package. See `package-vc--archive-spec-alist'
482`package-vc--archive-spec-alist' for details. The optional argument 475for details. The optional argument REV specifies a specific revision to
483REV specifies a specific revision to checkout. This overrides 476checkout. This overrides the `:branch' attribute in PKG-SPEC."
484the `:brach' attribute in PKG-SPEC."
485 (pcase-let* (((map :url :lisp-dir) pkg-spec) 477 (pcase-let* (((map :url :lisp-dir) pkg-spec)
486 (name (package-desc-name pkg-desc)) 478 (name (package-desc-name pkg-desc))
487 (dirname (package-desc-full-name pkg-desc)) 479 (dirname (package-desc-full-name pkg-desc))
@@ -523,7 +515,7 @@ the `:brach' attribute in PKG-SPEC."
523 package-archive-contents)) 515 package-archive-contents))
524 516
525(defun package-vc-update (pkg-desc) 517(defun package-vc-update (pkg-desc)
526 "Attempt to update the packager PKG-DESC." 518 "Attempt to update the package PKG-DESC."
527 ;; HACK: To run `package-vc--unpack-1' after checking out the new 519 ;; HACK: To run `package-vc--unpack-1' after checking out the new
528 ;; revision, we insert a hook into `vc-post-command-functions', and 520 ;; revision, we insert a hook into `vc-post-command-functions', and
529 ;; remove it right after it ran. To avoid running the hook multiple 521 ;; remove it right after it ran. To avoid running the hook multiple
@@ -558,13 +550,13 @@ the `:brach' attribute in PKG-SPEC."
558 (vc-pull)))) 550 (vc-pull))))
559 551
560(defun package-vc--archives-initialize () 552(defun package-vc--archives-initialize ()
561 "Initialise package.el and fetch package specifications." 553 "Initialize package.el and fetch package specifications."
562 (package--archives-initialize) 554 (package--archives-initialize)
563 (unless package-vc--archive-data-alist 555 (unless package-vc--archive-data-alist
564 (package-vc--download-and-read-archives))) 556 (package-vc--download-and-read-archives)))
565 557
566(defun package-vc--release-rev (pkg-desc) 558(defun package-vc--release-rev (pkg-desc)
567 "Find the latest revision that bumps the \"Version\" tag for PKG-DESC. 559 "Return the latest revision that bumps the \"Version\" tag for PKG-DESC.
568If no such revision can be found, return nil." 560If no such revision can be found, return nil."
569 (with-current-buffer (find-file-noselect (package-vc--main-file pkg-desc)) 561 (with-current-buffer (find-file-noselect (package-vc--main-file pkg-desc))
570 (vc-buffer-sync) 562 (vc-buffer-sync)
@@ -586,20 +578,23 @@ If no such revision can be found, return nil."
586 578
587;;;###autoload 579;;;###autoload
588(defun package-vc-install (name-or-url &optional name rev backend) 580(defun package-vc-install (name-or-url &optional name rev backend)
589 "Fetch the source of NAME-OR-URL. 581 "Fetch a package NAME-OR-URL and set it up for using with Emacs.
590If NAME-OR-URL is a URL, then the package will be downloaded from 582If NAME-OR-URL is a URL, download the package from the repository
591the repository indicated by the URL. The function will try to 583at that URL; the function will try to guess the name of the package
592guess the name of the package using `file-name-base'. This can 584from the URL. Otherwise NAME-OR-URL should be a symbol whose name
593be overridden by manually passing the optional NAME. Otherwise 585is the package name, and the URL for the package will be taken from
594NAME-OR-URL is taken to be a package name, and the package 586the package's metadata.
595metadata will be consulted for the URL. An explicit revision can 587By default, this function installs the last version of the package
596be requested using REV. If the command is invoked with a prefix 588available from its repository, but if REV is given and non-nil, it
597argument, the revision used for the last release in the package 589specifies the revision to install. If REV has the special value
598archive is used. This can also be reproduced by passing the 590`:last-release' (interactively, the prefix argument), that stands
599special value `:last-release' as REV. If a NAME-OR-URL is a URL, 591for the last released version of the package.
600that is to say a string, the VC backend used to clone the 592When calling from Lisp, optional argument NAME overrides the package
601repository can be set by BACKEND. If missing, 593name as deduced from NAME-OR-URL.
602`package-vc--guess-backend' will be used." 594Optional argument BACKEND specifies the VC backend to use for cloning
595the package's repository; this is only possible if NAME-OR-URL is a URL,
596a string. If BACKEND is omitted or nil, the function
597uses `package-vc--guess-backend' to guess the backend."
603 (interactive 598 (interactive
604 (progn 599 (progn
605 ;; Initialize the package system to get the list of package 600 ;; Initialize the package system to get the list of package
@@ -637,12 +632,15 @@ repository can be set by BACKEND. If missing,
637 632
638;;;###autoload 633;;;###autoload
639(defun package-vc-checkout (pkg-desc directory &optional rev) 634(defun package-vc-checkout (pkg-desc directory &optional rev)
640 "Clone the sources for PKG-DESC into DIRECTORY and open it. 635 "Clone the sources for PKG-DESC into DIRECTORY and visit that directory.
641An explicit revision can be requested by passing a string to the 636Unlike `package-vc-install', this does not yet set up the package
642optional argument REV. If the command is invoked with a prefix 637for use with Emacs; use `package-vc-link-directory' for setting
643argument, the revision used for the last release in the package 638the package up after this function finishes.
644archive is used. This can also be reproduced by passing the 639Optional argument REV means to clone a specific version of the
645special value `:last-release' as REV." 640package; it defaults to the last version available from the
641package's repository. If REV has the special value
642`:last-release' (interactively, the prefix argument), that stands
643for the last released version of the package."
646 (interactive 644 (interactive
647 (progn 645 (progn
648 ;; Initialize the package system to get the list of package 646 ;; Initialize the package system to get the list of package
@@ -668,10 +666,12 @@ special value `:last-release' as REV."
668 666
669;;;###autoload 667;;;###autoload
670(defun package-vc-link-directory (dir name) 668(defun package-vc-link-directory (dir name)
671 "Install the package NAME in DIR by linking it into the ELPA directory. 669 "Set up the package NAME in DIR by linking it into the ELPA directory.
672If invoked interactively with a prefix argument, the user will be 670Interactively, prompt the user for DIR, which should be a directory
673prompted for the package NAME. Otherwise it will be inferred 671under version control, typically one created by `package-vc-checkout'.
674from the base name of DIR." 672If invoked interactively with a prefix argument, prompt the user
673for the NAME of the package to set up. Otherwise infer the package
674name from the base name of DIR."
675 (interactive (let ((dir (read-directory-name "Directory: "))) 675 (interactive (let ((dir (read-directory-name "Directory: ")))
676 (list dir 676 (list dir
677 (if current-prefix-arg 677 (if current-prefix-arg
@@ -690,7 +690,8 @@ from the base name of DIR."
690 690
691;;;###autoload 691;;;###autoload
692(defun package-vc-refresh (pkg-desc) 692(defun package-vc-refresh (pkg-desc)
693 "Refresh the installation for PKG-DESC." 693 "Refresh the installation for package given by PKG-DESC.
694Interactively, prompt for the name of the package to refresh."
694 (interactive (package-vc--read-pkg "Refresh package: ")) 695 (interactive (package-vc--read-pkg "Refresh package: "))
695 (package-vc--unpack-1 pkg-desc (package-desc-dir pkg-desc))) 696 (package-vc--unpack-1 pkg-desc (package-desc-dir pkg-desc)))
696 697
@@ -706,9 +707,12 @@ from the base name of DIR."
706 707
707;;;###autoload 708;;;###autoload
708(defun package-vc-prepare-patch (pkg subject revisions) 709(defun package-vc-prepare-patch (pkg subject revisions)
709 "Send a patch to the maintainer of a package PKG. 710 "Send patch for REVISIONS to maintainer of the package PKG using SUBJECT.
710SUBJECT and REVISIONS are used passed on to `vc-prepare-patch'. 711SUBJECT and REVISIONS are passed on to `vc-prepare-patch', which see.
711PKG must be a package description." 712PKG must be a package description.
713Interactively, prompt for PKG, SUBJECT, and REVISIONS. However,
714if the current buffer has marked commit log entries, REVISIONS
715are the tags of the marked entries, see `log-view-get-marked'."
712 (interactive 716 (interactive
713 (list (package-vc--read-pkg "Package to prepare a patch for: ") 717 (list (package-vc--read-pkg "Package to prepare a patch for: ")
714 (and (not vc-prepare-patches-separately) 718 (and (not vc-prepare-patches-separately)