unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 0/7]: Add "M-x guix-licenses" and friends.
@ 2016-01-22  8:19 Alex Kost
  2016-01-22  8:19 ` [PATCH 1/7] emacs: Rename 'file-path' to 'file-name' Alex Kost
                   ` (6 more replies)
  0 siblings, 7 replies; 21+ messages in thread
From: Alex Kost @ 2016-01-22  8:19 UTC (permalink / raw)
  To: guix-devel

Hello, this patchset adds the following emacs commands:

- guix-browse-license-url
- guix-packages-by-license
- guix-licenses

Patches:

[PATCH 1/7] emacs: Rename 'file-path' to 'file-name'.

  Actually this patch is independent from the rest patchset, I just
  added it for the company.

[PATCH 2/7] licenses: Add a list of licenses.
[PATCH 3/7] emacs: Add 'guix-browse-license-url' command.
[PATCH 4/7] emacs: Buttonize licenses in "Package Info".
[PATCH 5/7] emacs: Add 'guix-packages-by-license' command.
[PATCH 6/7] emacs: list: Support displaying URL links.
[PATCH 7/7] emacs: Add interface for licenses.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/7] emacs: Rename 'file-path' to 'file-name'.
  2016-01-22  8:19 [PATCH 0/7]: Add "M-x guix-licenses" and friends Alex Kost
@ 2016-01-22  8:19 ` Alex Kost
  2016-01-23 17:06   ` Ludovic Courtès
  2016-01-22  8:19 ` [PATCH 2/7] licenses: Add a list of licenses Alex Kost
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Alex Kost @ 2016-01-22  8:19 UTC (permalink / raw)
  To: guix-devel

* emacs/guix-info.el (guix-info-file-path): Rename to...
  (guix-info-file-name): ... this.
* emacs/guix-list.el (guix-list-file-path): Rename to...
  (guix-list-file-name): ... this.
  (guix-list-get-file-path): Rename to...
  (guix-list-get-file-name): ... this.
* emacs/guix-ui-generation.el (guix-generation-list-format): Adjust
  accordingly.
* emacs/guix-ui-system-generation.el (guix-system-generation-list-format):
  Likewise.
* NEWS: Mention faces renaming.
---
 NEWS                               |  3 ++-
 emacs/guix-info.el                 |  6 +++---
 emacs/guix-list.el                 | 14 +++++++-------
 emacs/guix-ui-generation.el        |  2 +-
 emacs/guix-ui-system-generation.el |  2 +-
 5 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/NEWS b/NEWS
index 0084394..b27ebc7 100644
--- a/NEWS
+++ b/NEWS
@@ -16,7 +16,7 @@ Please send Guix bug reports to bug-guix@gnu.org.
 
 *** Emacs interface for system generations
 *** Emacs interface for hydra.gnu.org
-*** Changes in Emacs interface variables
+*** Changes in Emacs interface variables and faces
 In the following names, BUFFER-TYPE means "info" or "list";
 ENTRY-TYPE means "package", "output" or "generation".
 
@@ -30,6 +30,7 @@ ENTRY-TYPE means "package", "output" or "generation".
 - guix-buffer-name-function -> guix-ui-buffer-name-function
 - guix-update-after-operation -> guix-ui-update-after-operation
 - guix-search-params -> guix-package-search-params
+- guix-BUFFER-TYPE-file-path (face) -> guix-BUFFER-TYPE-file-name
 
 **** Replaced
 - guix-list-column-format, guix-list-column-value-methods ->
diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index 644533e..6aefd2f 100644
--- a/emacs/guix-info.el
+++ b/emacs/guix-info.el
@@ -42,9 +42,9 @@
   "Face used for titles of parameters."
   :group 'guix-info-faces)
 
-(defface guix-info-file-path
+(defface guix-info-file-name
   '((t :inherit link))
-  "Face used for file paths."
+  "Face used for file names."
   :group 'guix-info-faces)
 
 (defface guix-info-url
@@ -337,7 +337,7 @@ BUTTON-OR-FACE is a button type)."
 
 (define-button-type 'guix-file
   :supertype 'guix
-  'face 'guix-info-file-path
+  'face 'guix-info-file-name
   'help-echo "Find file"
   'action (lambda (btn)
             (guix-find-file (button-label btn))))
diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index 7e57f42..51eb106 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -33,9 +33,9 @@
 
 (guix-define-buffer-type list)
 
-(defface guix-list-file-path
-  '((t :inherit guix-info-file-path))
-  "Face used for file paths."
+(defface guix-list-file-name
+  '((t :inherit guix-info-file-name))
+  "Face used for file names."
   :group 'guix-list-faces)
 
 (defface guix-list-time
@@ -214,10 +214,10 @@ VAL may be nil."
   (guix-get-string (guix-get-time-string seconds)
                    'guix-list-time))
 
-(defun guix-list-get-file-path (path &optional _)
-  "Return PATH button specification for `tabulated-list-entries'."
-  (list path
-        'face 'guix-list-file-path
+(defun guix-list-get-file-name (file-name &optional _)
+  "Return FILE-NAME button specification for `tabulated-list-entries'."
+  (list file-name
+        'face 'guix-list-file-name
         'action (lambda (btn) (find-file (button-label btn)))
         'follow-link t
         'help-echo "Find file"))
diff --git a/emacs/guix-ui-generation.el b/emacs/guix-ui-generation.el
index 4047850..74b8ff2 100644
--- a/emacs/guix-ui-generation.el
+++ b/emacs/guix-ui-generation.el
@@ -166,7 +166,7 @@ current profile's GENERATION."
   :format '((number nil 5 guix-list-sort-numerically-0 :right-align t)
             (current guix-generation-list-get-current 10 t)
             (time guix-list-get-time 20 t)
-            (path guix-list-get-file-path 30 t))
+            (path guix-list-get-file-name 30 t))
   :titles '((number . "N."))
   :sort-key '(number . t)
   :marks '((delete . ?D)))
diff --git a/emacs/guix-ui-system-generation.el b/emacs/guix-ui-system-generation.el
index d79f3bc..7f4d76d 100644
--- a/emacs/guix-ui-system-generation.el
+++ b/emacs/guix-ui-system-generation.el
@@ -71,7 +71,7 @@ SEARCH-VALUES."
             (current guix-generation-list-get-current 10 t)
             (label nil 40 t)
             (time guix-list-get-time 20 t)
-            (path guix-list-get-file-path 30 t))
+            (path guix-list-get-file-name 30 t))
   :titles guix-generation-list-titles
   :sort-key '(number . t)
   :marks '((delete . ?D)))
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/7] licenses: Add a list of licenses.
  2016-01-22  8:19 [PATCH 0/7]: Add "M-x guix-licenses" and friends Alex Kost
  2016-01-22  8:19 ` [PATCH 1/7] emacs: Rename 'file-path' to 'file-name' Alex Kost
@ 2016-01-22  8:19 ` Alex Kost
  2016-01-23 17:08   ` Ludovic Courtès
  2016-01-22  8:19 ` [PATCH 3/7] emacs: Add 'guix-browse-license-url' command Alex Kost
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Alex Kost @ 2016-01-22  8:19 UTC (permalink / raw)
  To: guix-devel

* guix/licenses.scm (%licenses): New variable.
---
 guix/licenses.scm | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/guix/licenses.scm b/guix/licenses.scm
index 9ace7f5..75e4426 100644
--- a/guix/licenses.scm
+++ b/guix/licenses.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2012, 2013 Nikita Karetnikov <nikita@karetnikov.org>
+;;; Copyright © 2014, 2016 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
 ;;;
@@ -23,6 +24,7 @@
 (define-module (guix licenses)
   #:use-module (srfi srfi-9)
   #:export (license? license-name license-uri license-comment
+            %licenses
             agpl3 agpl3+
             asl2.0
             boost1.0
@@ -405,4 +407,46 @@ of licenses, approved as free by the FSF.  More details can be found at URI."
            uri
            comment))
 
+(define %licenses
+  ;; List of all licenses.
+  (list
+   agpl3 agpl3+
+   asl2.0
+   boost1.0
+   bsd-2 bsd-3 bsd-4
+   cc0
+   cc-by-sa4.0 cc-by-sa3.0 cc-by3.0
+   cddl1.0
+   cecill-c
+   artistic2.0 clarified-artistic
+   copyleft-next
+   cpl1.0
+   epl1.0
+   expat
+   freetype
+   gpl1 gpl1+ gpl2 gpl2+ gpl3 gpl3+
+   gfl1.0
+   fdl1.3+
+   opl1.0+
+   isc
+   ijg
+   ibmpl1.0
+   imlib2
+   ipa
+   lgpl2.0 lgpl2.0+ lgpl2.1 lgpl2.1+ lgpl3 lgpl3+
+   mpl1.1 mpl2.0
+   ms-pl
+   ncsa
+   openldap2.8 openssl
+   psfl public-domain
+   qpl
+   ruby
+   sgifreeb2.0
+   silofl1.1
+   sleepycat
+   vim
+   x11
+   zpl2.1
+   zlib))
+
 ;;; licenses.scm ends here
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/7] emacs: Add 'guix-browse-license-url' command.
  2016-01-22  8:19 [PATCH 0/7]: Add "M-x guix-licenses" and friends Alex Kost
  2016-01-22  8:19 ` [PATCH 1/7] emacs: Rename 'file-path' to 'file-name' Alex Kost
  2016-01-22  8:19 ` [PATCH 2/7] licenses: Add a list of licenses Alex Kost
@ 2016-01-22  8:19 ` Alex Kost
  2016-01-23 17:13   ` Ludovic Courtès
  2016-01-23 17:18   ` Ludovic Courtès
  2016-01-22  8:19 ` [PATCH 4/7] emacs: Buttonize licenses in "Package Info" Alex Kost
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 21+ messages in thread
From: Alex Kost @ 2016-01-22  8:19 UTC (permalink / raw)
  To: guix-devel

* emacs/guix-main.scm (license-names, license-name->license)
  (license-name->uri): New procedures.
* emacs/guix-read.el (guix-license-names, guix-read-license-name): New
  procedures.
* emacs/guix-license.el: New file.
* emacs.am (ELFILES): Add it.
---
 emacs.am              |  3 ++-
 emacs/guix-license.el | 44 ++++++++++++++++++++++++++++++++++++++++++++
 emacs/guix-main.scm   | 18 ++++++++++++++++++
 emacs/guix-read.el    | 11 ++++++++++-
 4 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 emacs/guix-license.el

diff --git a/emacs.am b/emacs.am
index d0d4dfb..6af9596 100644
--- a/emacs.am
+++ b/emacs.am
@@ -1,5 +1,5 @@
 # GNU Guix --- Functional package management for GNU
-# Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
+# Copyright © 2014, 2015, 2016 Alex Kost <alezost@gmail.com>
 #
 # This file is part of GNU Guix.
 #
@@ -37,6 +37,7 @@ ELFILES =					\
   emacs/guix-hydra-jobset.el			\
   emacs/guix-info.el				\
   emacs/guix-init.el				\
+  emacs/guix-license.el				\
   emacs/guix-list.el				\
   emacs/guix-messages.el			\
   emacs/guix-pcomplete.el			\
diff --git a/emacs/guix-license.el b/emacs/guix-license.el
new file mode 100644
index 0000000..a28b45e
--- /dev/null
+++ b/emacs/guix-license.el
@@ -0,0 +1,44 @@
+;;; guix-license.el --- Licenses
+
+;; Copyright © 2016 Alex Kost <alezost@gmail.com>
+
+;; This file is part of GNU Guix.
+
+;; GNU Guix is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Guix is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file provides the code to work with licenses of Guix packages.
+
+;;; Code:
+
+(require 'guix-read)
+(require 'guix-backend)
+(require 'guix-guile)
+
+(defun guix-license-name->url (license)
+  "Return URL of a LICENSE."
+  (or (guix-eval-read (guix-make-guile-expression
+                       'license-name->uri license))
+      (error "Hm, I don't know URL of '%s' license" license)))
+
+;;;###autoload
+(defun guix-browse-license-url (license)
+  "Browse URL of a LICENSE."
+  (interactive (list (guix-read-license-name)))
+  (browse-url (guix-license-name->url license)))
+
+(provide 'guix-license)
+
+;;; guix-license.el ends here
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 236c882..7706921 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -1042,3 +1042,21 @@ Return #t if the shell command was executed successfully."
 ;; See the comment to 'guix-package-names' function in "guix-popup.el".
 (define (package-names-lists)
   (map list (package-names)))
+
+\f
+;;; Licenses
+
+(define (license-names)
+  "Return a list of names of available licenses."
+  (map license-name %licenses))
+
+(define license-name->license
+  (memoize
+   (lambda (name)
+     (find (lambda (l)
+             (string=? name (license-name l)))
+           %licenses))))
+
+(define (license-name->uri name)
+  (and=> (license-name->license name)
+         license-uri))
diff --git a/emacs/guix-read.el b/emacs/guix-read.el
index 3bc7b16..a1a6b86 100644
--- a/emacs/guix-read.el
+++ b/emacs/guix-read.el
@@ -1,6 +1,6 @@
 ;;; guix-read.el --- Minibuffer readers
 
-;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
 
 ;; This file is part of GNU Guix.
 
@@ -58,6 +58,10 @@
                             'package-names-lists)))
    #'string<))
 
+(guix-memoized-defun guix-license-names ()
+  "Return a list of names of available licenses."
+  (guix-eval-read (guix-make-guile-expression 'license-names)))
+
 \f
 ;;; Readers
 
@@ -122,6 +126,11 @@
  :multiple-prompt "Package,s: "
  :multiple-separator " ")
 
+(guix-define-readers
+ :completions-getter guix-license-names
+ :single-reader guix-read-license-name
+ :single-prompt "License: ")
+
 (provide 'guix-read)
 
 ;;; guix-read.el ends here
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 4/7] emacs: Buttonize licenses in "Package Info".
  2016-01-22  8:19 [PATCH 0/7]: Add "M-x guix-licenses" and friends Alex Kost
                   ` (2 preceding siblings ...)
  2016-01-22  8:19 ` [PATCH 3/7] emacs: Add 'guix-browse-license-url' command Alex Kost
@ 2016-01-22  8:19 ` Alex Kost
  2016-01-23 17:14   ` Ludovic Courtès
  2016-01-22  8:19 ` [PATCH 5/7] emacs: Add 'guix-packages-by-license' command Alex Kost
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Alex Kost @ 2016-01-22  8:19 UTC (permalink / raw)
  To: guix-devel

* emacs/guix-ui-package.el (guix-package-license): New button type.
  (guix-package-info-format, guix-output-info-format): Use it.
* doc/emacs.texi (Emacs Info buffer): Mention it.
---
 doc/emacs.texi           |  1 +
 emacs/guix-ui-package.el | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index eb470ab..d321a89 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -355,6 +355,7 @@ emacs, The GNU Emacs Manual}) which can be used to:
 @item install/remove a package;
 @item jump to a package location;
 @item browse home page of a package;
+@item browse license URL;
 @item describe packages from ``Inputs'' fields.
 @end itemize
 
diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el
index 2951452..655ed74 100644
--- a/emacs/guix-ui-package.el
+++ b/emacs/guix-ui-package.el
@@ -35,6 +35,7 @@
 (require 'guix-entry)
 (require 'guix-utils)
 (require 'guix-hydra-build)
+(require 'guix-license)
 
 (guix-ui-define-entry-type package)
 (guix-ui-define-entry-type output)
@@ -220,7 +221,7 @@ ENTRIES is a list of package entries to get info about packages."
             (source simple guix-package-info-insert-source)
             (location format (format guix-package-location))
             (home-url format (format guix-url))
-            (license format (format guix-package-info-license))
+            (license format (format guix-package-license))
             (systems format guix-package-info-insert-systems)
             (inputs format (format guix-package-input))
             (native-inputs format (format guix-package-native-input))
@@ -338,6 +339,13 @@ formatted with this string, an action button is inserted.")
   'action (lambda (btn)
             (guix-find-location (button-label btn))))
 
+(define-button-type 'guix-package-license
+  :supertype 'guix
+  'face 'guix-package-info-license
+  'help-echo "Browse license URL"
+  'action (lambda (btn)
+            (guix-browse-license-url (button-label btn))))
+
 (define-button-type 'guix-package-name
   :supertype 'guix
   'face 'guix-package-info-name-button
@@ -767,7 +775,7 @@ for all ARGS."
             (dependencies simple (indent guix-file))
             (location format (format guix-package-location))
             (home-url format (format guix-url))
-            (license format (format guix-package-info-license))
+            (license format (format guix-package-license))
             (systems format guix-package-info-insert-systems)
             (inputs format (format guix-package-input))
             (native-inputs format (format guix-package-native-input))
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 5/7] emacs: Add 'guix-packages-by-license' command.
  2016-01-22  8:19 [PATCH 0/7]: Add "M-x guix-licenses" and friends Alex Kost
                   ` (3 preceding siblings ...)
  2016-01-22  8:19 ` [PATCH 4/7] emacs: Buttonize licenses in "Package Info" Alex Kost
@ 2016-01-22  8:19 ` Alex Kost
  2016-01-23 17:15   ` Ludovic Courtès
  2016-01-22  8:19 ` [PATCH 6/7] emacs: list: Support displaying URL links Alex Kost
  2016-01-22  8:19 ` [PATCH 7/7] emacs: Add interface for licenses Alex Kost
  6 siblings, 1 reply; 21+ messages in thread
From: Alex Kost @ 2016-01-22  8:19 UTC (permalink / raw)
  To: guix-devel

* emacs/guix-main.scm (packages-by-license): New procedure.
(%patterns-makers): Add 'license' search type.
* emacs/guix-messages.el (guix-message-packages-by-license): New procedure.
(guix-messages): Use it.
* emacs/guix-ui-package.el (guix-packages-by-license): New command.
* doc/emacs.texi (Emacs Commands): Document it.
---
 doc/emacs.texi           |  3 +++
 emacs/guix-main.scm      | 11 +++++++++++
 emacs/guix-messages.el   | 15 +++++++++++++++
 emacs/guix-ui-package.el | 12 ++++++++++++
 4 files changed, 41 insertions(+)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index d321a89..e72a386 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -158,6 +158,9 @@ but cannot be found among available packages).
 @item M-x guix-packages-by-name
 Display package(s) with the specified name.
 
+@item M-x guix-packages-by-license
+Display package(s) with the specified license.
+
 @item M-x guix-search-by-regexp
 Search for packages by a specified regexp.  By default ``name'',
 ``synopsis'' and ``description'' of the packages will be searched.  This
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 7706921..c39501d 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -403,6 +403,12 @@ MATCH-PARAMS is a list of parameters that REGEXP can match."
   (let ((re (make-regexp regexp regexp/icase)))
     (matching-packages (cut package-match? <> re))))
 
+(define (packages-by-license license)
+  "Return a list of packages with LICENSE."
+  (matching-packages
+   (lambda (package)
+     (memq license (list-maybe (package-license package))))))
+
 (define (all-available-packages)
   "Return a list of all available packages."
   (matching-packages (const #t)))
@@ -663,6 +669,9 @@ ENTRIES is a list of installed manifest entries."
          (manifest-output-proc  (apply-to-first manifest-output-patterns))
          (regexp-proc           (lambda (_ regexp params . __)
                                   (packages-by-regexp regexp params)))
+         (license-proc          (lambda (_ license-name)
+                                  (packages-by-license
+                                   (license-name->license license-name))))
          (all-proc              (lambda _ (all-available-packages)))
          (newest-proc           (lambda _ (newest-available-packages))))
     `((package
@@ -671,6 +680,7 @@ ENTRIES is a list of installed manifest entries."
        (installed        . ,manifest-package-proc)
        (obsolete         . ,(apply-to-first obsolete-package-patterns))
        (regexp           . ,regexp-proc)
+       (license          . ,license-proc)
        (all-available    . ,all-proc)
        (newest-available . ,newest-proc))
       (output
@@ -679,6 +689,7 @@ ENTRIES is a list of installed manifest entries."
        (installed        . ,manifest-output-proc)
        (obsolete         . ,(apply-to-first obsolete-output-patterns))
        (regexp           . ,regexp-proc)
+       (license          . ,license-proc)
        (all-available    . ,all-proc)
        (newest-available . ,newest-proc)))))
 
diff --git a/emacs/guix-messages.el b/emacs/guix-messages.el
index c4f15dc..de0331f 100644
--- a/emacs/guix-messages.el
+++ b/emacs/guix-messages.el
@@ -36,6 +36,10 @@
      (name
       ,(lambda (_ entries names)
          (guix-message-packages-by-name entries 'package names)))
+     (license
+      ,(lambda (_ entries licenses)
+         (apply #'guix-message-packages-by-license
+                entries 'package licenses)))
      (regexp
       (0 "No packages matching '%s'." val)
       (1 "A single package matching '%s'." val)
@@ -64,6 +68,10 @@
      (name
       ,(lambda (_ entries names)
          (guix-message-packages-by-name entries 'output names)))
+     (license
+      ,(lambda (_ entries licenses)
+         (apply #'guix-message-packages-by-license
+                entries 'output licenses)))
      (regexp
       (0 "No package outputs matching '%s'." val)
       (1 "A single package output matching '%s'." val)
@@ -159,6 +167,13 @@ Try \"M-x guix-search-by-name\"."
                             (guix-message-string-name (car names))))))
     (message "%s %s." str-beg str-end)))
 
+(defun guix-message-packages-by-license (entries entry-type license)
+  "Display a message for packages or outputs searched by LICENSE."
+  (let* ((count (length entries))
+         (str-beg (guix-message-string-entries count entry-type))
+         (str-end (format "with license '%s'" license)))
+    (message "%s %s." str-beg str-end)))
+
 (defun guix-message-generations-by-time (profile entries times)
   "Display a message for generations searched by TIMES."
   (let* ((count (length entries))
diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el
index 655ed74..414bc9b 100644
--- a/emacs/guix-ui-package.el
+++ b/emacs/guix-ui-package.el
@@ -35,6 +35,7 @@
 (require 'guix-entry)
 (require 'guix-utils)
 (require 'guix-hydra-build)
+(require 'guix-read)
 (require 'guix-license)
 
 (guix-ui-define-entry-type package)
@@ -933,6 +934,17 @@ Interactively with prefix, prompt for PROFILE."
   (guix-package-get-display profile 'name name))
 
 ;;;###autoload
+(defun guix-packages-by-license (license &optional profile)
+  "Display Guix packages with LICENSE.
+LICENSE is a license name string.
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
+  (interactive
+   (list (guix-read-license-name)
+         (guix-ui-read-profile)))
+  (guix-package-get-display profile 'license license))
+
+;;;###autoload
 (defun guix-search-by-regexp (regexp &optional params profile)
   "Search for Guix packages by REGEXP.
 PARAMS are package parameters that should be searched.
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 6/7] emacs: list: Support displaying URL links.
  2016-01-22  8:19 [PATCH 0/7]: Add "M-x guix-licenses" and friends Alex Kost
                   ` (4 preceding siblings ...)
  2016-01-22  8:19 ` [PATCH 5/7] emacs: Add 'guix-packages-by-license' command Alex Kost
@ 2016-01-22  8:19 ` Alex Kost
  2016-01-23 17:15   ` Ludovic Courtès
  2016-01-22  8:19 ` [PATCH 7/7] emacs: Add interface for licenses Alex Kost
  6 siblings, 1 reply; 21+ messages in thread
From: Alex Kost @ 2016-01-22  8:19 UTC (permalink / raw)
  To: guix-devel

* emacs/guix-list.el (guix-list-url): New face.
  (guix-list-get-url): New procedure.
---
 emacs/guix-list.el | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index 51eb106..c91c67c 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -38,6 +38,11 @@
   "Face used for file names."
   :group 'guix-list-faces)
 
+(defface guix-list-url
+  '((t :inherit guix-info-url))
+  "Face used for URLs."
+  :group 'guix-list-faces)
+
 (defface guix-list-time
   '((t :inherit guix-info-time))
   "Face used for time stamps."
@@ -222,6 +227,14 @@ VAL may be nil."
         'follow-link t
         'help-echo "Find file"))
 
+(defun guix-list-get-url (url &optional _)
+  "Return URL button specification for `tabulated-list-entries'."
+  (list url
+        'face 'guix-list-url
+        'action (lambda (btn) (browse-url (button-label btn)))
+        'follow-link t
+        'help-echo "Browse URL"))
+
 \f
 ;;; 'List' lines
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 7/7] emacs: Add interface for licenses.
  2016-01-22  8:19 [PATCH 0/7]: Add "M-x guix-licenses" and friends Alex Kost
                   ` (5 preceding siblings ...)
  2016-01-22  8:19 ` [PATCH 6/7] emacs: list: Support displaying URL links Alex Kost
@ 2016-01-22  8:19 ` Alex Kost
  2016-01-23 17:17   ` Ludovic Courtès
  6 siblings, 1 reply; 21+ messages in thread
From: Alex Kost @ 2016-01-22  8:19 UTC (permalink / raw)
  To: guix-devel

* emacs/guix-main.scm (%license-param-alist): New variable.
  (license->sexp, find-licenses, license-entries): New procedures.
* emacs/guix-license.el (guix-license-get-entries)
  (guix-license-get-display, guix-license-insert-packages-button)
  (guix-license-insert-comment, guix-license-list-describe)
  (guix-license-list-show-packages): New procedures.
  (guix-licenses): New command.
* doc/emacs.texi (Emacs Licenses): New node.
  (Emacs Interface): Add it.
* doc/guix.texi (Top): Add it.
* NEWS: Mention new interface.
---
 NEWS                  |  1 +
 doc/emacs.texi        | 22 +++++++++++++
 doc/guix.texi         |  1 +
 emacs/guix-license.el | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++
 emacs/guix-main.scm   | 22 +++++++++++++
 5 files changed, 132 insertions(+)

diff --git a/NEWS b/NEWS
index b27ebc7..010789e 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Please send Guix bug reports to bug-guix@gnu.org.
 
 ** Package management
 
+*** Emacs interface for licenses
 *** Emacs interface for system generations
 *** Emacs interface for hydra.gnu.org
 *** Changes in Emacs interface variables and faces
diff --git a/doc/emacs.texi b/doc/emacs.texi
index e72a386..2fa28c9 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -9,6 +9,7 @@ Guix convenient and fun.
 @menu
 * Initial Setup: Emacs Initial Setup.	Preparing @file{~/.emacs}.
 * Package Management: Emacs Package Management.	Managing packages and generations.
+* Licenses: Emacs Licenses.		Interface for licenses of Guix packages.
 * Popup Interface: Emacs Popup Interface.	Magit-like interface for guix commands.
 * Prettify Mode: Emacs Prettify.	Abbreviating @file{/gnu/store/@dots{}} file names.
 * Build Log Mode: Emacs Build Log.	Highlighting Guix build logs.
@@ -520,6 +521,27 @@ Various settings for ``info'' buffers.
 @end table
 
 
+@node Emacs Licenses
+@section Licenses
+
+If you want to browse an URL of a particular license, or to look at a
+list of licenses, you may use the following commands:
+
+@table @kbd
+
+@item M-x guix-browse-license-url
+Choose a license from a completion list to browse its URL using
+@code{browse-url} function (@pxref{Browse-URL,,, emacs, The GNU Emacs
+Manual}).
+
+@item M-x guix-licenses
+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}).
+
+@end table
+
+
 @node Emacs Popup Interface
 @section Popup Interface
 
diff --git a/doc/guix.texi b/doc/guix.texi
index 592ec3c..1f513da 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -111,6 +111,7 @@ Emacs Interface
 
 * Initial Setup: Emacs Initial Setup.	Preparing @file{~/.emacs}.
 * Package Management: Emacs Package Management.	Managing packages and generations.
+* Licenses: Emacs Licenses.		Interface for licenses of Guix packages.
 * Popup Interface: Emacs Popup Interface.	Magit-like interface for guix commands.
 * Prettify Mode: Emacs Prettify.	Abbreviating @file{/gnu/store/@dots{}} file names.
 * Build Log Mode: Emacs Build Log.	Highlighting Guix build logs.
diff --git a/emacs/guix-license.el b/emacs/guix-license.el
index a28b45e..5904979 100644
--- a/emacs/guix-license.el
+++ b/emacs/guix-license.el
@@ -23,22 +23,108 @@
 
 ;;; Code:
 
+(require 'guix-buffer)
+(require 'guix-list)
+(require 'guix-info)
 (require 'guix-read)
 (require 'guix-backend)
 (require 'guix-guile)
 
+(guix-define-entry-type license)
+
 (defun guix-license-name->url (license)
   "Return URL of a LICENSE."
   (or (guix-eval-read (guix-make-guile-expression
                        'license-name->uri license))
       (error "Hm, I don't know URL of '%s' license" license)))
 
+(defun guix-license-get-entries (search-type &rest args)
+  "Receive 'license' entries.
+SEARCH-TYPE may be one of the following symbols: `all', `id', `name'."
+  (guix-eval-read
+   (apply #'guix-make-guile-expression
+          'license-entries search-type args)))
+
+(defun guix-license-get-display (search-type &rest args)
+  "Search for licenses and show results."
+  (apply #'guix-list-get-display-entries
+         'license search-type args))
+
+\f
+;;; License 'info'
+
+(guix-info-define-interface license
+  :buffer-name "*Guix License Info*"
+  :get-entries-function 'guix-license-get-entries
+  :format '((name ignore (simple guix-info-heading))
+            ignore
+            guix-license-insert-packages-button
+            (url ignore (simple guix-url))
+            guix-license-insert-comment)
+  :titles '((url . "URL")))
+
+(declare-function guix-packages-by-license "guix-ui-package")
+
+(defun guix-license-insert-packages-button (entry)
+  "Insert button to display packages by license ENTRY."
+  (guix-info-insert-action-button
+   "Packages"
+   (lambda (btn)
+     (guix-packages-by-license (button-get btn 'license)))
+   "Show packages with this license"
+   'license (guix-entry-value entry 'name)))
+
+(defun guix-license-insert-comment (entry)
+  "Insert 'comment' of a license ENTRY."
+  (let ((comment (guix-entry-value entry 'comment)))
+    (if (and comment
+             (string-match-p "^http" comment))
+        (guix-info-insert-value-simple comment 'guix-url)
+      (guix-info-insert-title-simple
+       (guix-info-param-title 'license 'comment))
+      (guix-info-insert-value-indent comment))))
+
+\f
+;;; License 'list'
+
+(guix-list-define-interface license
+  :buffer-name "*Guix Licenses*"
+  :get-entries-function 'guix-license-get-entries
+  :describe-function 'guix-license-list-describe
+  :format '((name nil 40 t)
+            (url guix-list-get-url 50 t))
+  :titles '((name . "License"))
+  :sort-key '(name))
+
+(let ((map guix-license-list-mode-map))
+  (define-key map (kbd "RET") 'guix-license-list-show-packages))
+
+(defun guix-license-list-describe (ids)
+  "Describe licenses with IDS (list of identifiers)."
+  (guix-buffer-display-entries
+   (guix-entries-by-ids ids (guix-buffer-current-entries))
+   'info 'license (cl-list* 'id ids) 'add))
+
+(defun guix-license-list-show-packages ()
+  "Display packages with the license at point."
+  (interactive)
+  (guix-packages-by-license (guix-list-current-id)))
+
+\f
+;;; Interactive commands
+
 ;;;###autoload
 (defun guix-browse-license-url (license)
   "Browse URL of a LICENSE."
   (interactive (list (guix-read-license-name)))
   (browse-url (guix-license-name->url license)))
 
+;;;###autoload
+(defun guix-licenses ()
+  "Display licenses of the Guix packages."
+  (interactive)
+  (guix-license-get-display 'all))
+
 (provide 'guix-license)
 
 ;;; guix-license.el ends here
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index c39501d..b2f307a 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -1071,3 +1071,25 @@ Return #t if the shell command was executed successfully."
 (define (license-name->uri name)
   (and=> (license-name->license name)
          license-uri))
+
+(define %license-param-alist
+  `((id      . ,license-name)
+    (name    . ,license-name)
+    (url     . ,license-uri)
+    (comment . ,license-comment)))
+
+(define license->sexp
+  (object-transformer %license-param-alist))
+
+(define (find-licenses search-type . search-values)
+  "Return a list of licenses depending on SEARCH-TYPE and SEARCH-VALUES."
+  (case search-type
+    ((id name)
+     (let ((names search-values))
+       (filter-map license-name->license names)))
+    ((all)
+     %licenses)))
+
+(define (license-entries search-type . search-values)
+  (map license->sexp
+       (apply find-licenses search-type search-values)))
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/7] emacs: Rename 'file-path' to 'file-name'.
  2016-01-22  8:19 ` [PATCH 1/7] emacs: Rename 'file-path' to 'file-name' Alex Kost
@ 2016-01-23 17:06   ` Ludovic Courtès
  0 siblings, 0 replies; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-23 17:06 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-info.el (guix-info-file-path): Rename to...
>   (guix-info-file-name): ... this.
> * emacs/guix-list.el (guix-list-file-path): Rename to...
>   (guix-list-file-name): ... this.
>   (guix-list-get-file-path): Rename to...
>   (guix-list-get-file-name): ... this.
> * emacs/guix-ui-generation.el (guix-generation-list-format): Adjust
>   accordingly.
> * emacs/guix-ui-system-generation.el (guix-system-generation-list-format):
>   Likewise.
> * NEWS: Mention faces renaming.

I support the change!  :-)

Ludo’.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/7] licenses: Add a list of licenses.
  2016-01-22  8:19 ` [PATCH 2/7] licenses: Add a list of licenses Alex Kost
@ 2016-01-23 17:08   ` Ludovic Courtès
  2016-01-23 22:37     ` Alex Kost
  0 siblings, 1 reply; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-23 17:08 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * guix/licenses.scm (%licenses): New variable.

For the purposes of this patch set, I think we’d rather avoid that, and
instead do something like:

    (module-map (lambda (sym var)
                  (variable-ref var))
                (resolve-interface '(guix licenses)))

WDYT?

Ludo’.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/7] emacs: Add 'guix-browse-license-url' command.
  2016-01-22  8:19 ` [PATCH 3/7] emacs: Add 'guix-browse-license-url' command Alex Kost
@ 2016-01-23 17:13   ` Ludovic Courtès
  2016-01-25 19:18     ` Alex Kost
  2016-01-23 17:18   ` Ludovic Courtès
  1 sibling, 1 reply; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-23 17:13 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-main.scm (license-names, license-name->license)
>   (license-name->uri): New procedures.
> * emacs/guix-read.el (guix-license-names, guix-read-license-name): New
>   procedures.
> * emacs/guix-license.el: New file.
> * emacs.am (ELFILES): Add it.

[...]

> +;;; Licenses

I’d do:

  (define %licenses
    (delay (module-map thing from previous message…)))

> +(define (license-names)
> +  "Return a list of names of available licenses."
> +  (map license-name %licenses))

So here it’d become: (force %licenses).

Other than that, LGTM!

Ludo’.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/7] emacs: Buttonize licenses in "Package Info".
  2016-01-22  8:19 ` [PATCH 4/7] emacs: Buttonize licenses in "Package Info" Alex Kost
@ 2016-01-23 17:14   ` Ludovic Courtès
  0 siblings, 0 replies; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-23 17:14 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-ui-package.el (guix-package-license): New button type.
>   (guix-package-info-format, guix-output-info-format): Use it.
> * doc/emacs.texi (Emacs Info buffer): Mention it.

OK!

Ludo’.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/7] emacs: Add 'guix-packages-by-license' command.
  2016-01-22  8:19 ` [PATCH 5/7] emacs: Add 'guix-packages-by-license' command Alex Kost
@ 2016-01-23 17:15   ` Ludovic Courtès
  0 siblings, 0 replies; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-23 17:15 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-main.scm (packages-by-license): New procedure.
> (%patterns-makers): Add 'license' search type.
> * emacs/guix-messages.el (guix-message-packages-by-license): New procedure.
> (guix-messages): Use it.
> * emacs/guix-ui-package.el (guix-packages-by-license): New command.
> * doc/emacs.texi (Emacs Commands): Document it.

OK!

Ludo'.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 6/7] emacs: list: Support displaying URL links.
  2016-01-22  8:19 ` [PATCH 6/7] emacs: list: Support displaying URL links Alex Kost
@ 2016-01-23 17:15   ` Ludovic Courtès
  0 siblings, 0 replies; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-23 17:15 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-list.el (guix-list-url): New face.
>   (guix-list-get-url): New procedure.

OK

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 7/7] emacs: Add interface for licenses.
  2016-01-22  8:19 ` [PATCH 7/7] emacs: Add interface for licenses Alex Kost
@ 2016-01-23 17:17   ` Ludovic Courtès
  0 siblings, 0 replies; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-23 17:17 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-main.scm (%license-param-alist): New variable.
>   (license->sexp, find-licenses, license-entries): New procedures.
> * emacs/guix-license.el (guix-license-get-entries)
>   (guix-license-get-display, guix-license-insert-packages-button)
>   (guix-license-insert-comment, guix-license-list-describe)
>   (guix-license-list-show-packages): New procedures.
>   (guix-licenses): New command.
> * doc/emacs.texi (Emacs Licenses): New node.
>   (Emacs Interface): Add it.
> * doc/guix.texi (Top): Add it.
> * NEWS: Mention new interface.

[...]

> +@node Emacs Licenses
> +@section Licenses
> +
> +If you want to browse an URL of a particular license, or to look at a

s/an URL/the URL/

> +list of licenses, you may use the following commands:
> +
> +@table @kbd
> +
> +@item M-x guix-browse-license-url
> +Choose a license from a completion list to browse its URL using
> +@code{browse-url} function (@pxref{Browse-URL,,, emacs, The GNU Emacs
> +Manual}).
> +
> +@item M-x guix-licenses
> +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}).
> +
> +@end table

Otherwise LGTM!  This is going to be very useful for packagers.

Thank you for the great idea!

Ludo’.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/7] emacs: Add 'guix-browse-license-url' command.
  2016-01-22  8:19 ` [PATCH 3/7] emacs: Add 'guix-browse-license-url' command Alex Kost
  2016-01-23 17:13   ` Ludovic Courtès
@ 2016-01-23 17:18   ` Ludovic Courtès
  2016-01-23 22:49     ` Alex Kost
  1 sibling, 1 reply; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-23 17:18 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> +(define license-name->license

I just realized that I’d rather call it ‘lookup-license’ for
consistency, because it’s not a conversion.

Ludo’.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/7] licenses: Add a list of licenses.
  2016-01-23 17:08   ` Ludovic Courtès
@ 2016-01-23 22:37     ` Alex Kost
  2016-01-24 20:59       ` Ludovic Courtès
  0 siblings, 1 reply; 21+ messages in thread
From: Alex Kost @ 2016-01-23 22:37 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2016-01-23 20:08 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> * guix/licenses.scm (%licenses): New variable.
>
> For the purposes of this patch set, I think we’d rather avoid that, and
> instead do something like:
>
>     (module-map (lambda (sym var)
>                   (variable-ref var))
>                 (resolve-interface '(guix licenses)))
>
> WDYT?

Oh, great, I didn't know about 'module-map', thanks!  But since there
are also things like 'license?' or 'license-uri' in this module, we need
to ignore objects which are not licenses.  Would it be ok to do it like
this:

  (hash-fold (lambda (sym var res)
               (let ((object (variable-ref var)))
                 (if (license? object)
                     (cons object res)
                     res)))
             '()
             (module-obarray (resolve-interface '(guix licenses))))

or is there a more idiomatic way?

-- 
Alex

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/7] emacs: Add 'guix-browse-license-url' command.
  2016-01-23 17:18   ` Ludovic Courtès
@ 2016-01-23 22:49     ` Alex Kost
  2016-01-24 21:00       ` Ludovic Courtès
  0 siblings, 1 reply; 21+ messages in thread
From: Alex Kost @ 2016-01-23 22:49 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2016-01-23 20:18 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> +(define license-name->license
>
> I just realized that I’d rather call it ‘lookup-license’ for
> consistency, because it’s not a conversion.

OK, I'll rename it, and what about:

(define (license-name->uri name)
  (and=> (license-name->license name)
         license-uri))

Should it be called ‘lookup-license-uri’ maybe?

-- 
Alex

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/7] licenses: Add a list of licenses.
  2016-01-23 22:37     ` Alex Kost
@ 2016-01-24 20:59       ` Ludovic Courtès
  0 siblings, 0 replies; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-24 20:59 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2016-01-23 20:08 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
>>
>>> * guix/licenses.scm (%licenses): New variable.
>>
>> For the purposes of this patch set, I think we’d rather avoid that, and
>> instead do something like:
>>
>>     (module-map (lambda (sym var)
>>                   (variable-ref var))
>>                 (resolve-interface '(guix licenses)))
>>
>> WDYT?
>
> Oh, great, I didn't know about 'module-map', thanks!  But since there
> are also things like 'license?' or 'license-uri' in this module, we need
> to ignore objects which are not licenses.  Would it be ok to do it like
> this:
>
>   (hash-fold (lambda (sym var res)
>                (let ((object (variable-ref var)))
>                  (if (license? object)
>                      (cons object res)
>                      res)))
>              '()
>              (module-obarray (resolve-interface '(guix licenses))))
>
> or is there a more idiomatic way?

Good point.  I’d rather write it as:

  (filter license? (module-map …))

(‘module-obarray’ is an implementation detail that may not be here
forever.)

Ludo’.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/7] emacs: Add 'guix-browse-license-url' command.
  2016-01-23 22:49     ` Alex Kost
@ 2016-01-24 21:00       ` Ludovic Courtès
  0 siblings, 0 replies; 21+ messages in thread
From: Ludovic Courtès @ 2016-01-24 21:00 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2016-01-23 20:18 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
>>
>>> +(define license-name->license
>>
>> I just realized that I’d rather call it ‘lookup-license’ for
>> consistency, because it’s not a conversion.
>
> OK, I'll rename it, and what about:
>
> (define (license-name->uri name)
>   (and=> (license-name->license name)
>          license-uri))
>
> Should it be called ‘lookup-license-uri’ maybe?

Sounds good.

Ludo’.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/7] emacs: Add 'guix-browse-license-url' command.
  2016-01-23 17:13   ` Ludovic Courtès
@ 2016-01-25 19:18     ` Alex Kost
  0 siblings, 0 replies; 21+ messages in thread
From: Alex Kost @ 2016-01-25 19:18 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2016-01-23 20:13 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> * emacs/guix-main.scm (license-names, license-name->license)
>>   (license-name->uri): New procedures.
>> * emacs/guix-read.el (guix-license-names, guix-read-license-name): New
>>   procedures.
>> * emacs/guix-license.el: New file.
>> * emacs.am (ELFILES): Add it.
>
> [...]
>
>> +;;; Licenses
>
> I’d do:
>
>   (define %licenses
>     (delay (module-map thing from previous message…)))
>
>> +(define (license-names)
>> +  "Return a list of names of available licenses."
>> +  (map license-name %licenses))
>
> So here it’d become: (force %licenses).
>
> Other than that, LGTM!

I used delay/force and "(filter license? (module-map …))" advice from
the other message and pushed this patchset.  Thank you for your very
useful and informative comments!

-- 
Alex

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2016-01-25 19:18 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-22  8:19 [PATCH 0/7]: Add "M-x guix-licenses" and friends Alex Kost
2016-01-22  8:19 ` [PATCH 1/7] emacs: Rename 'file-path' to 'file-name' Alex Kost
2016-01-23 17:06   ` Ludovic Courtès
2016-01-22  8:19 ` [PATCH 2/7] licenses: Add a list of licenses Alex Kost
2016-01-23 17:08   ` Ludovic Courtès
2016-01-23 22:37     ` Alex Kost
2016-01-24 20:59       ` Ludovic Courtès
2016-01-22  8:19 ` [PATCH 3/7] emacs: Add 'guix-browse-license-url' command Alex Kost
2016-01-23 17:13   ` Ludovic Courtès
2016-01-25 19:18     ` Alex Kost
2016-01-23 17:18   ` Ludovic Courtès
2016-01-23 22:49     ` Alex Kost
2016-01-24 21:00       ` Ludovic Courtès
2016-01-22  8:19 ` [PATCH 4/7] emacs: Buttonize licenses in "Package Info" Alex Kost
2016-01-23 17:14   ` Ludovic Courtès
2016-01-22  8:19 ` [PATCH 5/7] emacs: Add 'guix-packages-by-license' command Alex Kost
2016-01-23 17:15   ` Ludovic Courtès
2016-01-22  8:19 ` [PATCH 6/7] emacs: list: Support displaying URL links Alex Kost
2016-01-23 17:15   ` Ludovic Courtès
2016-01-22  8:19 ` [PATCH 7/7] emacs: Add interface for licenses Alex Kost
2016-01-23 17:17   ` 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).