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

    Operate on book at point if no books are marked
    
    * calibre-library.el (calibre--get-active-books): New function.
    (calibre-library-add-tags): Use calibre--get-active-books to get list
    of books to operate on.
    (calibre-library-remove-tags): Use calibre--get-active-books to get list
    of books to operate on.
    
    Operating on the book at point seems like the most reasonable
    behaviour when no books are marked and metadata modifications are
    requested.
---
 calibre-library.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/calibre-library.el b/calibre-library.el
index 37a8b3380a..b648a323f6 100644
--- a/calibre-library.el
+++ b/calibre-library.el
@@ -89,10 +89,17 @@ TAGS should be a list of strings to add to FILE."
     (if (derived-mode-p 'dired-mode)
         (calibre-library-add-books (dired-get-marked-files) tags)))
 
+(defun calibre--get-active-books ()
+  "Get the list of books to operate on.
+
+Get the list of books a library command should operate on.  If any books
+are marked return those books otherwise return the book at point."
+  (or (calibre-library-get-marked) (list (tabulated-list-get-id))))
+
 (defun calibre-library-add-tags (tags books)
   "Add TAGS to BOOKS if not already present."
   (interactive (list (calibre--read-tags)
-                     (or (calibre-library-get-marked) (list 
(tabulated-list-get-id))))
+                     (calibre--get-active-books))
                calibre-library-mode)
   (dolist (book books)
       (calibre-edit-add-tags tags book))
@@ -101,7 +108,7 @@ TAGS should be a list of strings to add to FILE."
 (defun calibre-library-remove-tags (tags books)
   "Remove TAGS from BOOKS if present."
   (interactive (list (calibre--read-tags)
-                     (or (calibre-library-get-marked) (list 
(tabulated-list-get-id))))
+                     (calibre--get-active-books))
                calibre-library-mode)
   (dolist (book books)
     (calibre-edit-remove-tags tags book))

Reply via email to