[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/09: emacs: Separate package license code.
From: |
Alex Kost |
Subject: |
03/09: emacs: Separate package license code. |
Date: |
Mon, 18 Apr 2016 07:13:37 +0000 |
alezost pushed a commit to branch master
in repository guix.
commit 27986d7b192f23eb4185d5ff0135d0a0470cd86a
Author: Alex Kost <address@hidden>
Date: Thu Apr 7 19:07:23 2016 +0300
emacs: Separate package license code.
Move list/info interface code from "guix-license.el" to
"guix-ui-license.el".
* emacs/guix-license.el (guix-license-get-entries, guix-license-get-display)
(guix-license-insert-packages-button, guix-license-insert-comment)
(guix-licenses): Move to...
* emacs/guix-ui-license.el: ... here. New file.
* emacs.am (ELFILES): Add it.
---
emacs.am | 1 +
emacs/guix-license.el | 86 -------------------------
emacs/{guix-license.el => guix-ui-license.el} | 35 ++++-------
3 files changed, 13 insertions(+), 109 deletions(-)
diff --git a/emacs.am b/emacs.am
index c0d294d..f0647d1 100644
--- a/emacs.am
+++ b/emacs.am
@@ -48,6 +48,7 @@ ELFILES = \
emacs/guix-profiles.el \
emacs/guix-read.el \
emacs/guix-ui.el \
+ emacs/guix-ui-license.el \
emacs/guix-ui-package.el \
emacs/guix-ui-generation.el \
emacs/guix-ui-system-generation.el \
diff --git a/emacs/guix-license.el b/emacs/guix-license.el
index a99d7af..940f551 100644
--- a/emacs/guix-license.el
+++ b/emacs/guix-license.el
@@ -23,108 +23,22 @@
;;; 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-lookup-license-url (license)
"Return URL of a LICENSE."
(or (guix-eval-read (guix-make-guile-expression
'lookup-license-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))
-
-
-;;; 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))))
-
-
-;;; 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)))
-
-
-;;; Interactive commands
-
;;;###autoload
(defun guix-browse-license-url (license)
"Browse URL of a LICENSE."
(interactive (list (guix-read-license-name)))
(browse-url (guix-lookup-license-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-license.el b/emacs/guix-ui-license.el
similarity index 80%
copy from emacs/guix-license.el
copy to emacs/guix-ui-license.el
index a99d7af..c5e642f 100644
--- a/emacs/guix-license.el
+++ b/emacs/guix-ui-license.el
@@ -1,4 +1,4 @@
-;;; guix-license.el --- Licenses
+;;; guix-ui-license.el --- Interface for displaying licenses
;; Copyright © 2016 Alex Kost <address@hidden>
@@ -19,25 +19,19 @@
;;; Commentary:
-;; This file provides the code to work with licenses of Guix packages.
+;; This file provides 'list'/'info' interface for displaying licenses of
+;; Guix packages.
;;; 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-lookup-license-url (license)
- "Return URL of a LICENSE."
- (or (guix-eval-read (guix-make-guile-expression
- 'lookup-license-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'."
@@ -67,12 +61,13 @@ SEARCH-TYPE may be one of the following symbols: `all',
`id', `name'."
(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)))
+ (let ((license (guix-entry-value entry 'name)))
+ (guix-info-insert-action-button
+ "Packages"
+ (lambda (btn)
+ (guix-packages-by-license (button-get btn 'license)))
+ (format "Display packages with license '%s'" license)
+ 'license license)))
(defun guix-license-insert-comment (entry)
"Insert 'comment' of a license ENTRY."
@@ -114,17 +109,11 @@ SEARCH-TYPE may be one of the following symbols: `all',
`id', `name'."
;;; Interactive commands
;;;###autoload
-(defun guix-browse-license-url (license)
- "Browse URL of a LICENSE."
- (interactive (list (guix-read-license-name)))
- (browse-url (guix-lookup-license-url license)))
-
-;;;###autoload
(defun guix-licenses ()
"Display licenses of the Guix packages."
(interactive)
(guix-license-get-display 'all))
-(provide 'guix-license)
+(provide 'guix-ui-license)
-;;; guix-license.el ends here
+;;; guix-ui-license.el ends here
- branch master updated (9bb46c1 -> a7c6178), Alex Kost, 2016/04/18
- 05/09: emacs: Make 'guix-find-location' interactive., Alex Kost, 2016/04/18
- 03/09: emacs: Separate package license code.,
Alex Kost <=
- 09/09: emacs: Display license info on button press in Package Info buffer., Alex Kost, 2016/04/18
- 01/09: emacs: Add 'guix-packages-by-location' command., Alex Kost, 2016/04/18
- 06/09: doc: emacs: Add "Package Source Locations" section., Alex Kost, 2016/04/18
- 08/09: emacs: Add location "Packages" button to Package Info buffer., Alex Kost, 2016/04/18
- 07/09: emacs: Add interface for package locations., Alex Kost, 2016/04/18
- 02/09: emacs: Separate package location code., Alex Kost, 2016/04/18
- 04/09: emacs: Display message if license not found., Alex Kost, 2016/04/18