branch: externals/calibre
commit 60a12e2aceb47ddb59e2fa3b96375ab1a4d8d212
Author: Kjartan Oli Agustsson <[email protected]>
Commit: Kjartan Oli Agustsson <[email protected]>
Add ability to set tags to apply to all added books
* calibre-library.el (calibre-library-add-books): Insert tags and the
--tags flag into the add command if calibre-default-tags is non-nil.
* calibre.el (calibre-default-tags): New defcustom.
* doc/calibre.texi (Tagging added books): New section.
* etc/NEWS: New section about calibre-default-tags.
The ability to add default tags to all books enables things like
tagging all books as "unread", allowing easy tracking of what books
you have not read yet.
---
calibre-library.el | 6 +++++-
calibre.el | 5 +++++
doc/calibre.texi | 9 +++++++++
etc/NEWS | 4 ++++
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/calibre-library.el b/calibre-library.el
index f511b33829..d5afffafb2 100644
--- a/calibre-library.el
+++ b/calibre-library.el
@@ -51,7 +51,11 @@ opening books in that format."
(defun calibre-library-add-books (files)
"Add FILES to the Calibre library."
(calibre-exec--queue-command
- `("add" "-r" ,@(mapcar #'expand-file-name files)))
+ `("add" "-r"
+ ,@(mapcar #'expand-file-name files)
+ ,@(if calibre-default-tags
+ (list "--tags" (string-join calibre-default-tags ","))
+ nil)))
(calibre-exec--start-execution))
;;;###autoload
diff --git a/calibre.el b/calibre.el
index 09a823deba..ad6a55145d 100644
--- a/calibre.el
+++ b/calibre.el
@@ -46,6 +46,11 @@
(directory :tag "Location")))
:package-version '("calibre" . "0.1.0"))
+(defcustom calibre-default-tags nil
+ "A list of tags to add to books when they are added."
+ :type '(repeat :tag "Tag" (string :tag "Tag"))
+ :package-version '("calibre" . "1.5.0"))
+
(defun calibre--library-names ()
"Return a list of the names of defined libraries."
(mapcar #'car calibre-libraries))
diff --git a/doc/calibre.texi b/doc/calibre.texi
index 2c4ae90c31..af1fb2aa67 100644
--- a/doc/calibre.texi
+++ b/doc/calibre.texi
@@ -287,6 +287,7 @@ is automatically refreshed once the modification has been
completed.
@menu
* Adding individual books::
* Adding books in bulk::
+* Tagging added books
@end menu
@node Adding individual books
@@ -310,6 +311,14 @@ can make use of calibre.el's integration with Dired
buffer and call @code{calibre-dired-add} to add them all to your
library.
+@node Tagging added books
+@subsection Tagging added books
+@vindex calibre-default-tags
+If you have tags you want to apply to all books added to your library,
+for example to tag all books as ``unread'', you can customise
+@code{calibre-default-tags}. Any tag present in this list will be
+automatically added to the book.
+
@node Modifying books
@section Modifying books
calibre.el provides two methods of modifying book metadata. A dedicated
diff --git a/etc/NEWS b/etc/NEWS
index aab09a8567..49e8bc4a18 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -16,6 +16,10 @@ calibre-library-remove-tags enable the addition and removal
of tags
directly from the Library buffer. If any books are marked they will
operate on all of the marked books.
+** Add ability to specify tags to apply to all added books
+The new defcustom calibre-default-tags allows specifying a list of
+tags which should be applied to all books added to the library.
+
* Changes in calibre.el 1.4.1
** Fix sorting by series