From 71310ccc56f24c7975ddc3bb9893083e138be808 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Tue, 19 Jan 2016 20:27:58 +0300 Subject: emacs: Add 'guix-browse-license-url' command. * emacs/guix-main.scm (%licenses): New variable. (licenses, license-names, lookup-license, lookup-license-uri): New procedures. * emacs/guix-read.el (guix-license-names, guix-read-license-name): New procedures. * emacs/guix-license.el: New file. (guix-lookup-license-url): New procedure. (guix-browse-license-url): New command. * emacs.am (ELFILES): Add new file. --- emacs/guix-main.scm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'emacs/guix-main.scm') diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm index 236c882e3c..0aee206a15 100644 --- a/emacs/guix-main.scm +++ b/emacs/guix-main.scm @@ -1042,3 +1042,33 @@ (define (package-names) ;; See the comment to 'guix-package-names' function in "guix-popup.el". (define (package-names-lists) (map list (package-names))) + + +;;; Licenses + +(define %licenses + (delay + (filter license? + (module-map (lambda (_ var) + (variable-ref var)) + (resolve-interface '(guix licenses)))))) + +(define (licenses) + (force %licenses)) + +(define (license-names) + "Return a list of names of available licenses." + (map license-name (licenses))) + +(define lookup-license + (memoize + (lambda (name) + "Return a license by its name." + (find (lambda (l) + (string=? name (license-name l))) + (licenses))))) + +(define (lookup-license-uri name) + "Return a license URI by its name." + (and=> (lookup-license name) + license-uri)) -- cgit v1.2.3