* [PATCH 0/3] emacs: Add possibilities to move to license definition.
@ 2016-04-18 8:17 Alex Kost
2016-04-18 8:17 ` [PATCH 1/3] emacs: Add 'guix-find-license-definition' command Alex Kost
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Alex Kost @ 2016-04-18 8:17 UTC (permalink / raw)
To: guix-devel
As a user can move to a package definition (with "guix edit"), (s)he can
also want to go to a license definition (why not?). This patchset adds
this possibility in 3 places:
1. As a standalone command (analog of "M-x guix-edit"):
M-x guix-find-license-definition
Or maybe it should be called "guix-license-edit" and "guix-edit"
should be renamed (aliased) to "guix-package-edit"? Or to
"guix-find-package-definition"?
Just to mention, I changed my opinion on the bug#22587¹: now I think
"edit" is not a good name for displaying a package recipe.
2. As a button to *Guix License Info* buffer (this buffer appears, for
example, when you press a license button in a *Guix Package Info*
buffer).
3. As an "e" key in *Guix Licenses* buffer (this buffer appears after
"M-x guix-licenses"). I bound it to "e" because it is essentially
the same thing as "edit" for packages, which is bound to "e" in a
*Guix Package List* buffer. I don't like "e" key actually, but it is
for the same "edit" bug.
[PATCH 1/3] emacs: Add 'guix-find-license-definition' command.
[PATCH 2/3] emacs: Add license definition button to License Info.
[PATCH 3/3] emacs: Add "edit" command to a list of licenses.
¹ http://bugs.gnu.org/22587
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/3] emacs: Add 'guix-find-license-definition' command.
2016-04-18 8:17 [PATCH 0/3] emacs: Add possibilities to move to license definition Alex Kost
@ 2016-04-18 8:17 ` Alex Kost
2016-04-25 21:46 ` Ludovic Courtès
2016-04-18 8:17 ` [PATCH 2/3] emacs: Add license definition button to License Info buffer Alex Kost
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Alex Kost @ 2016-04-18 8:17 UTC (permalink / raw)
To: guix-devel
* 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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/3] emacs: Add license definition button to License Info buffer.
2016-04-18 8:17 [PATCH 0/3] emacs: Add possibilities to move to license definition Alex Kost
2016-04-18 8:17 ` [PATCH 1/3] emacs: Add 'guix-find-license-definition' command Alex Kost
@ 2016-04-18 8:17 ` Alex Kost
2016-04-25 21:46 ` Ludovic Courtès
2016-04-18 8:17 ` [PATCH 3/3] emacs: Add "edit" command to a list of licenses Alex Kost
2016-04-25 21:45 ` [PATCH 0/3] emacs: Add possibilities to move to license definition Ludovic Courtès
3 siblings, 1 reply; 11+ messages in thread
From: Alex Kost @ 2016-04-18 8:17 UTC (permalink / raw)
To: guix-devel
* emacs/guix-ui-license.el (guix-license-insert-file): New procedure.
(guix-license-info-format): Use it.
---
emacs/guix-ui-license.el | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/emacs/guix-ui-license.el b/emacs/guix-ui-license.el
index ab1d25b..772a168 100644
--- a/emacs/guix-ui-license.el
+++ b/emacs/guix-ui-license.el
@@ -29,6 +29,7 @@
(require 'guix-info)
(require 'guix-backend)
(require 'guix-guile)
+(require 'guix-license)
(guix-define-entry-type license)
@@ -64,7 +65,9 @@ SEARCH-TYPE may be one of the following symbols: `all', `id', `name'."
ignore
guix-license-insert-packages-button
(url ignore (simple guix-url))
- guix-license-insert-comment)
+ guix-license-insert-comment
+ ignore
+ guix-license-insert-file)
:titles '((url . "URL")))
(declare-function guix-packages-by-license "guix-ui-package")
@@ -89,6 +92,16 @@ SEARCH-TYPE may be one of the following symbols: `all', `id', `name'."
(guix-info-param-title 'license 'comment))
(guix-info-insert-value-indent comment))))
+(defun guix-license-insert-file (entry)
+ "Insert button to open license definition."
+ (let ((license (guix-entry-value entry 'name)))
+ (guix-insert-button
+ (guix-license-file) 'guix-file
+ 'help-echo (format "Open definition of license '%s'" license)
+ 'action (lambda (btn)
+ (guix-find-license-definition (button-get btn 'license)))
+ 'license license)))
+
\f
;;; License 'list'
--
2.7.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/3] emacs: Add "edit" command to a list of licenses.
2016-04-18 8:17 [PATCH 0/3] emacs: Add possibilities to move to license definition Alex Kost
2016-04-18 8:17 ` [PATCH 1/3] emacs: Add 'guix-find-license-definition' command Alex Kost
2016-04-18 8:17 ` [PATCH 2/3] emacs: Add license definition button to License Info buffer Alex Kost
@ 2016-04-18 8:17 ` Alex Kost
2016-04-25 21:47 ` Ludovic Courtès
2016-04-25 21:45 ` [PATCH 0/3] emacs: Add possibilities to move to license definition Ludovic Courtès
3 siblings, 1 reply; 11+ messages in thread
From: Alex Kost @ 2016-04-18 8:17 UTC (permalink / raw)
To: guix-devel
* emacs/guix-ui-license.el (guix-license-list-edit): New command.
(guix-license-list-mode-map): Bind it to "e" key.
---
emacs/guix-ui-license.el | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/emacs/guix-ui-license.el b/emacs/guix-ui-license.el
index 772a168..cf1b5cd 100644
--- a/emacs/guix-ui-license.el
+++ b/emacs/guix-ui-license.el
@@ -116,6 +116,7 @@ SEARCH-TYPE may be one of the following symbols: `all', `id', `name'."
:sort-key '(name))
(let ((map guix-license-list-mode-map))
+ (define-key map (kbd "e") 'guix-license-list-edit)
(define-key map (kbd "RET") 'guix-license-list-show-packages))
(defun guix-license-list-describe (ids)
@@ -129,6 +130,12 @@ SEARCH-TYPE may be one of the following symbols: `all', `id', `name'."
(interactive)
(guix-packages-by-license (guix-list-current-id)))
+(defun guix-license-list-edit (&optional directory)
+ "Go to the location of the current license definition.
+See `guix-license-file' for the meaning of DIRECTORY."
+ (interactive (list (guix-read-directory)))
+ (guix-find-license-definition (guix-list-current-id) directory))
+
\f
;;; Interactive commands
--
2.7.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 0/3] emacs: Add possibilities to move to license definition.
2016-04-18 8:17 [PATCH 0/3] emacs: Add possibilities to move to license definition Alex Kost
` (2 preceding siblings ...)
2016-04-18 8:17 ` [PATCH 3/3] emacs: Add "edit" command to a list of licenses Alex Kost
@ 2016-04-25 21:45 ` Ludovic Courtès
2016-04-26 9:49 ` Alex Kost
3 siblings, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2016-04-25 21:45 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> As a user can move to a package definition (with "guix edit"), (s)he can
> also want to go to a license definition (why not?). This patchset adds
> this possibility in 3 places:
>
> 1. As a standalone command (analog of "M-x guix-edit"):
>
> M-x guix-find-license-definition
I think this is a fine name. :-)
> 2. As a button to *Guix License Info* buffer (this buffer appears, for
> example, when you press a license button in a *Guix Package Info*
> buffer).
>
> 3. As an "e" key in *Guix Licenses* buffer (this buffer appears after
> "M-x guix-licenses"). I bound it to "e" because it is essentially
> the same thing as "edit" for packages, which is bound to "e" in a
> *Guix Package List* buffer. I don't like "e" key actually, but it is
> for the same "edit" bug.
Awesome!
I think perhaps ‘guix-view-license’, which would open the license text
(probably via a browser pointing at the URL of the <license>) would be
cool.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] emacs: Add 'guix-find-license-definition' command.
2016-04-18 8:17 ` [PATCH 1/3] emacs: Add 'guix-find-license-definition' command Alex Kost
@ 2016-04-25 21:46 ` Ludovic Courtès
0 siblings, 0 replies; 11+ messages in thread
From: Ludovic Courtès @ 2016-04-25 21:46 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> * emacs/guix-license.el (guix-license-file): New procedure.
> (guix-find-license-definition): New command.
> * doc/emacs.texi (Emacs Licenses): Document it.
OK!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] emacs: Add license definition button to License Info buffer.
2016-04-18 8:17 ` [PATCH 2/3] emacs: Add license definition button to License Info buffer Alex Kost
@ 2016-04-25 21:46 ` Ludovic Courtès
0 siblings, 0 replies; 11+ messages in thread
From: Ludovic Courtès @ 2016-04-25 21:46 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> * emacs/guix-ui-license.el (guix-license-insert-file): New procedure.
> (guix-license-info-format): Use it.
OK!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] emacs: Add "edit" command to a list of licenses.
2016-04-18 8:17 ` [PATCH 3/3] emacs: Add "edit" command to a list of licenses Alex Kost
@ 2016-04-25 21:47 ` Ludovic Courtès
2016-04-26 9:48 ` Alex Kost
0 siblings, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2016-04-25 21:47 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> * emacs/guix-ui-license.el (guix-license-list-edit): New command.
> (guix-license-list-mode-map): Bind it to "e" key.
OK!
And sorry for the delay…
Ludo’.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] emacs: Add "edit" command to a list of licenses.
2016-04-25 21:47 ` Ludovic Courtès
@ 2016-04-26 9:48 ` Alex Kost
0 siblings, 0 replies; 11+ messages in thread
From: Alex Kost @ 2016-04-26 9:48 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Ludovic Courtès (2016-04-26 00:47 +0300) wrote:
> Alex Kost <alezost@gmail.com> skribis:
>
>> * emacs/guix-ui-license.el (guix-license-list-edit): New command.
>> (guix-license-list-mode-map): Bind it to "e" key.
>
> OK!
>
> And sorry for the delay…
No problem :-) I've pushed this patchset, thanks!
--
Alex
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/3] emacs: Add possibilities to move to license definition.
2016-04-25 21:45 ` [PATCH 0/3] emacs: Add possibilities to move to license definition Ludovic Courtès
@ 2016-04-26 9:49 ` Alex Kost
2016-04-27 12:20 ` Ludovic Courtès
0 siblings, 1 reply; 11+ messages in thread
From: Alex Kost @ 2016-04-26 9:49 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Ludovic Courtès (2016-04-26 00:45 +0300) wrote:
> Alex Kost <alezost@gmail.com> skribis:
>
>> As a user can move to a package definition (with "guix edit"), (s)he can
>> also want to go to a license definition (why not?). This patchset adds
>> this possibility in 3 places:
>>
>> 1. As a standalone command (analog of "M-x guix-edit"):
>>
>> M-x guix-find-license-definition
>
> I think this is a fine name. :-)
>
>> 2. As a button to *Guix License Info* buffer (this buffer appears, for
>> example, when you press a license button in a *Guix Package Info*
>> buffer).
>>
>> 3. As an "e" key in *Guix Licenses* buffer (this buffer appears after
>> "M-x guix-licenses"). I bound it to "e" because it is essentially
>> the same thing as "edit" for packages, which is bound to "e" in a
>> *Guix Package List* buffer. I don't like "e" key actually, but it is
>> for the same "edit" bug.
>
> Awesome!
>
> I think perhaps ‘guix-view-license’, which would open the license text
> (probably via a browser pointing at the URL of the <license>) would be
> cool.
If I understand you correctly, what you mean is "M-x
guix-browse-license-url" (introduced by commit 71310ccc).
--
Alex
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/3] emacs: Add possibilities to move to license definition.
2016-04-26 9:49 ` Alex Kost
@ 2016-04-27 12:20 ` Ludovic Courtès
0 siblings, 0 replies; 11+ messages in thread
From: Ludovic Courtès @ 2016-04-27 12:20 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> Ludovic Courtès (2016-04-26 00:45 +0300) wrote:
[...]
>> I think perhaps ‘guix-view-license’, which would open the license text
>> (probably via a browser pointing at the URL of the <license>) would be
>> cool.
>
> If I understand you correctly, what you mean is "M-x
> guix-browse-license-url" (introduced by commit 71310ccc).
Indeed, you’re a hero!
Ludo’.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2016-04-27 12:20 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-18 8:17 [PATCH 0/3] emacs: Add possibilities to move to license definition Alex Kost
2016-04-18 8:17 ` [PATCH 1/3] emacs: Add 'guix-find-license-definition' command Alex Kost
2016-04-25 21:46 ` Ludovic Courtès
2016-04-18 8:17 ` [PATCH 2/3] emacs: Add license definition button to License Info buffer Alex Kost
2016-04-25 21:46 ` Ludovic Courtès
2016-04-18 8:17 ` [PATCH 3/3] emacs: Add "edit" command to a list of licenses Alex Kost
2016-04-25 21:47 ` Ludovic Courtès
2016-04-26 9:48 ` Alex Kost
2016-04-25 21:45 ` [PATCH 0/3] emacs: Add possibilities to move to license definition Ludovic Courtès
2016-04-26 9:49 ` Alex Kost
2016-04-27 12:20 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).