From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Artur Malabarba Newsgroups: gmane.emacs.devel Subject: Re: package.el dependencies Date: Mon, 2 Feb 2015 19:37:19 -0200 Message-ID: References: <87wq4dpqib.fsf@gmail.com> <87wq44su8v.fsf@gmail.com> <878ugj7ajz.fsf@gmail.com> <874mr67gjb.fsf@gmail.com> <87oapervqv.fsf@gmail.com> <877fw2kp1y.fsf@gmail.com> <87d25tps2q.fsf@gmail.com> <87egq83veh.fsf@gmail.com> Reply-To: bruce.connor.am@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1422913050 18361 80.91.229.3 (2 Feb 2015 21:37:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Feb 2015 21:37:30 +0000 (UTC) Cc: Stefan Monnier , emacs-devel To: Thierry Volpiatto Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 02 22:37:29 2015 Return-path: Envelope-to: ged-emacs-devel@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 1YIOgS-00007G-OJ for ged-emacs-devel@m.gmane.org; Mon, 02 Feb 2015 22:37:28 +0100 Original-Received: from localhost ([::1]:56819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIOgR-0006wT-SW for ged-emacs-devel@m.gmane.org; Mon, 02 Feb 2015 16:37:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIOgM-0006vk-IW for emacs-devel@gnu.org; Mon, 02 Feb 2015 16:37:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIOgL-0002Ey-92 for emacs-devel@gnu.org; Mon, 02 Feb 2015 16:37:22 -0500 Original-Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:40698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIOgL-0002E3-2a for emacs-devel@gnu.org; Mon, 02 Feb 2015 16:37:21 -0500 Original-Received: by mail-oi0-f48.google.com with SMTP id v63so46269756oia.7 for ; Mon, 02 Feb 2015 13:37:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=qjOrUp+8oYkwxiePJy+PRQhwJ2t5Ypf+Hab+2YY+j3U=; b=T7ceN8d+JM08Dlkfq0o7HpV0GTBqQEpSEyHTdG2V1KL/qWExuUngY0zis33B4K1M06 a1SNu2tKOOCQSRcWrjls9oZVb9azOrzKwZ2Jrg8TEJVZ38FA4T6Y+owBujStCP7z0TBM o1iN9rwAHxrM0MNF0cHXvWMw5GB0O5UeZsj9YfDimLyYkx7W/SQfilRY1gqqgtW2275U K6udPcQnsq+TjVCJldZhndcfP20ejCyjIon2qhEsf4gczZnSxtFfiGntfAK7q1MSLpro d8IarlmhOTzJLndGR+wfkJzDeCutktIozF43LVJEGXcsoLyiJBYOuxIVctt5cvOLUvtM hpSg== X-Received: by 10.202.218.135 with SMTP id r129mr8024911oig.26.1422913039853; Mon, 02 Feb 2015 13:37:19 -0800 (PST) Original-Received: by 10.76.125.1 with HTTP; Mon, 2 Feb 2015 13:37:19 -0800 (PST) In-Reply-To: <87egq83veh.fsf@gmail.com> X-Google-Sender-Auth: 7rmJIU4d6C07ukPO5ZHxjJAh2ys X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c06::230 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:182295 Archived-At: 2015-02-02 18:35 GMT-02:00 Thierry Volpiatto : > > Stefan Monnier writes: > >> We have a problem: since package-reinstall does a `package-delete' >> and since this `package-delete' always marks the package as unselected, >> it follows that package-reinstall will always mark the package as >> unselected :-( > > This patch fix this issue: > > diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el > index 9a29d63..296ee46 100644 > --- a/lisp/emacs-lisp/package.el > +++ b/lisp/emacs-lisp/package.el > @@ -1239,7 +1239,8 @@ to `package-selected-packages'." > "Reinstall package: " > (mapcar #'symbol-name > (mapcar #'car package-alist)))))) > - (package-delete (cadr (assq pkg package-alist)) t) > + (package-delete (cadr (assq pkg package-alist)) 'force > + (memq pkg package-selected-packages)) > (package-install pkg)) > > (defun package-strip-rcs-id (str) > @@ -1470,7 +1471,7 @@ with PKG-DESC entry removed." > (and (memq pkg (mapcar #'car (package-desc-reqs (cadr p)))) > (car p)))))) > > -(defun package-delete (pkg-desc &optional force) > +(defun package-delete (pkg-desc &optional force nosave) > "Delete package PKG-DESC. > > Argument PKG-DESC is a full description of package as vector. > @@ -1506,7 +1507,8 @@ elsewhere." > (unless (cdr pkgs) > (setq package-alist (delq pkgs package-alist)))) > ;; Update package-selected-packages. > - (when (memq name package-selected-packages) > + (when (and (memq name package-selected-packages) > + (null nosave)) > (customize-save-variable > 'package-selected-packages (remove name package-selected-packages))) > (message "Package `%s' deleted." (package-desc-full-name pkg-desc)))))) I was about to suggest the following. @@ -1238,9 +1238,10 @@ to `package-selected-packages'." (interactive (list (intern (completing-read "Reinstall package: " (mapcar #'symbol-name - (mapcar #'car package-alist)))))) - (package-delete (cadr (assq pkg package-alist)) t) - (package-install pkg)) + (mapcar #'car package-alist)))))) + (let ((selected (memq pkg package-selected-packages))) + (package-delete (cadr (assq pkg package-alist)) 'force) + (package-install pkg selected))) (defun package-strip-rcs-id (str) "Strip RCS version ID from the version string STR. >> One more thing: now that we have package-selected-packages, >> package-delete should be fixed to be a real "inverse" of >> package-install, i.e. it should delete its unused dependencies. > > Hmm, not sure it is a good idea. I'm on the fence on this. Personally, I would automate this (as Stefan suggests). But, of all linux package managers I've used, I don't remember any of them removing dependencies without explicit request. Other options, for the sake of completeness: 1. Just like we say "N packages can be upgraded, hit U...", we could have a message saying "N packages are dependencies which are no longer needed, hit R to remove them". 2. After `package-execute' is done, we could check if there are any unneeded deps and ask the user a 3rd question "The following dependencies are no longer necessary, remove them? ...". If the user answers `n' here, we can also ask "mark these as explicitily selected to prevent future autoremoval?". >> One more thing: it'd be great to extend the list-package display so as >> to indicate which packages are selected and which ones aren't. > > I already did this in helm, with "I" in first column, but in helm the > first 2 columns are not needed like in list-package ("I" and "D"). > Will see what I can do even if I don't use this UI. My suggestion would be to change the "installed" string (displayed on the status column) to "dependency" for packages that are not in `package-selected-packages'.