From 73ce3c19c435db51ec818ec62a75e0956b31899f Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Thu, 22 Oct 2015 10:08:42 +0300 Subject: emacs: Add API for 'guix-entry'. * emacs/guix-info.el: Use new entry procedures. * emacs/guix-list.el: Likewise. * emacs/guix-base.el: Likewise. (guix-get-entry-by-id): Move and rename to ... * emacs/guix-entry.el (guix-entry-by-id): ...this. New file. (guix-entry-value, guix-entry-id, guix-entries-by-ids) (guix-replace-entry): New procedures. * emacs.am (ELFILES): Add new file. --- emacs/guix-base.el | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'emacs/guix-base.el') diff --git a/emacs/guix-base.el b/emacs/guix-base.el index d9c70aae9e..7055a0984e 100644 --- a/emacs/guix-base.el +++ b/emacs/guix-base.el @@ -30,6 +30,7 @@ (require 'cl-lib) (require 'guix-profiles) (require 'guix-backend) +(require 'guix-entry) (require 'guix-guile) (require 'guix-utils) (require 'guix-history) @@ -103,15 +104,15 @@ Each element of the list has a form: (defun guix-get-full-name (entry &optional output) "Return name specification of the package ENTRY and OUTPUT." - (guix-get-name-spec (guix-assq-value entry 'name) - (guix-assq-value entry 'version) + (guix-get-name-spec (guix-entry-value entry 'name) + (guix-entry-value entry 'version) output)) (defun guix-entry-to-specification (entry) "Return name specification by the package or output ENTRY." - (guix-get-name-spec (guix-assq-value entry 'name) - (guix-assq-value entry 'version) - (guix-assq-value entry 'output))) + (guix-get-name-spec (guix-entry-value entry 'name) + (guix-entry-value entry 'version) + (guix-entry-value entry 'output))) (defun guix-entries-to-specifications (entries) "Return name specifications by the package or output ENTRIES." @@ -121,14 +122,8 @@ Each element of the list has a form: (defun guix-get-installed-outputs (entry) "Return list of installed outputs for the package ENTRY." (mapcar (lambda (installed-entry) - (guix-assq-value installed-entry 'output)) - (guix-assq-value entry 'installed))) - -(defun guix-get-entry-by-id (id entries) - "Return entry from ENTRIES by entry ID." - (cl-find-if (lambda (entry) - (equal id (guix-assq-value entry 'id))) - entries)) + (guix-entry-value installed-entry 'output)) + (guix-entry-value entry 'installed))) (defun guix-get-package-id-and-output-by-output-id (oid) "Return list (PACKAGE-ID OUTPUT) by output id OID." @@ -940,9 +935,9 @@ ENTRIES is a list of package entries to get info about packages." (lambda (spec) (let* ((id (car spec)) (outputs (cdr spec)) - (entry (guix-get-entry-by-id id entries))) + (entry (guix-entry-by-id id entries))) (when entry - (let ((location (guix-assq-value entry 'location))) + (let ((location (guix-entry-value entry 'location))) (concat (guix-get-full-name entry) (when outputs (concat ":" -- cgit v1.2.3