Alex Kost <alez...@gmail.com> 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 “full names” without having a <package> 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