[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/calibre 4f980e2161 2/8: Reduce usage of cl-* functions
From: |
ELPA Syncer |
Subject: |
[elpa] externals/calibre 4f980e2161 2/8: Reduce usage of cl-* functions |
Date: |
Tue, 12 Dec 2023 06:57:34 -0500 (EST) |
branch: externals/calibre
commit 4f980e216135467a1aea3a44228ed1e6bd255d55
Author: Kjartan Oli Agustsson <kjartanoli@disroot.org>
Commit: Kjartan Oli Agustsson <kjartanoli@disroot.org>
Reduce usage of cl-* functions
* calibre-cli.el (calibre-cli--get-authors):
(calibre-cli--get-tags):
(calibre-cli--get-formats):
* calibre-core.el (calibre--get-filter-items):
(calibre-library--filter):
* calibre-search.el (calibre-search--operation):
Replace cl-* functions with equivalent seq-* functions.
---
calibre-cli.el | 26 +++++++++++++++-----------
calibre-core.el | 43 ++++++++++++++++++++++++-------------------
calibre-search.el | 4 +++-
3 files changed, 42 insertions(+), 31 deletions(-)
diff --git a/calibre-cli.el b/calibre-cli.el
index ac95f6b0d4..2be09163fc 100644
--- a/calibre-cli.el
+++ b/calibre-cli.el
@@ -132,9 +132,11 @@ AUTHORS should be a comma separated string."
(defun calibre-cli--get-authors ()
"Return a list of the authors in the active library."
(cl-remove-duplicates
- (cl-reduce #'cl-union (mapcar (lambda (b)
- (calibre-cli--parse-authors (alist-get
'authors b)))
- (calibre-cli--list "authors")))
+ (seq-reduce #'seq-union
+ (mapcar (lambda (b)
+ (calibre-cli--parse-authors (alist-get 'authors b)))
+ (calibre-cli--list "authors"))
+ '())
:test #'string=))
(defun calibre-cli--get-publishers ()
@@ -155,17 +157,19 @@ AUTHORS should be a comma separated string."
(defun calibre-cli--get-tags ()
"Return a list of the tags in the active library."
- (cl-remove-duplicates
- (cl-reduce #'cl-union (mapcar (lambda (b)
- (alist-get 'tags b))
- (calibre-cli--list "tags")))
- :test #'string=))
+ (seq-reduce #'seq-union
+ (mapcar (lambda (b)
+ (alist-get 'tags b))
+ (calibre-cli--list "tags"))
+ '()))
(defun calibre-cli--get-formats ()
"Return a list of the file formats stored in the active library."
- (cl-reduce #'cl-union (mapcar (lambda (b)
- (calibre-cli--parse-formats (alist-get
'formats b)))
- (calibre-cli--list "formats"))))
+ (seq-reduce #'seq-union
+ (mapcar (lambda (b)
+ (calibre-cli--parse-formats (alist-get 'formats b)))
+ (calibre-cli--list "formats"))
+ '()))
(provide 'calibre-cli)
;;; calibre-cli.el ends here
diff --git a/calibre-core.el b/calibre-core.el
index 15c9c81082..329cfd7c06 100644
--- a/calibre-core.el
+++ b/calibre-core.el
@@ -208,12 +208,15 @@ BOOK is a `calibre-book'."
"Return the id's of books matching FILTER."
(if (calibre-composite-filter-p filter)
(seq-let (op filters) filter
- (cl-reduce (if (eq op '+)
- #'cl-union
- #'cl-intersection)
- (mapcar (lambda (f)
+ (seq-reduce (if (eq op '+)
+ #'seq-union
+ #'seq-intersection)
+ (mapcar (lambda (f)
(calibre--get-filter-items (vconcat `[,op] f)))
- filters)))
+ filters)
+ (if (eq op '+)
+ '()
+ (calibre--books))))
(seq-let (_ field value) filter
(cl-case field
(title (calibre-core--interface get-title-books value))
@@ -227,23 +230,25 @@ BOOK is a `calibre-book'."
"Return those books in BOOKS that match FILTERS.
FILTERS should be a list of vectors, for the exact contents see
`calibre-virtual-libraries'."
- (let* ((include (cl-remove-if-not (lambda (f) (eq (elt f 0) '+)) filters))
- (exclude (cl-remove-if-not (lambda (f) (eq (elt f 0) '-)) filters))
+ (let* ((include (seq-filter (lambda (f) (eq (elt f 0) '+)) filters))
+ (exclude (seq-filter (lambda (f) (eq (elt f 0) '-)) filters))
(include-ids (when include
- (cl-reduce #'cl-intersection
- (mapcar #'calibre--get-filter-items
include))))
+ (seq-reduce #'seq-intersection
+ (mapcar #'calibre--get-filter-items
include)
+ (mapcar #'calibre-book-id
calibre--books))))
(exclude-ids (when exclude
- (cl-reduce #'cl-union
- (mapcar #'calibre--get-filter-items
exclude)))))
- (cl-remove-if (lambda (b)
- (seq-find (lambda (id)
- (= id (calibre-book-id b)))
- exclude-ids))
+ (seq-reduce #'seq-union
+ (mapcar #'calibre--get-filter-items
exclude)
+ '()))))
+ (seq-filter (lambda (b)
+ (not (seq-find (lambda (id)
+ (= id (calibre-book-id b)))
+ exclude-ids)))
(if include-ids
- (cl-remove-if-not (lambda (b)
- (seq-find (lambda (id)
- (= id (calibre-book-id b)))
- include-ids))
+ (seq-filter (lambda (b)
+ (seq-find (lambda (id)
+ (= id (calibre-book-id b)))
+ include-ids))
books)
(if include
nil
diff --git a/calibre-search.el b/calibre-search.el
index 3879f8bcb0..8b885853f5 100644
--- a/calibre-search.el
+++ b/calibre-search.el
@@ -55,7 +55,9 @@ will not be appended to the calibre-db--get-FIELD function's
name."
(defun calibre-search--operation (args)
"Return the appropriate symbol for a filter operation.
ARGS is the argument list of a transient command."
- (if (cl-find "--exclude" args :test #'string=) '- '+))
+ (if (seq-contains-p args "--exclude")
+ '-
+ '+))
(defmacro calibre-library--search-function (field)
"Create a function adding a filter for FIELD."
- [elpa] externals/calibre updated (ad65bf9b51 -> 2c4221ecfa), ELPA Syncer, 2023/12/12
- [elpa] externals/calibre ac7170e09e 3/8: Add a docstring to calibre-library-revert, ELPA Syncer, 2023/12/12
- [elpa] externals/calibre 9e532313c9 5/8: Handle invalid timestamps, ELPA Syncer, 2023/12/12
- [elpa] externals/calibre 6815074635 6/8: Add searching by title to composite filters, ELPA Syncer, 2023/12/12
- [elpa] externals/calibre dae6a54a38 1/8: Add NEWS and TODO list, ELPA Syncer, 2023/12/12
- [elpa] externals/calibre 4f980e2161 2/8: Reduce usage of cl-* functions,
ELPA Syncer <=
- [elpa] externals/calibre 4422899b7d 4/8: Add author and commentary to calibre-edit.el, ELPA Syncer, 2023/12/12
- [elpa] externals/calibre b749cf57d4 7/8: Fix order of elements in defcustom type, ELPA Syncer, 2023/12/12
- [elpa] externals/calibre 2c4221ecfa 8/8: Bump version, ELPA Syncer, 2023/12/12