branch: externals/calibre
commit 4c0c97cc0ce46fcf393c820a0ab41502c2a80fd2
Author: Kjartan Oli Agustsson <[email protected]>
Commit: Kjartan Oli Agustsson <[email protected]>
Add user option to control automerge policy
* calibre-library.el (calibre-library-add-books): Add --automerge flag
and the appropriate value the the add command.
* calibre.el (calibre-automerge-policy): New defcustom.
* doc/calibre.texi (Adding books): Document calibre-automerge-policy.
(Handling duplicate books): New subsection.
* etc/TODO: Remove entry relating to calibre-automerge-policy.
---
calibre-library.el | 3 ++-
calibre.el | 14 ++++++++++++++
doc/calibre.texi | 28 ++++++++++++++++++++++++++++
etc/TODO | 5 -----
4 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/calibre-library.el b/calibre-library.el
index 38ac4cdfb4..acef570285 100644
--- a/calibre-library.el
+++ b/calibre-library.el
@@ -65,7 +65,8 @@ TAGS should be a list of strings to add to FILE."
TAGS should be a list of strings to add to FILE."
(calibre-exec--queue-command
- `("add" "-r"
+ `("add" "--recurse"
+ "--automerge" ,calibre-automerge-policy
,@(mapcar #'expand-file-name files)
,@(if (or tags calibre-default-tags)
(list "--tags" (string-join (append tags calibre-default-tags) ","))
diff --git a/calibre.el b/calibre.el
index 875ef2b1eb..95aa01fa73 100644
--- a/calibre.el
+++ b/calibre.el
@@ -51,6 +51,20 @@
(directory :tag "Location")))
:package-version '("calibre" . "0.1.0"))
+(defcustom calibre-automerge-policy "ignore"
+ "What to do when adding books which already exists.
+
+If books with similar titles and authors are found, merge the incoming
+formats (files) automatically into existing book records. A value of
+\"ignore\" means duplicate formats are discarded. A value of
+\"overwrite\" means duplicate formats in the library are overwritten
+with the newly added files. A value of \"new_record\" means duplicate
+formats are placed into a new book record."
+ :type '(choice (const :tag "Ignore" "ignore")
+ (const :tag "Overwrite" "overwrite")
+ (const :tag "New Record" "new_record"))
+ :package-version '("calibre" . "1.5.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"))
diff --git a/doc/calibre.texi b/doc/calibre.texi
index 56794d3806..e0732bdf5f 100644
--- a/doc/calibre.texi
+++ b/doc/calibre.texi
@@ -294,6 +294,7 @@ is automatically refreshed once the modification has been
completed.
* Adding individual books::
* Adding books in bulk::
* Tagging added books::
+* Handling duplicate books::
@end menu
@node Adding individual books
@@ -330,6 +331,33 @@ and @code{calibre-dired-add} can be called with a prefix
argument. When
called with a prefix argument they will prompt for a list of tags to
apply to the books being added.
+@node Handling duplicate books
+@subsection Handling duplicate books
+When adding new books Calibre compares them with existing books in your
+library in an attempt to determine if the book is already present. When
+a duplicate is detected Calibre can do one of three things:
+@enumerate
+@item
+Ignore the new book
+@item
+Overwrite the existing book
+@item
+Create a new book, resulting in two distinct books in your library.
+@end enumerate
+
+@vindex calibre-automerge-policy
+Which of these options calibre.el uses is controlled by the user option
+@code{calibre-automerge-policy} whose three values:
+@itemize
+@item
+Ignore
+@item
+Overwrite
+@item
+New Record
+@end itemize
+correspond to the three options.
+
@node Adding formats to existing books
@section Adding formats to existing books
@findex calibre-library-add-format
diff --git a/etc/TODO b/etc/TODO
index 3b0ce071e9..0fbd926967 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -39,11 +39,6 @@ formats from the *Library* buffer.
It should be possible to mark a set of books and apply a change, such
as adding tags or setting a publisher, to to all of them.
-* Add a defcustom specifying automerge policy
-calibredb add's --automerge option allows specifying how to handle
-books already in the library. The user should be allowed to control
-this in calibre.el.
-
* Allow modifying publication date