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: [Emacs-diffs] master b689b90: Package archives now have priorities. Date: Sat, 17 Jan 2015 10:12:32 -0200 Message-ID: References: <20150116102411.11014.8945@vcs.savannah.gnu.org> Reply-To: bruce.connor.am@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1421496761 23232 80.91.229.3 (17 Jan 2015 12:12:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Jan 2015 12:12:41 +0000 (UTC) Cc: emacs-devel To: =?UTF-8?Q?Jorgen_Sch=C3=A4fer?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 17 13:12:40 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 1YCSF6-0000gS-DB for ged-emacs-devel@m.gmane.org; Sat, 17 Jan 2015 13:12:40 +0100 Original-Received: from localhost ([::1]:58949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCSF5-0001AU-N9 for ged-emacs-devel@m.gmane.org; Sat, 17 Jan 2015 07:12:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCSF1-0001AO-Ma for emacs-devel@gnu.org; Sat, 17 Jan 2015 07:12:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YCSF0-0006zh-NB for emacs-devel@gnu.org; Sat, 17 Jan 2015 07:12:35 -0500 Original-Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:36238) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCSEy-0006zC-UT for emacs-devel@gnu.org; Sat, 17 Jan 2015 07:12:34 -0500 Original-Received: by mail-oi0-f53.google.com with SMTP id g201so21041027oib.12 for ; Sat, 17 Jan 2015 04:12:32 -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:content-transfer-encoding; bh=rrc3fQbZhsfsSGbZvX7PqfA5uqJX7uPK1/mD79QiG7o=; b=LFkZrBcABhxFvmndO3MMF14yb1vGG0YC+w/NfAnz5F0EoxpcHGZqqKK1yZLhIJMJd4 StUzmaeV9z+5M77SBwUO0XoXY1KHooxGOiUUm89f1DCV+TAnhSCIL7yDj3cRBLzmG32u txyVQEDbH5Zg8h0w8s+v1p86fsREifz9MAiZvyksZ8+jc/h3YfgtS3NuRD6V2PfOD/+l A1CmmwfHKh6io9oLTIsIldJp4XECwU0VAWwXqZMdrG8BtkjQw1lZnvKv85n/hIefpz4g WY2hr4s+TfOw5Yxb9TgcRwsBaETWjpBGG8Cpzrz0BEbMl0GAlXyOARIhZuhn4zjq2wSR PiUA== X-Received: by 10.60.136.170 with SMTP id qb10mr12502332oeb.71.1421496752489; Sat, 17 Jan 2015 04:12:32 -0800 (PST) Original-Received: by 10.76.125.1 with HTTP; Sat, 17 Jan 2015 04:12:32 -0800 (PST) In-Reply-To: X-Google-Sender-Auth: rE-cS2YzXlzPlJyaXgwUY486nzQ X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c06::235 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:181372 Archived-At: >>> +(defun package--add-to-alist (pkg-desc alist) >>> + "Add PKG-DESC to ALIST. >>> + >>> +Packages are grouped by name. The package descriptions are sorted >>> +by version number." >>> + (let* ((name (package-desc-name pkg-desc)) >>> + (priority-version (package-desc-priority-version pkg-desc)) >>> + (existing-packages (assq name alist))) >>> + (if (not existing-packages) >>> + (cons (list name pkg-desc) >> This list should be a cons, probably why the test is failing. > > Why should this be a cons? The alist maps package names to ordered > package descriptors =E2=80=93 I guess (cons name (list pkg-desc)) would b= e > clearer in intent. Reading your code again, I see there are places where this `list' is correct, but there's also one point where I think it's wrong. Note the following diff section. It used to push `(cons (package-desc-name pkg-desc) pkg-desc)', and now it uses `package--add-to-alist' which pushes a list instead of a cons. Do you see what I mean? (defun package--download-one-archive (archive file) "Retrieve an archive file FILE from ARCHIVE, and cache it. ARCHIVE should be a cons cell of the form (NAME . LOCATION), @@ -1991,18 +2035,18 @@ If optional arg BUTTON is non-nil, describe its associated package." ;; ENTRY is (PKG-DESC [NAME VERSION STATUS DOC]) (let ((pkg-desc (car entry)) (status (aref (cadr entry) 2))) - (cond ((member status '("installed" "unsigned")) - (push pkg-desc installed)) - ((member status '("available" "new")) - (push (cons (package-desc-name pkg-desc) pkg-desc) - available))))) + (cond ((member status '("installed" "unsigned")) + (push pkg-desc installed)) + ((member status '("available" "new")) + (setq available (package--add-to-alist pkg-desc available))= )))) Maybe the solution is not to change `package--add-to-alist' but simply to not use it here. I also have a very tiny peeve here. Could we name this function `package--alist-append' or something like this? It's just that `add-to-alist' really reminds me of `add-to-list', which has a very different effect (the list variable is the first argument, it's referenced by name instead of value, and it's changed destructively). If you don't agree I won't push it. :-)