From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 1/3] emacs: Add 'guix-find-license-definition' command. Date: Mon, 18 Apr 2016 11:17:53 +0300 Message-ID: <1460967475-3771-2-git-send-email-alezost@gmail.com> References: <1460967475-3771-1-git-send-email-alezost@gmail.com> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1as4Np-0004gJ-IS for guix-devel@gnu.org; Mon, 18 Apr 2016 04:18:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1as4Nm-0003LZ-5k for guix-devel@gnu.org; Mon, 18 Apr 2016 04:18:13 -0400 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:34256) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1as4Nl-0003Iu-UC for guix-devel@gnu.org; Mon, 18 Apr 2016 04:18:10 -0400 Received: by mail-lf0-x241.google.com with SMTP id e190so25016563lfe.1 for ; Mon, 18 Apr 2016 01:18:09 -0700 (PDT) Received: from localhost.localdomain ([217.107.192.146]) by smtp.gmail.com with ESMTPSA id ku5sm2865250lbc.11.2016.04.18.01.18.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Apr 2016 01:18:08 -0700 (PDT) In-Reply-To: <1460967475-3771-1-git-send-email-alezost@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * 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 @kbd{@key{RET}} there to display packages with this license in the same way as @kbd{M-x guix-packages-by-license} would do (@pxref{Emacs Commands}). +@item M-x guix-find-license-definition +Open @file{@dots{}/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))) -- 2.7.3