emacs: Add 'guix-generations-by-time' command.
* emacs/guix-main.scm (find-generations): Add finding generations by time. * emacs/guix-utils.el (guix-read-date): New procedure. * emacs/guix-base.el (guix-messages): Add new messages. * emacs/guix.el (guix-generations-by-time): New command. * doc/emacs.texi (emacs Commands): Document it.master
parent
347e17b474
commit
189cea2782
|
@ -102,6 +102,11 @@ can be changed by modifying @code{guix-search-params} variable.
|
||||||
List generations for the current profile. With numeric prefix, show so
|
List generations for the current profile. With numeric prefix, show so
|
||||||
many last generations.
|
many last generations.
|
||||||
|
|
||||||
|
@item M-x guix-generations-by-time
|
||||||
|
List generations matching time period. You'll be prompted for the
|
||||||
|
period using Org mode time prompt based on Emacs calendar (@pxref{The
|
||||||
|
date/time prompt,,, org, Org Mode Manual}).
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
By default commands for displaying packages display each output on a
|
By default commands for displaying packages display each output on a
|
||||||
|
|
|
@ -626,7 +626,11 @@ This function will not update the information, use
|
||||||
(all
|
(all
|
||||||
(0 "No available generations.")
|
(0 "No available generations.")
|
||||||
(1 "A single available generation.")
|
(1 "A single available generation.")
|
||||||
(many "%d available generations." count)))))
|
(many "%d available generations." count))
|
||||||
|
(time
|
||||||
|
(0 "Generations not found.")
|
||||||
|
(1 "A single generation matching time period.")
|
||||||
|
(many "%d generations matching time period." count)))))
|
||||||
|
|
||||||
(defun guix-result-message (entries entry-type search-type search-vals)
|
(defun guix-result-message (entries entry-type search-type search-vals)
|
||||||
"Display an appropriate message after displaying ENTRIES."
|
"Display an appropriate message after displaying ENTRIES."
|
||||||
|
|
|
@ -669,6 +669,15 @@ If NUMBER is 0 or less, return all generations."
|
||||||
(last-generations profile (car search-vals)))
|
(last-generations profile (car search-vals)))
|
||||||
((all)
|
((all)
|
||||||
(last-generations profile +inf.0))
|
(last-generations profile +inf.0))
|
||||||
|
((time)
|
||||||
|
(match search-vals
|
||||||
|
((from to)
|
||||||
|
(matching-generations
|
||||||
|
profile
|
||||||
|
(lambda (gen)
|
||||||
|
(let ((time (time-second (generation-time profile gen))))
|
||||||
|
(< from time to)))))
|
||||||
|
(_ '())))
|
||||||
(else (search-type-error "generation" search-type))))
|
(else (search-type-error "generation" search-type))))
|
||||||
|
|
||||||
(define (generation-sexps profile params search-type search-vals)
|
(define (generation-sexps profile params search-type search-vals)
|
||||||
|
@ -696,7 +705,7 @@ SEARCH-TYPE should be one of the following symbols:
|
||||||
'installed', 'obsolete', 'generation'.
|
'installed', 'obsolete', 'generation'.
|
||||||
|
|
||||||
- If ENTRY-TYPE is 'generation':
|
- If ENTRY-TYPE is 'generation':
|
||||||
'id', 'last', 'all'.
|
'id', 'last', 'all', 'time'.
|
||||||
|
|
||||||
PARAMS is a list of parameters for receiving. If it is an empty list,
|
PARAMS is a list of parameters for receiving. If it is an empty list,
|
||||||
get information with all available parameters, which are:
|
get information with all available parameters, which are:
|
||||||
|
|
|
@ -138,6 +138,14 @@ split it into several short lines."
|
||||||
hist def inherit-input-method)
|
hist def inherit-input-method)
|
||||||
:test #'string=))
|
:test #'string=))
|
||||||
|
|
||||||
|
(declare-function org-read-date "org" t)
|
||||||
|
|
||||||
|
(defun guix-read-date (prompt)
|
||||||
|
"Prompt for a date or time using `org-read-date'.
|
||||||
|
Return time value."
|
||||||
|
(require 'org)
|
||||||
|
(org-read-date nil t nil prompt))
|
||||||
|
|
||||||
(defun guix-get-key-val (alist &rest keys)
|
(defun guix-get-key-val (alist &rest keys)
|
||||||
"Return value from ALIST by KEYS.
|
"Return value from ALIST by KEYS.
|
||||||
ALIST is alist of alists of alists ... which can be consecutively
|
ALIST is alist of alists of alists ... which can be consecutively
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
(require 'guix-base)
|
(require 'guix-base)
|
||||||
(require 'guix-list)
|
(require 'guix-list)
|
||||||
(require 'guix-info)
|
(require 'guix-info)
|
||||||
|
(require 'guix-utils)
|
||||||
|
|
||||||
(defgroup guix nil
|
(defgroup guix nil
|
||||||
"Interface for Guix package manager."
|
"Interface for Guix package manager."
|
||||||
|
@ -134,6 +135,17 @@ Interactively, NUMBER is defined by a numeric prefix."
|
||||||
(guix-get-show-generations 'last number)
|
(guix-get-show-generations 'last number)
|
||||||
(guix-get-show-generations 'all)))
|
(guix-get-show-generations 'all)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun guix-generations-by-time (from to)
|
||||||
|
"Display information about generations created between FROM and TO.
|
||||||
|
FROM and TO should be time values."
|
||||||
|
(interactive
|
||||||
|
(list (guix-read-date "Find generations (from): ")
|
||||||
|
(guix-read-date "Find generations (to): ")))
|
||||||
|
(guix-get-show-generations 'time
|
||||||
|
(float-time from)
|
||||||
|
(float-time to)))
|
||||||
|
|
||||||
(provide 'guix)
|
(provide 'guix)
|
||||||
|
|
||||||
;;; guix.el ends here
|
;;; guix.el ends here
|
||||||
|
|
Reference in New Issue