aboutsummaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2016-04-08 11:49:39 +0300
committerAlex Kost <alezost@gmail.com>2016-04-26 12:32:56 +0300
commit8472b2fd2d4c4d060b1333c9c527575d965a0ebd (patch)
tree1087b721435b64fb71cb93f4c7db132ac346f2e4 /emacs
parentf674439433da47efd7253b59dbd27641c3aa6fbc (diff)
downloadguix-8472b2fd2d4c4d060b1333c9c527575d965a0ebd.tar
guix-8472b2fd2d4c4d060b1333c9c527575d965a0ebd.tar.gz
emacs: Add 'guix-find-license-definition' command.
* emacs/guix-license.el (guix-license-file): New procedure. (guix-find-license-definition): New command. * doc/emacs.texi (Emacs Licenses): Document it.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/guix-license.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/emacs/guix-license.el b/emacs/guix-license.el
index 940f5518e2..6003a21aac 100644
--- a/emacs/guix-license.el
+++ b/emacs/guix-license.el
@@ -27,6 +27,12 @@
(require 'guix-backend)
(require 'guix-guile)
+(defun guix-license-file (&optional directory)
+ "Return name of the file with license definitions.
+DIRECTORY is a directory with Guix source (`guix-directory' by default)."
+ (expand-file-name "guix/licenses.scm"
+ (or directory guix-directory)))
+
(defun guix-lookup-license-url (license)
"Return URL of a LICENSE."
(or (guix-eval-read (guix-make-guile-expression
@@ -34,6 +40,21 @@
(error "Hm, I don't know URL of '%s' license" license)))
;;;###autoload
+(defun guix-find-license-definition (license &optional directory)
+ "Open licenses file from DIRECTORY and move to the LICENSE definition.
+See `guix-license-file' for the meaning of DIRECTORY.
+Interactively, with prefix argument, prompt for DIRECTORY."
+ (interactive
+ (list (guix-read-license-name)
+ (guix-read-directory)))
+ (find-file (guix-license-file directory))
+ (goto-char (point-min))
+ (when (re-search-forward (concat "\"" (regexp-quote license) "\"")
+ nil t)
+ (beginning-of-defun)
+ (recenter 1)))
+
+;;;###autoload
(defun guix-browse-license-url (license)
"Browse URL of a LICENSE."
(interactive (list (guix-read-license-name)))