1 ;;; guix-entry.el --- 'Entry' type -*- lexical-binding: t -*-
3 ;; Copyright © 2015 Alex Kost <alezost@gmail.com>
5 ;; This file is part of GNU Guix.
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.
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.
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/>.
22 ;; This file provides an API for 'entry' type which is just an alist of
23 ;; KEY/VALUE pairs (KEY should be a symbol) with the required 'id' KEY.
30 (defalias 'guix-entry-value
#'guix-assq-value
)
32 (defun guix-entry-id (entry)
34 (guix-entry-value entry
'id
))
36 (defun guix-entry-by-id (id entries
)
37 "Return an entry from ENTRIES by its ID."
38 (cl-find-if (lambda (entry)
39 (equal (guix-entry-id entry
) id
))
42 (defun guix-entries-by-ids (ids entries
)
43 "Return entries with IDS (a list of identifiers) from ENTRIES."
44 (cl-remove-if-not (lambda (entry)
45 (member (guix-entry-id entry
) ids
))
48 (defun guix-replace-entry (id new-entry entries
)
49 "Replace an entry with ID from ENTRIES by NEW-ENTRY.
50 Return a list of entries with the replaced entry."
51 (cl-substitute-if new-entry
53 (equal id
(guix-entry-id entry
)))
59 ;;; guix-entry.el ends here