Commit | Line | Data |
---|---|---|
b4b9975d AK |
1 | ;;; guix-ui-location.el --- Interface for displaying package locations |
2 | ||
3 | ;; Copyright © 2016 Alex Kost <alezost@gmail.com> | |
4 | ||
5 | ;; This file is part of GNU Guix. | |
6 | ||
7 | ;; GNU Guix is free software; you can redistribute it and/or modify | |
8 | ;; it under the terms of the GNU General Public Location as published by | |
9 | ;; the Free Software Foundation, either version 3 of the Location, or | |
10 | ;; (at your option) any later version. | |
11 | ||
12 | ;; GNU Guix is distributed in the hope that it will be useful, | |
13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;; GNU General Public Location for more details. | |
16 | ||
17 | ;; You should have received a copy of the GNU General Public Location | |
18 | ;; along with this program. If not, see <http://www.gnu.org/locations/>. | |
19 | ||
20 | ;;; Commentary: | |
21 | ||
22 | ;; This file provides a 'list' interface for displaying locations of Guix | |
23 | ;; packages. | |
24 | ||
25 | ;;; Code: | |
26 | ||
27 | (require 'guix-buffer) | |
28 | (require 'guix-list) | |
29 | (require 'guix-location) | |
30 | (require 'guix-backend) | |
31 | ||
32 | (guix-define-entry-type location) | |
33 | ||
34 | (defun guix-location-get-entries () | |
35 | "Receive 'package location' entries." | |
36 | (guix-eval-read "(package-location-entries)")) | |
37 | ||
38 | \f | |
39 | ;;; Location 'list' | |
40 | ||
41 | (guix-list-define-interface location | |
42 | :buffer-name "*Guix Package Locations*" | |
43 | :get-entries-function 'guix-location-get-entries | |
44 | :format '((location guix-location-list-file-name-specification 50 t) | |
45 | (number-of-packages nil 10 guix-list-sort-numerically-1 | |
46 | :right-align t)) | |
47 | :sort-key '(location)) | |
48 | ||
49 | (let ((map guix-location-list-mode-map)) | |
50 | (define-key map (kbd "RET") 'guix-location-list-show-packages) | |
51 | ;; "Location Info" buffer is not defined (it would be useless), so | |
52 | ;; unbind "i" key (by default, it is used to display Info buffer). | |
53 | (define-key map (kbd "i") nil)) | |
54 | ||
55 | (defun guix-location-list-file-name-specification (location &optional _) | |
56 | "Return LOCATION button specification for `tabulated-list-entries'." | |
57 | (list location | |
58 | 'face 'guix-list-file-name | |
59 | 'action (lambda (btn) | |
60 | (guix-find-location (button-get btn 'location))) | |
61 | 'follow-link t | |
62 | 'help-echo (concat "Find location: " location) | |
63 | 'location location)) | |
64 | ||
65 | (declare-function guix-packages-by-location "guix-ui-package") | |
66 | ||
67 | (defun guix-location-list-show-packages () | |
68 | "Display packages placed in the location at point." | |
69 | (interactive) | |
70 | (guix-packages-by-location (guix-list-current-id))) | |
71 | ||
72 | \f | |
73 | ;;; Interactive commands | |
74 | ||
75 | ;;;###autoload | |
76 | (defun guix-locations () | |
77 | "Display locations of the Guix packages." | |
78 | (interactive) | |
79 | (guix-list-get-display-entries 'location)) | |
80 | ||
81 | (provide 'guix-ui-location) | |
82 | ||
83 | ;;; guix-ui-location.el ends here |