aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2025-03-02 04:12:57 +0100
committerStefan Kangas2025-03-02 04:19:35 +0100
commit735eace97b88c7e1a7864a0eb5caf2a6d263b60a (patch)
tree85cff8d06ba5f36af5d48019269fe1b0235f3ccc
parent38782e684bf5f67e2d8f69daeeb17f37cf4b2c3f (diff)
downloademacs-735eace97b88c7e1a7864a0eb5caf2a6d263b60a.tar.gz
emacs-735eace97b88c7e1a7864a0eb5caf2a6d263b60a.zip
Make package-install accept a string as well
* lisp/emacs-lisp/package.el (package-install): Allow passing a string instead of a symbol. (Bug#72160) (package-upgrade): Improve docstring. * test/lisp/emacs-lisp/package-tests.el (package-test-install-single-from-archive/string-type): New test.
-rw-r--r--lisp/emacs-lisp/package.el9
-rw-r--r--test/lisp/emacs-lisp/package-tests.el7
2 files changed, 14 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 78bd846c951..cfe57fb9e35 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2196,7 +2196,8 @@ built-in package with a (possibly newer) version from a package archive."
2196;;;###autoload 2196;;;###autoload
2197(defun package-install (pkg &optional dont-select) 2197(defun package-install (pkg &optional dont-select)
2198 "Install the package PKG. 2198 "Install the package PKG.
2199PKG can be a `package-desc' or a symbol naming one of the 2199
2200PKG can be a `package-desc', or a symbol or string naming one of the
2200available packages in an archive in `package-archives'. 2201available packages in an archive in `package-archives'.
2201 2202
2202Mark the installed package as selected by adding it to 2203Mark the installed package as selected by adding it to
@@ -2229,6 +2230,8 @@ had been enabled."
2229 package-archive-contents) 2230 package-archive-contents)
2230 nil t)) 2231 nil t))
2231 nil))) 2232 nil)))
2233 (cl-check-type pkg (or string symbol package-desc))
2234 (if (stringp pkg) (setq pkg (intern pkg)))
2232 (package--archives-initialize) 2235 (package--archives-initialize)
2233 (add-hook 'post-command-hook #'package-menu--post-refresh) 2236 (add-hook 'post-command-hook #'package-menu--post-refresh)
2234 (let ((name (if (package-desc-p pkg) 2237 (let ((name (if (package-desc-p pkg)
@@ -2256,7 +2259,9 @@ had been enabled."
2256 2259
2257;;;###autoload 2260;;;###autoload
2258(defun package-upgrade (name) 2261(defun package-upgrade (name)
2259 "Upgrade package NAME if a newer version exists." 2262 "Upgrade package NAME if a newer version exists.
2263
2264NAME can be either a symbol or a string."
2260 (interactive 2265 (interactive
2261 (list (completing-read 2266 (list (completing-read
2262 "Upgrade package: " (package--upgradeable-packages t) nil t))) 2267 "Upgrade package: " (package--upgradeable-packages t) nil t)))
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index d8e260319bd..ed778049dcb 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -450,6 +450,13 @@ but with a different end of line convention (bug#48137)."
450 (package-refresh-contents) 450 (package-refresh-contents)
451 (package-install 'simple-single))) 451 (package-install 'simple-single)))
452 452
453(ert-deftest package-test-install-single-from-archive/string-type ()
454 "Install a single package from a package archive, using string argument."
455 (with-package-test ()
456 (package-initialize)
457 (package-refresh-contents)
458 (package-install "simple-single")))
459
453(ert-deftest package-test-install-prioritized () 460(ert-deftest package-test-install-prioritized ()
454 "Install a lower version from a higher-prioritized archive." 461 "Install a lower version from a higher-prioritized archive."
455 (with-package-test () 462 (with-package-test ()