gnu: Add emacs-undercover.
[jackhill/guix/guix.git] / emacs / guix-ui-system-generation.el
CommitLineData
67cedc4b
AK
1;;; guix-ui-system-generation.el --- Interface for displaying system generations -*- lexical-binding: t -*-
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 License as published by
9;; the Free Software Foundation, either version 3 of the License, 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 License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;; This file provides an interface for displaying system generations
23;; in 'list' and 'info' buffers, and commands for working with them.
24
25;;; Code:
26
27(require 'cl-lib)
28(require 'guix-list)
29(require 'guix-ui)
30(require 'guix-ui-generation)
31(require 'guix-profiles)
32
33(guix-ui-define-entry-type system-generation)
34
35(defun guix-system-generation-get-display (search-type &rest search-values)
36 "Search for system generations and show results.
37See `guix-ui-get-entries' for the meaning of SEARCH-TYPE and
38SEARCH-VALUES."
39 (apply #'guix-list-get-display-entries
40 'system-generation
41 guix-system-profile
42 search-type search-values))
43
44\f
45;;; System generation 'info'
46
47(guix-ui-info-define-interface system-generation
48 :buffer-name "*Guix Generation Info*"
49 :format '((number format guix-generation-info-insert-number)
50 (label format (format))
51 (prev-number format (format))
52 (current format guix-generation-info-insert-current)
53 (path format (format guix-file))
54 (time format (time))
55 (root-device format (format))
56 (kernel format (format guix-file)))
57 :titles guix-generation-info-titles)
58
59\f
60;;; System generation 'list'
61
62;; FIXME It is better to make `guix-generation-list-shared-map' with
63;; common keys for both usual and system generations.
64(defvar guix-system-generation-list-mode-map
65 (copy-keymap guix-generation-list-mode-map)
66 "Keymap for `guix-system-generation-list-mode' buffers.")
67
68(guix-ui-list-define-interface system-generation
69 :buffer-name "*Guix Generation List*"
70 :format '((number nil 5 guix-list-sort-numerically-0 :right-align t)
71 (current guix-generation-list-get-current 10 t)
72 (label nil 40 t)
73 (time guix-list-get-time 20 t)
0a2a2b33 74 (path guix-list-get-file-name 30 t))
67cedc4b
AK
75 :titles guix-generation-list-titles
76 :sort-key '(number . t)
77 :marks '((delete . ?D)))
78
79\f
80;;; Interactive commands
81
82;;;###autoload
83(defun guix-system-generations ()
84 "Display information about system generations."
85 (interactive)
86 (guix-system-generation-get-display 'all))
87
88;;;###autoload
89(defun guix-last-system-generations (number)
90 "Display information about last NUMBER of system generations."
91 (interactive "nThe number of last generations: ")
92 (guix-system-generation-get-display 'last number))
93
94;;;###autoload
95(defun guix-system-generations-by-time (from to)
96 "Display information about system generations created between FROM and TO."
97 (interactive
98 (list (guix-read-date "Find generations (from): ")
99 (guix-read-date "Find generations (to): ")))
100 (guix-system-generation-get-display
101 'time (float-time from) (float-time to)))
102
103(provide 'guix-ui-system-generation)
104
105;;; guix-ui-system-generation.el ends here