From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Aaron Ecay Newsgroups: gmane.emacs.bugs Subject: bug#21625: [PATCH] lisp/emacs-lisp/package.el (package-install): Fix error. Date: Mon, 5 Oct 2015 20:55:58 +0100 Message-ID: <1444074958-32600-1-git-send-email-aaronecay@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1444075089 7228 80.91.229.3 (5 Oct 2015 19:58:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Oct 2015 19:58:09 +0000 (UTC) To: 21625@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 05 21:57:53 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZjBtP-0005Pt-92 for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Oct 2015 21:57:51 +0200 Original-Received: from localhost ([::1]:47448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjBtO-00044s-KY for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Oct 2015 15:57:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjBsg-0003Ey-7n for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 15:57:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjBsc-0005Fy-MZ for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 15:57:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjBsc-0005Fu-Ie for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 15:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZjBsc-0007rf-G0 for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 15:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Aaron Ecay Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Oct 2015 19:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21625 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.144407497330173 (code B ref -1); Mon, 05 Oct 2015 19:57:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Oct 2015 19:56:13 +0000 Original-Received: from localhost ([127.0.0.1]:55459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZjBro-0007qa-OG for submit@debbugs.gnu.org; Mon, 05 Oct 2015 15:56:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37573) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZjBrn-0007qT-D3 for submit@debbugs.gnu.org; Mon, 05 Oct 2015 15:56:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjBrm-0004zY-1L for submit@debbugs.gnu.org; Mon, 05 Oct 2015 15:56:10 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:53115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjBrl-0004zT-U7 for submit@debbugs.gnu.org; Mon, 05 Oct 2015 15:56:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjBrl-0002uK-2c for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 15:56:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjBrh-0004xG-TK for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 15:56:09 -0400 Original-Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:33999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjBrh-0004wY-O1 for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 15:56:05 -0400 Original-Received: by wicfx3 with SMTP id fx3so136244810wic.1 for ; Mon, 05 Oct 2015 12:56:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=00VBIOLDCJCoY5xvn3izROa1nl7POVjws5Xb6AGLsBo=; b=X80DwLwN1WGNup8+apA8vCZn51myFWuFqpffrUZ47YkpG6OyJBseSvADYluNbUtDu6 652BKL5fk+nEudpqYLHNuy1ckdpx0pCaQd1G7oDeYGIBEkiLIg0w22J4h043CExQ7qlF 08c/RglRg4o7AQ0fB9gZIColfg4KTObct4ObjKdk/4NDRKnYJdW0kblTf1HFiUv1ihl0 92KUUWpEal+fu9W+9+lonfdtOQl5vdqmUDawca4aSiIN0eQcDa0rC2aed9LxINq25rqF LooqKt2jDJJ+lf8RjJ9whJgqxIGliCXkMuxuwlF4MstRp/LpQeC4submQ8g8AieviQDO cDfA== X-Received: by 10.181.27.138 with SMTP id jg10mr14439615wid.29.1444074964985; Mon, 05 Oct 2015 12:56:04 -0700 (PDT) Original-Received: from haize.york.ac.uk (natvip7.york.ac.uk. [144.32.240.7]) by smtp.gmail.com with ESMTPSA id it4sm28618423wjb.0.2015.10.05.12.56.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Oct 2015 12:56:04 -0700 (PDT) X-Mailer: git-send-email 2.6.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107332 Archived-At: * 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