[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/calibre b237fd2e5e 05/10: Allow searching by title
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/calibre b237fd2e5e 05/10: Allow searching by title |
|
Date: |
Thu, 18 May 2023 12:57:32 -0400 (EDT) |
branch: externals/calibre
commit b237fd2e5efc0e21e0f640bf48540ef891803805
Author: Kjartan Óli Ágústsson <kjartanoli@disroot.org>
Commit: Kjartan Óli Ágústsson <kjartanoli@disroot.org>
Allow searching by title
* calibre-core.el (calibre--get-filter-items): Allow filtering by title.
(calibre-core--get-titles, calibre-cli--get-titles): Create
(calibre-cli--get-series): Adjust indentation.
* calibre-db.el (calibre-db--get-titles, calibre-db--get-title-books):
Create
* calibre-search.el (calibre-library-search-title,
calibre-search-chose-title): Create
---
calibre-core.el | 15 +++++++++++++--
calibre-db.el | 11 +++++++++++
calibre-search.el | 3 +++
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/calibre-core.el b/calibre-core.el
index 95131de047..ff29f73641 100644
--- a/calibre-core.el
+++ b/calibre-core.el
@@ -215,6 +215,7 @@ BOOK is a `calibre-book'."
filters)))
(seq-let (_ field value) filter
(cl-case field
+ (title (calibre-core--interface get-title-books value))
(author (calibre-core--interface get-author-books value))
(tag (calibre-core--interface get-tag-books value))
(publisher (calibre-core--interface get-publisher-books value))
@@ -245,6 +246,10 @@ FILTERS should be a list of vectors, for the exact
contents see
books)
books))))
+(defun calibre-core--get-titles ()
+ "Return a list of the titles in the active library."
+ (calibre-core--interface get-titles))
+
(defun calibre-core--get-authors ()
"Return a list of the authors in the active library."
(calibre-core--interface get-authors))
@@ -269,6 +274,12 @@ FILTERS should be a list of vectors, for the exact
contents see
;; These functions should be in calibre-cli.el, but they require
;; calibre--books because the calibredb interface does not expose the
;; ability get this information.
+(defun calibre-cli--get-titles ()
+ "Return a list of the titles in the active library."
+ (cl-remove-duplicates
+ (mapcar #'calibre-book-title (calibre--books))
+ :test #'string=))
+
(defun calibre-cli--get-authors ()
"Return a list of the authors in the active library."
(cl-reduce #'cl-union (mapcar #'calibre-book-authors (calibre--books))))
@@ -284,8 +295,8 @@ FILTERS should be a list of vectors, for the exact contents
see
(defun calibre-cli--get-series ()
"Return a list of the series in the active library."
(remq nil (cl-remove-duplicates
- (mapcar #'calibre-book-series (calibre--books))
- :test #'string=)))
+ (mapcar #'calibre-book-series (calibre--books))
+ :test #'string=)))
(defun calibre-cli--get-publishers ()
"Return a list of the publishers in the active library."
diff --git a/calibre-db.el b/calibre-db.el
index 0ea6b2336a..26ba2d1809 100644
--- a/calibre-db.el
+++ b/calibre-db.el
@@ -88,6 +88,11 @@ WHERE books.id = ?"
"SELECT format FROM data WHERE book = ?"
`[,id]))))
+(defun calibre-db--get-titles ()
+ "Return a list of the titles in the active library."
+ (flatten-list (sqlite-select (calibre--db)
+ "SELECT title FROM books;")))
+
(defun calibre-db--get-authors ()
"Return a list of the authors in the active library."
(flatten-list (sqlite-select (calibre--db)
@@ -138,6 +143,12 @@ FROM books
LEFT JOIN books_series_link sl ON books.id = sl.book
LEFT JOIN series ON sl.series = series.id;"))))
+(defun calibre-db--get-title-books (title)
+ "Return the id's of books whose title is TITLE."
+ (flatten-list (sqlite-select (calibre--db)
+ "SELECT id FROM books WHERE title = ?"
+ `[,title])))
+
(defun calibre-db--get-author-books (author)
"Return the id's of books written by AUTHOR."
(flatten-list (sqlite-select (calibre--db)
diff --git a/calibre-search.el b/calibre-search.el
index c4facae03b..57067e430e 100644
--- a/calibre-search.el
+++ b/calibre-search.el
@@ -45,6 +45,7 @@ will not be appended to the calibre-db--get-FIELD function's
name."
field
(if plural "" "s")))))))
+(calibre-search--choice-function "title")
(calibre-search--choice-function "author" t)
(calibre-search--choice-function "publisher")
(calibre-search--choice-function "tag")
@@ -68,6 +69,7 @@ ARGS is the argument list of a transient command."
calibre-library--filters))
(calibre-library--refresh)))
+(calibre-library--search-function "title")
(calibre-library--search-function "author")
(calibre-library--search-function "publisher")
(calibre-library--search-function "series")
@@ -87,6 +89,7 @@ ARGS is the argument list of a transient command."
["Arguments"
("-e" "Exclude" "--exclude")]
["Search"
+ ("T" "Title" calibre-library-search-title)
("a" "Author" calibre-library-search-author)
("p" "Publisher" calibre-library-search-publisher)
("t" "Tag" calibre-library-search-tag)
- [elpa] externals/calibre updated (e283a2c928 -> ba5fa17e31), ELPA Syncer, 2023/05/18
- [elpa] externals/calibre f0324a9d21 06/10: Move calibre-parse-timestamp to calibre-db, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre b237fd2e5e 05/10: Allow searching by title,
ELPA Syncer <=
- [elpa] externals/calibre 512b5a1197 02/10: Add mode line indicator when updating library, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre c07fa7d0f3 04/10: Require exact matching in calibre-cli search, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre cc66ec42bf 08/10: Remove seemingly unnecessary require, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre c6d0201342 09/10: Capture calibredb output, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 47ae488aed 07/10: Drop EIEIO in favor of custom editing solution, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre ba5fa17e31 10/10: Update copyright headers, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 524ce0353e 01/10: Fix docstring, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre f096edd1d3 03/10: Return list instead of list of lists, ELPA Syncer, 2023/05/18