[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/07: emacs: Add 'guix-packages-by-license' command.
From: |
Alex Kost |
Subject: |
04/07: emacs: Add 'guix-packages-by-license' command. |
Date: |
Mon, 25 Jan 2016 19:17:38 +0000 |
alezost pushed a commit to branch master
in repository guix.
commit 83aab70b2d4d11fa345c1fbf2ccdbec8b7ad6662
Author: Alex Kost <address@hidden>
Date: Wed Jan 20 18:53:19 2016 +0300
emacs: Add 'guix-packages-by-license' command.
* 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(+), 0 deletions(-)
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.
address@hidden 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 0aee206..bec26c7 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
+ (lookup-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.
- branch master updated (8581f4c -> 0833d0c), Alex Kost, 2016/01/25
- 02/07: emacs: Add 'guix-browse-license-url' command., Alex Kost, 2016/01/25
- 05/07: emacs: list: Support displaying URL links., Alex Kost, 2016/01/25
- 04/07: emacs: Add 'guix-packages-by-license' command.,
Alex Kost <=
- 01/07: emacs: Rename 'file-path' to 'file-name'., Alex Kost, 2016/01/25
- 07/07: gnu: aspell-dict-en: Update to 2016.01.19-0., Alex Kost, 2016/01/25
- 06/07: emacs: Add interface for licenses., Alex Kost, 2016/01/25
- 03/07: emacs: Buttonize licenses in "Package Info"., Alex Kost, 2016/01/25