From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Lirzin Subject: Re: [PATCH 04/13] utils: Use '@' for separating package names and version numbers. Date: Tue, 26 Jan 2016 18:57:11 +0100 Message-ID: <877fiw4420.fsf@gnu.org> References: <1453666771-16869-1-git-send-email-mthl@gnu.org> <1453666771-16869-5-git-send-email-mthl@gnu.org> <87y4bd2v6x.fsf@gnu.org> <87wpqx5j5q.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO7rh-00017i-GR for guix-devel@gnu.org; Tue, 26 Jan 2016 12:57:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO7re-0002c3-4c for guix-devel@gnu.org; Tue, 26 Jan 2016 12:57:17 -0500 In-Reply-To: <87wpqx5j5q.fsf@gmail.com> (Alex Kost's message of "Tue, 26 Jan 2016 02:33:21 +0300") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Alex Kost Cc: guix-devel Alex Kost writes: > Mathieu Lirzin (2016-01-26 00:41 +0300) wrote: > >> Finally, There is some code redundancy for the emacs UI but If I >> remember correctly there is a reason for that. (Alex?) > > If there is redundancy in the code, it should be removed. I didn't find > a procedure to make a name specification at the time, so I wrote > 'make-package-specification' in "emacs/guix-main.scm". I think we can > add a general procedure to construct a name specification to (guix > utils): Sorry, my mind got confused. ;) --8<---------------cut here---------------start------------->8--- (define (full-name->name+version spec) "Given package specification SPEC with or without output, return two values: name and version. For example, for SPEC \"foo@0.9.1b:lib\", return \"foo\" and \"0.9.1b\"." (let-values (((name version output) (package-specification->name+version+output spec))) (values name version))) (define (name+version->full-name name version) (string-append name "@" version)) (define* (make-package-specification name #:optional version output) (let ((full-name (if version (name+version->full-name name version) name))) (if output (string-append full-name ":" output) full-name))) --8<---------------cut here---------------end--------------->8--- I overlooked that this code handles =E2=80=9Cfull names=E2=80=9D without ha= ving a object as an argument. > (define* (package-name-specification name #:optional version output) > (let ((full-name (if version > (string-append name "@" version) > name))) > (if output > (string-append full-name ":" output) > full-name))) > > Then 'package-full-name' from (guix packages) and the code from > "emacs/guix-main.scm" can use it. WDYT? It seems a good idea to me now. Thanks, -- Mathieu Lirzin