[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/calibre 188a3da504 04/76: Add functions to add and remo
From: |
ELPA Syncer |
Subject: |
[elpa] externals/calibre 188a3da504 04/76: Add functions to add and remove books |
Date: |
Thu, 18 May 2023 09:57:40 -0400 (EDT) |
branch: externals/calibre
commit 188a3da504693bca40453b3baa2c9efb857b1d70
Author: Kjartan Óli Ágústsson <kjartanoli@disroot.org>
Commit: Kjartan Óli Ágústsson <kjartanoli@disroot.org>
Add functions to add and remove books
* calibre-library.el
(calibre-library-add-book,
calibre-library-add-books,
calibre-remove-books,
calibre-library--process-sentinel,
calibre-library--execute): Created
---
calibre-library.el | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/calibre-library.el b/calibre-library.el
index a51e3fde23..f74d94e4dc 100644
--- a/calibre-library.el
+++ b/calibre-library.el
@@ -32,6 +32,41 @@
(calibre--books)))
(tabulated-list-print))))
+;;;###autoload
+(defun calibre-library-add-book (file)
+ "Add FILE to the Calibre library."
+ (interactive "f")
+ (unless (executable-find "calibredb"))
+ (calibre-add-books (list file)))
+
+(defun calibre-library-add-books (files)
+ "Add FILES to the Calibre library."
+ (calibre-library--execute `("add" ,@(mapcar #'expand-file-name files))))
+
+(defun calibre-remove-books (books)
+ "Remove BOOKS from the Calibre library."
+ (let ((ids (mapcar #'int-to-string (mapcar #'calibre-book-id books))))
+ (calibre-library--execute `("remove" ,(string-join ids ",")))))
+
+(defun calibre-library--process-sentinel (_ event)
+ "Process filter for Calibre library operations.
+EVENT is the process event, see Info node
+`(elisp)Sentinels'"
+ (if (string= event "finished\n")
+ (if (get-buffer calibre-library-buffer)
+ (calibre-library--refresh))
+ (error "Calibre process failed %S" event)))
+
+(cl-defun calibre-library--execute (args &optional (sentinel
#'calibre-library--process-sentinel))
+ "Execute calibredb with arguments ARGS.
+ARGS should be a list of strings. SENTINEL is a process sentinel to install."
+ (if (not (executable-find calibre-calibredb-executable))
+ (error "Could not find calibredb")
+ (make-process
+ :name "calibre"
+ :command `("calibredb" "--with-library" ,calibre-library-dir ,@args)
+ :sentinel sentinel)))
+
(defun calibre-library-mark-remove (&optional _num)
"Mark a book for removal and move to the next line."
(interactive "p" calibre-library-mode)
- [elpa] externals/calibre 187685e08e 70/76: Use cond instead of cl-case, (continued)
- [elpa] externals/calibre 187685e08e 70/76: Use cond instead of cl-case, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 0e7221461b 62/76: Add ability to use CLI interface instead of SQLite, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 13141efce4 67/76: Bump package version, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 3a7abbee56 64/76: Use compat to lower required Emacs version, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 090b28d6ec 69/76: Use int-to-string instead of format, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre fd949f1813 72/76: Set name of calibre-library-mode, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 8560bbd48b 75/76: Sort in ascending order by series index, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre dc4b5f79ac 11/76: Add commentary, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 7d97c360f1 15/76: Update package version to 1.0, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 38e0beb840 03/76: Get publishers, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 188a3da504 04/76: Add functions to add and remove books,
ELPA Syncer <=
- [elpa] externals/calibre 393ae4a945 12/76: Add force option to library refresh, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre ecf03e1842 19/76: Fix circular dependencies and byte compiler warnings, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre e2863a9d6a 21/76: Fix byte compiler warning, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 330471a75f 26/76: Fix circular dependency and byte compiler warnings, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre fd1b0e5fd7 28/76: Use message instead of display-warning, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre bc26df0b48 36/76: Set tabulated-list-format in the correct buffer, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 07df132f5d 53/76: Error if no libraries are defined, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre b7d6dd90f1 57/76: Add customisation types to book slots, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 4e4bf841cb 59/76: Rename calibre-make-book, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 832e91827d 63/76: Move calibre--library to calibre-util, ELPA Syncer, 2023/05/18