all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Kost <alezost@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 6/6] emacs: Add interface for system generations.
Date: Sun, 10 Jan 2016 12:53:50 +0300	[thread overview]
Message-ID: <1452419630-4399-7-git-send-email-alezost@gmail.com> (raw)
In-Reply-To: <1452419630-4399-1-git-send-email-alezost@gmail.com>

* emacs/guix-main.scm (system-generation-boot-parameters)
(system-generation-param-alist, system-generation-sexps): New procedures.
(entries): Add 'system-generation' entry type.
* emacs/guix-messages.el (guix-result-message): Use the same messages
  for 'generation' and 'system-generation' entry types.
* emacs/guix-ui-system-generation.el: New file.
* emacs.am (ELFILES): Add it.
* doc/emacs.texi (Emacs Commands): Document new commands.
* NEWS: Mention new interface.
---
 NEWS                               |   1 +
 doc/emacs.texi                     |   8 +++
 emacs.am                           |   1 +
 emacs/guix-main.scm                |  36 +++++++++++++
 emacs/guix-messages.el             |   5 +-
 emacs/guix-ui-system-generation.el | 105 +++++++++++++++++++++++++++++++++++++
 6 files changed, 155 insertions(+), 1 deletion(-)
 create mode 100644 emacs/guix-ui-system-generation.el

diff --git a/NEWS b/NEWS
index c35c7d6..0084394 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Please send Guix bug reports to bug-guix@gnu.org.
 
 ** Package management
 
+*** Emacs interface for system generations
 *** Emacs interface for hydra.gnu.org
 *** Changes in Emacs interface variables
 In the following names, BUFFER-TYPE means "info" or "list";
diff --git a/doc/emacs.texi b/doc/emacs.texi
index ea340b1..b2a3d47 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -191,6 +191,14 @@ date/time prompt,,, org, The Org Manual}).
 
 @end table
 
+Analogously on GuixSD you can also display system generations:
+
+@table @kbd
+@item M-x guix-system-generations
+@item M-x guix-last-system-generations
+@item M-x guix-system-generations-by-time
+@end table
+
 You can also invoke the @command{guix pull} command (@pxref{Invoking
 guix pull}) from Emacs using:
 
diff --git a/emacs.am b/emacs.am
index 85165b9..d0d4dfb 100644
--- a/emacs.am
+++ b/emacs.am
@@ -47,6 +47,7 @@ ELFILES =					\
   emacs/guix-ui.el				\
   emacs/guix-ui-package.el			\
   emacs/guix-ui-generation.el			\
+  emacs/guix-ui-system-generation.el		\
   emacs/guix-utils.el
 
 if HAVE_EMACS
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 1199679..4baf2df 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -61,6 +61,7 @@
  (guix scripts lint)
  (guix scripts package)
  (guix scripts pull)
+ (guix scripts system)
  (gnu packages))
 
 (define-syntax-rule (first-or-false lst)
@@ -758,6 +759,38 @@ See 'entry-sexps' for details."
                                     params)))
     (map ->sexp generations)))
 
+(define system-generation-boot-parameters
+  (memoize
+   (lambda (profile generation)
+     "Return boot parameters for PROFILE's system GENERATION."
+     (let* ((gen-file   (generation-file-name profile generation))
+            (param-file (string-append gen-file "/parameters")))
+       (call-with-input-file param-file read-boot-parameters)))))
+
+(define (system-generation-param-alist profile)
+  "Return an alist of system generation parameters and procedures for
+PROFILE."
+  (append (generation-param-alist profile)
+          `((label       . ,(lambda (gen)
+                              (boot-parameters-label
+                               (system-generation-boot-parameters
+                                profile gen))))
+            (root-device . ,(lambda (gen)
+                              (boot-parameters-root-device
+                               (system-generation-boot-parameters
+                                profile gen))))
+            (kernel      . ,(lambda (gen)
+                              (boot-parameters-kernel
+                               (system-generation-boot-parameters
+                                profile gen)))))))
+
+(define (system-generation-sexps profile params search-type search-vals)
+  "Return an alist with information about system generations."
+  (let ((generations (find-generations profile search-type search-vals))
+        (->sexp (object-transformer (system-generation-param-alist profile)
+                                    params)))
+    (map ->sexp generations)))
+
 \f
 ;;; Getting package/output/generation entries (alists).
 
@@ -802,6 +835,9 @@ parameter/value pairs."
     ((generation)
      (generation-sexps profile params
                        search-type search-vals))
+    ((system-generation)
+     (system-generation-sexps profile params
+                              search-type search-vals))
     (else (entry-type-error entry-type))))
 
 \f
diff --git a/emacs/guix-messages.el b/emacs/guix-messages.el
index 9f6d833..c4f15dc 100644
--- a/emacs/guix-messages.el
+++ b/emacs/guix-messages.el
@@ -186,7 +186,10 @@ Try \"M-x guix-search-by-name\"."
                             search-type search-vals)
   "Display an appropriate message after displaying ENTRIES."
   (let* ((type-spec (guix-assq-value guix-messages
-                                     entry-type search-type))
+                                     (if (eq entry-type 'system-generation)
+                                         'generation
+                                       entry-type)
+                                     search-type))
          (fun-or-count-spec (car type-spec)))
     (if (functionp fun-or-count-spec)
         (funcall fun-or-count-spec profile entries search-vals)
diff --git a/emacs/guix-ui-system-generation.el b/emacs/guix-ui-system-generation.el
new file mode 100644
index 0000000..d79f3bc
--- /dev/null
+++ b/emacs/guix-ui-system-generation.el
@@ -0,0 +1,105 @@
+;;; guix-ui-system-generation.el --- Interface for displaying system generations  -*- lexical-binding: t -*-
+
+;; 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 an interface for displaying system generations
+;; in 'list' and 'info' buffers, and commands for working with them.
+
+;;; Code:
+
+(require 'cl-lib)
+(require 'guix-list)
+(require 'guix-ui)
+(require 'guix-ui-generation)
+(require 'guix-profiles)
+
+(guix-ui-define-entry-type system-generation)
+
+(defun guix-system-generation-get-display (search-type &rest search-values)
+  "Search for system generations and show results.
+See `guix-ui-get-entries' for the meaning of SEARCH-TYPE and
+SEARCH-VALUES."
+  (apply #'guix-list-get-display-entries
+         'system-generation
+         guix-system-profile
+         search-type search-values))
+
+\f
+;;; System generation 'info'
+
+(guix-ui-info-define-interface system-generation
+  :buffer-name "*Guix Generation Info*"
+  :format '((number format guix-generation-info-insert-number)
+            (label format (format))
+            (prev-number format (format))
+            (current format guix-generation-info-insert-current)
+            (path format (format guix-file))
+            (time format (time))
+            (root-device format (format))
+            (kernel format (format guix-file)))
+  :titles guix-generation-info-titles)
+
+\f
+;;; System generation 'list'
+
+;; FIXME It is better to make `guix-generation-list-shared-map' with
+;; common keys for both usual and system generations.
+(defvar guix-system-generation-list-mode-map
+  (copy-keymap guix-generation-list-mode-map)
+  "Keymap for `guix-system-generation-list-mode' buffers.")
+
+(guix-ui-list-define-interface system-generation
+  :buffer-name "*Guix Generation List*"
+  :format '((number nil 5 guix-list-sort-numerically-0 :right-align t)
+            (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))
+  :titles guix-generation-list-titles
+  :sort-key '(number . t)
+  :marks '((delete . ?D)))
+
+\f
+;;; Interactive commands
+
+;;;###autoload
+(defun guix-system-generations ()
+  "Display information about system generations."
+  (interactive)
+  (guix-system-generation-get-display 'all))
+
+;;;###autoload
+(defun guix-last-system-generations (number)
+  "Display information about last NUMBER of system generations."
+  (interactive "nThe number of last generations: ")
+  (guix-system-generation-get-display 'last number))
+
+;;;###autoload
+(defun guix-system-generations-by-time (from to)
+  "Display information about system generations created between FROM and TO."
+  (interactive
+   (list (guix-read-date "Find generations (from): ")
+         (guix-read-date "Find generations (to): ")))
+  (guix-system-generation-get-display
+   'time (float-time from) (float-time to)))
+
+(provide 'guix-ui-system-generation)
+
+;;; guix-ui-system-generation.el ends here
-- 
2.6.3

  parent reply	other threads:[~2016-01-10  9:54 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-10  9:53 [PATCH 0/6] emacs: Add "M-x guix-system-generations" Alex Kost
2016-01-10  9:53 ` [PATCH 1/6] guix system: Export <boot-parameters> accessors Alex Kost
2016-01-12 20:25   ` Ludovic Courtès
2016-01-13 20:44     ` Alex Kost
2016-01-13 22:33       ` Ludovic Courtès
2016-01-14  8:34         ` Alex Kost
2016-01-14 13:25           ` Ludovic Courtès
2016-01-10  9:53 ` [PATCH 2/6] emacs: profiles: Add 'guix-system-profile' Alex Kost
2016-01-12 20:25   ` Ludovic Courtès
2016-01-10  9:53 ` [PATCH 3/6] emacs: Find packages in system profiles Alex Kost
2016-01-12 20:28   ` Ludovic Courtès
2016-01-13 20:45     ` Alex Kost
2016-01-13 22:42       ` Ludovic Courtès
2016-01-14  8:38         ` Alex Kost
2016-01-14 13:27           ` Ludovic Courtès
2016-01-10  9:53 ` [PATCH 4/6] emacs: Replace 'generation-diff' search with 'profile-diff' Alex Kost
2016-01-12 20:29   ` Ludovic Courtès
2016-01-10  9:53 ` [PATCH 5/6] emacs: Remove 'generation' search type Alex Kost
2016-01-12 20:31   ` Ludovic Courtès
2016-01-10  9:53 ` Alex Kost [this message]
2016-01-12 20:35   ` [PATCH 6/6] emacs: Add interface for system generations Ludovic Courtès
2016-01-13 20:56     ` Alex Kost
2016-01-13 22:44       ` Ludovic Courtès
2016-01-12 20:23 ` [PATCH 0/6] emacs: Add "M-x guix-system-generations" Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452419630-4399-7-git-send-email-alezost@gmail.com \
    --to=alezost@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.