me
/
guix
Archived
1
0
Fork 0

emacs: Replace 'generation-diff' search with 'profile-diff'.

* emacs/guix-main.scm (generation-package-specifications): Rename to...
  (profile-package-specifications): ... this.  Take a single 'profile'
  argument.
  (generation-difference): Rename to...
  (profile-difference): ... this.  Take profiles as arguments.
  (package/output-sexps): Adjust accordingly.
* emacs/guix-ui-generation.el (guix-generation-list-profiles-to-compare):
  New procedure.
  (guix-generation-list-show-added-packages)
  (guix-generation-list-show-removed-packages): Use it.
* emacs/guix-messages.el (guix-messages): Replace 'generation-diff' with
  'profile-diff'.
  (guix-message-outputs-by-diff): Adjust accordingly.
master
Alex Kost 2016-01-04 22:59:04 +03:00
parent 2df17bd0ee
commit 54c3c284d7
3 changed files with 30 additions and 27 deletions

View File

@ -137,10 +137,9 @@ return two values: name and version. For example, for SPEC
(define (manifest-entries->package-specifications entries) (define (manifest-entries->package-specifications entries)
(map manifest-entry->package-specification entries)) (map manifest-entry->package-specification entries))
(define (generation-package-specifications profile number) (define (profile-package-specifications profile)
"Return a list of package specifications for generation NUMBER." "Return a list of package specifications for PROFILE."
(let ((manifest (profile-manifest (let ((manifest (profile-manifest profile)))
(generation-file-name profile number))))
(manifest-entries->package-specifications (manifest-entries->package-specifications
(manifest-entries manifest)))) (manifest-entries manifest))))
@ -153,11 +152,11 @@ Each element of the list is a list of the package specification and its path."
(manifest-entry-item entry))) (manifest-entry-item entry)))
(manifest-entries manifest)))) (manifest-entries manifest))))
(define (generation-difference profile number1 number2) (define (profile-difference profile1 profile2)
"Return a list of package specifications for outputs installed in generation "Return a list of package specifications for outputs installed in PROFILE1
NUMBER1 and not installed in generation NUMBER2." and not installed in PROFILE2."
(let ((specs1 (generation-package-specifications profile number1)) (let ((specs1 (profile-package-specifications profile1))
(specs2 (generation-package-specifications profile number2))) (specs2 (profile-package-specifications profile2)))
(lset-difference string=? specs1 specs2))) (lset-difference string=? specs1 specs2)))
(define (manifest-entries->hash-table entries) (define (manifest-entries->hash-table entries)
@ -698,11 +697,11 @@ See 'entry-sexps' for details."
profile)) profile))
(manifest (profile-manifest profile)) (manifest (profile-manifest profile))
(patterns (if (and (eq? entry-type 'output) (patterns (if (and (eq? entry-type 'output)
(eq? search-type 'generation-diff)) (eq? search-type 'profile-diff))
(match search-vals (match search-vals
((g1 g2) ((p1 p2)
(map specification->output-pattern (map specification->output-pattern
(generation-difference profile g1 g2))) (profile-difference p1 p2)))
(_ '())) (_ '()))
(apply (patterns-maker entry-type search-type) (apply (patterns-maker entry-type search-type)
manifest search-vals))) manifest search-vals)))

View File

@ -98,7 +98,7 @@
val profile) val profile)
(many "%d package outputs installed in generation %d of profile '%s'." (many "%d package outputs installed in generation %d of profile '%s'."
count val profile)) count val profile))
(generation-diff (profile-diff
guix-message-outputs-by-diff)) guix-message-outputs-by-diff))
(generation (generation
@ -183,19 +183,18 @@ Try \"M-x guix-search-by-name\"."
"matching time period '%s' - '%s'.") "matching time period '%s' - '%s'.")
str-beg profile time-beg time-end))) str-beg profile time-beg time-end)))
(defun guix-message-outputs-by-diff (profile entries generations) (defun guix-message-outputs-by-diff (_ entries profiles)
"Display a message for outputs searched by GENERATIONS difference." "Display a message for outputs searched by PROFILES difference."
(let* ((count (length entries)) (let* ((count (length entries))
(str-beg (guix-message-string-entries count 'output)) (str-beg (guix-message-string-entries count 'output))
(gen1 (car generations)) (profile1 (car profiles))
(gen2 (cadr generations))) (profile2 (cadr profiles)))
(cl-multiple-value-bind (new old str-action) (cl-multiple-value-bind (new old str-action)
(if (> gen1 gen2) (if (string-lessp profile2 profile1)
(list gen1 gen2 "added to") (list profile1 profile2 "added to")
(list gen2 gen1 "removed from")) (list profile2 profile1 "removed from"))
(message (concat "%s %s generation %d comparing with " (message "%s %s profile '%s' comparing with profile '%s'."
"generation %d of profile '%s'.") str-beg str-action new old))))
str-beg str-action new old profile))))
(defun guix-result-message (profile entries entry-type (defun guix-result-message (profile entries entry-type
search-type search-vals) search-type search-vals)

View File

@ -212,6 +212,11 @@ VAL is a boolean value."
(user-error "2 generations should be marked for comparing") (user-error "2 generations should be marked for comparing")
(sort numbers #'<)))) (sort numbers #'<))))
(defun guix-generation-list-profiles-to-compare ()
"Return a sorted list of 2 marked generation profiles for comparing."
(mapcar #'guix-generation-current-packages-profile
(guix-generation-list-generations-to-compare)))
(defun guix-generation-list-show-added-packages () (defun guix-generation-list-show-added-packages ()
"List package outputs added to the latest marked generation. "List package outputs added to the latest marked generation.
If 2 generations are marked with \\[guix-list-mark], display If 2 generations are marked with \\[guix-list-mark], display
@ -221,8 +226,8 @@ installed in the other one."
(guix-buffer-get-display-entries (guix-buffer-get-display-entries
'list 'output 'list 'output
(cl-list* (guix-ui-current-profile) (cl-list* (guix-ui-current-profile)
'generation-diff 'profile-diff
(reverse (guix-generation-list-generations-to-compare))) (reverse (guix-generation-list-profiles-to-compare)))
'add)) 'add))
(defun guix-generation-list-show-removed-packages () (defun guix-generation-list-show-removed-packages ()
@ -234,8 +239,8 @@ installed in the other one."
(guix-buffer-get-display-entries (guix-buffer-get-display-entries
'list 'output 'list 'output
(cl-list* (guix-ui-current-profile) (cl-list* (guix-ui-current-profile)
'generation-diff 'profile-diff
(guix-generation-list-generations-to-compare)) (guix-generation-list-profiles-to-compare))
'add)) 'add))
(defun guix-generation-list-compare (diff-fun gen-fun) (defun guix-generation-list-compare (diff-fun gen-fun)