]> git.eshelyaron.com Git - emacs.git/commitdiff
Add use-package-vc-prefer-newest user option
authorTony Zorman <soliditsallgood@mailbox.org>
Thu, 21 Dec 2023 16:51:09 +0000 (17:51 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sat, 30 Mar 2024 19:37:01 +0000 (20:37 +0100)
* lisp/use-package/use-package-core.el (use-package-vc-prefer-newest):
User option to prefer the latest commit (as opposed to the latest
release) of a package.
(use-package-normalize--vc-arg): Check for
use-package-vc-prefer-newest.

* doc/misc/use-package.texi (Install package): Document
use-package-vc-prefer-newest.

* etc/NEWS: Document use-package-vc-prefer-newest.

(cherry picked from commit 77115be256d08c6524bc0c498d1d268686814090)

doc/misc/use-package.texi
etc/NEWS
lisp/use-package/use-package-core.el

index d834e1be754a878cdcf5fd745da295531cf02fa3..c2b6404b68be451995d7d15ec8e204e5d564e6ba 100644 (file)
@@ -1639,8 +1639,12 @@ For example,
 would try -- by invoking @code{package-vc-install} -- to install the
 latest commit of the package @code{foo} from the specified remote.
 
-This can also be used for local packages, by combining it with the
-@code{:load-path} (@pxref{Load path}) keyword:
+@vindex use-package-vc-prefer-newest
+Alternatively, the @code{use-package-vc-prefer-newest} user option
+exists to always prefer the latest commit.
+
+The @code{:vc} keyword can also be used for local packages, by
+combining it with @code{:load-path} (@pxref{Load path}):
 
 @example
 @group
index 02cab87c34465daacd2124b6927f1d3faa73e4fb..811cc3a9658241910407e43b8a4bab92b002ba46 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1316,6 +1316,11 @@ interactive Python interpreter specified by 'python-interpreter'.
 *** New ':vc' keyword.
 This keyword enables the user to install packages using 'package-vc'.
 
++++
+*** New user option 'use-package-vc-prefer-newest'.
+This allows the user to always install the newest commit of a package
+when using the ':vc' keyword.
+
 ** Gnus
 
 *** The 'nnweb-type' option 'gmane' has been removed.
index d9343e14839be8e3102b25f8d694b066d6646b8a..ba2e93c97e91c82a2c7574a457cff0a256cfcb57 100644 (file)
@@ -346,6 +346,20 @@ undefined variables."
   :type 'boolean
   :group 'use-package)
 
+(defcustom use-package-vc-prefer-newest nil
+  "Prefer the newest commit over the latest release.
+By default, much like GNU ELPA and NonGNU ELPA, the `:vc' keyword
+tracks the latest stable release of a package.  If this option is
+non-nil, the latest commit is preferred instead.  This has the
+same effect as specifying `:rev :newest' in every invocation of
+`:vc'.
+
+Note that always tracking a package's latest commit might lead to
+stability issues."
+  :type 'boolean
+  :version "30.1"
+  :group 'use-package)
+
 (defvar use-package-statistics (make-hash-table))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1649,9 +1663,11 @@ indicating the latest commit) revision."
                (if (and s (stringp s)) (intern s) s))
              (normalize (k v)
                (pcase k
-                 (:rev (cond ((or (eq v :last-release) (not v)) :last-release)
-                             ((eq v :newest) nil)
-                             (t (ensure-string v))))
+                 (:rev (pcase v
+                         ('nil (if use-package-vc-prefer-newest nil :last-release))
+                         (:last-release :last-release)
+                         (:newest nil)
+                         (_ (ensure-string v))))
                  (:vc-backend (ensure-symbol v))
                  (_ (ensure-string v)))))
     (pcase-let ((valid-kws '(:url :branch :lisp-dir :main-file :vc-backend :rev))