GNU bug report logs -
#62720
29.0.60; Not easy at all to upgrade :core packages like Eglot
Previous Next
Reported by: João Távora <joaotavora <at> gmail.com>
Date: Fri, 7 Apr 2023 22:11:01 UTC
Severity: normal
Found in version 29.0.60
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Philip Kaludercic <philipk <at> posteo.net> writes:
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> From: Philip Kaludercic <philipk <at> posteo.net>
>>> Cc: João Távora <joaotavora <at> gmail.com>,
>>> monnier <at> iro.umontreal.ca,
>>> 62720 <at> debbugs.gnu.org, larsi <at> gnus.org
>>> Date: Wed, 12 Apr 2023 19:39:20 +0000
>>>
>>> >> Please, in normal non-shouting case, explain to me how you think
>>> >> that the behavior of an existing
>>> >> command can be changed with "completely separate code".
>>> >
>>> > I already did: either (1) add a prefix argument to an existing
>>> > command, which will then trigger the new behavior, or (2) add a
>>> > separate command.
>>>
>>> Here you have (1):
>>
>> Thanks. This is almost on-target, but it modifies
>> package-compute-transaction. Is that necessary?
>
> I have found an alternative that doesn't change the way
> `package-compute-transaction' works, but requires a small change in
> `package-install':
I have found a smaller but equivalent change that would also solve the
issue:
[Message part 2 (text/plain, inline)]
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index f92afe56b76..842a475290d 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -797,6 +797,17 @@ package-built-in-p
(require 'finder-inf nil t) ; For `package--builtins'.
(assq package package--builtins))))))
+(defun package--upgradable-built-in-p (package)
+ "Return non-nil if PACKAGE if the built-in version is used."
+ (and (not (assq (cond
+ ((package-desc-p package)
+ (package-desc-name package))
+ ((stringp package) (intern package))
+ ((symbolp package) package)
+ ((error "Unknown package format: %S" package)))
+ (package--alist)))
+ (package-built-in-p package)))
+
(defun package--autoloads-file-name (pkg-desc)
"Return the absolute name of the autoloads file, sans extension.
PKG-DESC is a `package-desc' object."
@@ -2187,7 +2198,9 @@ package-install
"Install the package PKG.
PKG can be a `package-desc' or a symbol naming one of the
available packages in an archive in `package-archives'. When
-called interactively, prompt for the package name.
+called interactively, prompt for the package name. When invoked
+with a prefix argument, the prompt will include built-in packages
+that can be upgraded via an archive.
Mark the installed package as selected by adding it to
`package-selected-packages'.
@@ -2205,11 +2218,13 @@ package-install
(package--archives-initialize)
(list (intern (completing-read
"Install package: "
- (delq nil
- (mapcar (lambda (elt)
- (unless (package-installed-p (car elt))
- (symbol-name (car elt))))
- package-archive-contents))
+ (mapcan
+ (lambda (elt)
+ (and (or (and current-prefix-arg
+ (package--upgradable-built-in-p (car elt)))
+ (not (package-installed-p (car elt))))
+ (list (car elt))))
+ package-archive-contents)
nil t))
nil)))
(package--archives-initialize)
@@ -2220,6 +2235,8 @@ package-install
(unless (or dont-select (package--user-selected-p name))
(package--save-selected-packages
(cons name package-selected-packages)))
+ (when (package--upgradable-built-in-p pkg)
+ (setq pkg (cadr (assq name package-archive-contents))))
(if-let* ((transaction
(if (package-desc-p pkg)
(unless (package-installed-p pkg)
[Message part 3 (text/plain, inline)]
This relies on the fact that package-install handles package descriptor
objects in a different way than when you just call the function with a
package name.
This would also mean that an alternative solution to this issue would be
to tell users to evaluate
(package-install (cadr (assq 'eglot package-archive-contents)))
but I don't know how user-friendly of an idea this is.
This bug report was last modified 2 years and 17 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.