unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21625: [PATCH] lisp/emacs-lisp/package.el (package-install): Fix error.
@ 2015-10-05 19:55 Aaron Ecay
  2015-10-06 10:39 ` Artur Malabarba
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Ecay @ 2015-10-05 19:55 UTC (permalink / raw)
  To: 21625

* lisp/emacs-lisp/package.el (package-install): Fix error when ‘pkg’ is
  not a ‘package-desc’.  Also clarify documentation.

Through trial and error, I discovered that for non-interactive use the
‘pkg’ argument of the package-install function should be a symbol, not a
string.  This can also be discerned by inspecting the (interactive)
spec, specifically the call to ‘intern’.  However, even when proceeding
with a symbol an error is raised if the package is already installed.
This patch reuses the name computed earlier in the function to avoid
this.
---
 lisp/emacs-lisp/package.el | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index eb66e8f..89f2a1a 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1887,7 +1887,7 @@ add a call to it along with some explanatory comments."
 ;;;###autoload
 (defun package-install (pkg &optional dont-select)
   "Install the package PKG.
-PKG can be a package-desc or the package name of one the available packages
+PKG can be a package-desc or a symbol naming one of the available packages
 in an archive in `package-archives'.  Interactively, prompt for its name.
 
 If called interactively or if DONT-SELECT nil, add PKG to
@@ -1918,15 +1918,15 @@ to install it but still mark it as selected."
                 pkg)))
     (unless (or dont-select (package--user-selected-p name))
       (package--save-selected-packages
-       (cons name package-selected-packages))))
-  (if-let ((transaction
-            (if (package-desc-p pkg)
-                (unless (package-installed-p pkg)
-                  (package-compute-transaction (list pkg)
-                                               (package-desc-reqs pkg)))
-              (package-compute-transaction () (list (list pkg))))))
-      (package-download-transaction transaction)
-    (message "`%s' is already installed" (package-desc-full-name pkg))))
+       (cons name package-selected-packages)))
+    (if-let ((transaction
+              (if (package-desc-p pkg)
+                  (unless (package-installed-p pkg)
+                    (package-compute-transaction (list pkg)
+                                                 (package-desc-reqs pkg)))
+                (package-compute-transaction () (list (list pkg))))))
+        (package-download-transaction transaction)
+      (message "`%s' is already installed" name))))
 
 (defun package-strip-rcs-id (str)
   "Strip RCS version ID from the version string STR.
-- 
2.6.0






^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#21625: [PATCH] lisp/emacs-lisp/package.el (package-install): Fix error.
  2015-10-05 19:55 bug#21625: [PATCH] lisp/emacs-lisp/package.el (package-install): Fix error Aaron Ecay
@ 2015-10-06 10:39 ` Artur Malabarba
  2015-10-06 12:01   ` Aaron Ecay
  0 siblings, 1 reply; 5+ messages in thread
From: Artur Malabarba @ 2015-10-06 10:39 UTC (permalink / raw)
  To: Aaron Ecay; +Cc: 21625

Looks good to me.
Thanks for the patch Aaron. Have you done the copyright paperwork?

2015-10-05 20:55 GMT+01:00 Aaron Ecay <aaronecay@gmail.com>:
> * lisp/emacs-lisp/package.el (package-install): Fix error when ‘pkg’ is
>   not a ‘package-desc’.  Also clarify documentation.
>
> Through trial and error, I discovered that for non-interactive use the
> ‘pkg’ argument of the package-install function should be a symbol, not a
> string.  This can also be discerned by inspecting the (interactive)
> spec, specifically the call to ‘intern’.  However, even when proceeding
> with a symbol an error is raised if the package is already installed.
> This patch reuses the name computed earlier in the function to avoid
> this.
> ---
>  lisp/emacs-lisp/package.el | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> index eb66e8f..89f2a1a 100644
> --- a/lisp/emacs-lisp/package.el
> +++ b/lisp/emacs-lisp/package.el
> @@ -1887,7 +1887,7 @@ add a call to it along with some explanatory comments."
>  ;;;###autoload
>  (defun package-install (pkg &optional dont-select)
>    "Install the package PKG.
> -PKG can be a package-desc or the package name of one the available packages
> +PKG can be a package-desc or a symbol naming one of the available packages
>  in an archive in `package-archives'.  Interactively, prompt for its name.
>
>  If called interactively or if DONT-SELECT nil, add PKG to
> @@ -1918,15 +1918,15 @@ to install it but still mark it as selected."
>                  pkg)))
>      (unless (or dont-select (package--user-selected-p name))
>        (package--save-selected-packages
> -       (cons name package-selected-packages))))
> -  (if-let ((transaction
> -            (if (package-desc-p pkg)
> -                (unless (package-installed-p pkg)
> -                  (package-compute-transaction (list pkg)
> -                                               (package-desc-reqs pkg)))
> -              (package-compute-transaction () (list (list pkg))))))
> -      (package-download-transaction transaction)
> -    (message "`%s' is already installed" (package-desc-full-name pkg))))
> +       (cons name package-selected-packages)))
> +    (if-let ((transaction
> +              (if (package-desc-p pkg)
> +                  (unless (package-installed-p pkg)
> +                    (package-compute-transaction (list pkg)
> +                                                 (package-desc-reqs pkg)))
> +                (package-compute-transaction () (list (list pkg))))))
> +        (package-download-transaction transaction)
> +      (message "`%s' is already installed" name))))
>
>  (defun package-strip-rcs-id (str)
>    "Strip RCS version ID from the version string STR.
> --
> 2.6.0
>
>
>
>





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#21625: [PATCH] lisp/emacs-lisp/package.el (package-install): Fix error.
  2015-10-06 10:39 ` Artur Malabarba
@ 2015-10-06 12:01   ` Aaron Ecay
  2015-10-06 18:43     ` Artur Malabarba
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Ecay @ 2015-10-06 12:01 UTC (permalink / raw)
  To: bruce.connor.am; +Cc: 21625

Hi Artur,

Thanks for taking a look at the patch.  My copyright papers are done and
on file.

-- 
Aaron Ecay





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#21625: [PATCH] lisp/emacs-lisp/package.el (package-install): Fix error.
  2015-10-06 12:01   ` Aaron Ecay
@ 2015-10-06 18:43     ` Artur Malabarba
  2015-10-12 10:53       ` immerrr again
  0 siblings, 1 reply; 5+ messages in thread
From: Artur Malabarba @ 2015-10-06 18:43 UTC (permalink / raw)
  To: Aaron Ecay; +Cc: 21625-done

Patch applied. Thanks again Aaron

2015-10-06 13:01 GMT+01:00 Aaron Ecay <aaronecay@gmail.com>:
> Hi Artur,
>
> Thanks for taking a look at the patch.  My copyright papers are done and
> on file.
>
> --
> Aaron Ecay





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#21625: [PATCH] lisp/emacs-lisp/package.el (package-install): Fix error.
  2015-10-06 18:43     ` Artur Malabarba
@ 2015-10-12 10:53       ` immerrr again
  0 siblings, 0 replies; 5+ messages in thread
From: immerrr again @ 2015-10-12 10:53 UTC (permalink / raw)
  To: 21625

This patch should fix 20863, too.

On Tue, Oct 6, 2015 at 9:43 PM, Artur Malabarba
<bruce.connor.am@gmail.com> wrote:
> Patch applied. Thanks again Aaron
>





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-12 10:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-05 19:55 bug#21625: [PATCH] lisp/emacs-lisp/package.el (package-install): Fix error Aaron Ecay
2015-10-06 10:39 ` Artur Malabarba
2015-10-06 12:01   ` Aaron Ecay
2015-10-06 18:43     ` Artur Malabarba
2015-10-12 10:53       ` immerrr again

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).