branch: externals/calibre
commit e6d698796dce25e156085990476f1d6251e3933b
Author: Kjartan Oli Agustsson <[email protected]>
Commit: Kjartan Oli Agustsson <[email protected]>

    Add ability to modify author lists from the library buffer
    
    * calibre-library.el (calibre--read-authors): New function.
    (calibre-library-add-authors): New function.
    (calibre-library-remove-authors): New function.
    * doc/calibre.texi (Modifying multiple books): Mention
    calibre-library-add-authors and calibre-library-remove-authors.
---
 calibre-library.el | 22 ++++++++++++++++++++++
 doc/calibre.texi   | 11 ++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/calibre-library.el b/calibre-library.el
index 0ab01abcb5..38ac4cdfb4 100644
--- a/calibre-library.el
+++ b/calibre-library.el
@@ -46,6 +46,10 @@ opening books in that format."
   "Prompt the user for a list of tags."
   (completing-read-multiple "Tags: " calibre-tags-completion-table))
 
+(defun calibre--read-authors ()
+  "Prompt the user for a list of authors."
+  (completing-read-multiple "Authors: " calibre-authors-completion-table))
+
 ;;;###autoload
 (defun calibre-library-add-book (file &optional tags)
   "Add FILE to the Calibre library.
@@ -114,6 +118,24 @@ are marked return those books otherwise return the book at 
point."
     (calibre-edit-remove-tags tags book))
   (calibre-library--refresh))
 
+(defun calibre-library-add-authors (authors books)
+  "Add AUTHORS to BOOKS if not already present."
+  (interactive (list (calibre--read-authors)
+                     (calibre--get-active-books))
+               calibre-library-mode)
+  (dolist (book books)
+      (calibre-edit-add-authors authors book))
+  (calibre-library--refresh))
+
+(defun calibre-library-remove-authors (authors books)
+  "Remove AUTHORS from BOOKS if present."
+  (interactive (list (calibre--read-authors)
+                     (calibre--get-active-books))
+               calibre-library-mode)
+  (dolist (book books)
+    (calibre-edit-remove-authors authors book))
+  (calibre-library--refresh))
+
 (defun calibre-library-remove-books (books)
   "Remove BOOKS from the Calibre library."
   (let ((ids (mapcar #'int-to-string (mapcar #'calibre-book-id books))))
diff --git a/doc/calibre.texi b/doc/calibre.texi
index 721c67ffe9..8a1ed4ba44 100644
--- a/doc/calibre.texi
+++ b/doc/calibre.texi
@@ -375,11 +375,12 @@ section will operate on the book at point.
 @findex calibre-library-add-tags
 @findex calibre-library-remove-tags
 Currently the only metadata that can be modified from the
-@file{*Library*} buffer is tags, which can be manipulated with the
-commands @code{calibre-library-add-tags} and
-@code{calibre-library-remove-tags}.  Both commands will prompt for one,
-or more, tags and respectively add them to any books which do not
-already have them, or remove them from any books that do.
+@file{*Library*} buffer are tags and authors, which can be manipulated
+with the commands @code{calibre-library-add-tags},
+@code{calibre-library-remove-tags}, @code{calibre-library-add-authors},
+and @code{calibre-library-remove-authors}.  Both commands will prompt
+for one, or more, tags or authors and respectively add them to any books
+which do not already have them, or remove them from any books that do.
 
 @node Committing and reverting modifications
 @subsection Committing and reverting modifications

Reply via email to