emacs: Add 'guix-browse-license-url' command.
[jackhill/guix/guix.git] / emacs / guix-license.el
1 ;;; guix-license.el --- Licenses
2
3 ;; Copyright © 2016 Alex Kost <alezost@gmail.com>
4
5 ;; This file is part of GNU Guix.
6
7 ;; GNU Guix is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
11
12 ;; GNU Guix is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 ;;; Commentary:
21
22 ;; This file provides the code to work with licenses of Guix packages.
23
24 ;;; Code:
25
26 (require 'guix-read)
27 (require 'guix-backend)
28 (require 'guix-guile)
29
30 (defun guix-lookup-license-url (license)
31 "Return URL of a LICENSE."
32 (or (guix-eval-read (guix-make-guile-expression
33 'lookup-license-uri license))
34 (error "Hm, I don't know URL of '%s' license" license)))
35
36 ;;;###autoload
37 (defun guix-browse-license-url (license)
38 "Browse URL of a LICENSE."
39 (interactive (list (guix-read-license-name)))
40 (browse-url (guix-lookup-license-url license)))
41
42 (provide 'guix-license)
43
44 ;;; guix-license.el ends here