guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/07: emacs: Add 'guix-find-license-definition' command.


From: Alex Kost
Subject: 01/07: emacs: Add 'guix-find-license-definition' command.
Date: Tue, 26 Apr 2016 09:47:27 +0000

alezost pushed a commit to branch master
in repository guix.

commit 8472b2fd2d4c4d060b1333c9c527575d965a0ebd
Author: Alex Kost <address@hidden>
Date:   Fri Apr 8 11:49:39 2016 +0300

    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.
---
 doc/emacs.texi        |    3 +++
 emacs/guix-license.el |   21 +++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index ed8896a..575e87c 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -544,6 +544,9 @@ Display a list of available licenses.  You can press 
@address@hidden
 there to display packages with this license in the same way as @kbd{M-x
 guix-packages-by-license} would do (@pxref{Emacs Commands}).
 
address@hidden M-x guix-find-license-definition
+Open @address@hidden/guix/licenses.scm} and move to the specified license.
+
 @end table
 
 
diff --git a/emacs/guix-license.el b/emacs/guix-license.el
index 940f551..6003a21 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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]