summary refs log tree commit diff
path: root/emacs/guix-main.scm
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2016-01-19 20:27:58 +0300
committerAlex Kost <alezost@gmail.com>2016-01-25 22:11:47 +0300
commit71310ccc56f24c7975ddc3bb9893083e138be808 (patch)
tree04a42ce70f4b6e6a55ab240d84c65ee5106d0098 /emacs/guix-main.scm
parent0a2a2b3387199c374c23912c0acfdf4156a0a84f (diff)
downloadguix-71310ccc56f24c7975ddc3bb9893083e138be808.tar.gz
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.
Diffstat (limited to 'emacs/guix-main.scm')
-rw-r--r--emacs/guix-main.scm30
1 files changed, 30 insertions, 0 deletions
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 @@ Return #t if the shell command was executed successfully."
 ;; 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))