branch: externals/calibre
commit b43ab3a90cd9dd99097c6b69de702ec71332edea
Author: Kjartan Óli Ágústsson <[email protected]>
Commit: Kjartan Óli Ágústsson <[email protected]>

    Allow overriding format preferences
    
    * calibre-library.el (calibre-library-open-book,
    calibre-library-open-book-other-window): Prompt for format if called
    with a prefix argument.
---
 calibre-library.el | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/calibre-library.el b/calibre-library.el
index 1ff4e7dd79..30f0f56bf9 100644
--- a/calibre-library.el
+++ b/calibre-library.el
@@ -97,15 +97,27 @@
         (goto-char (point-max))
       (calibre-library--find-book pos))))
 
-(defun calibre-library-open-book (book)
-  "Open BOOK in its preferred format."
-  (interactive (list (tabulated-list-get-id)) calibre-library-mode)
-  (find-file (calibre-book--file book (calibre-book--pick-format book))))
-
-(defun calibre-library-open-book-other-window (book)
-  "Open BOOK in its preferred format."
-  (interactive (list (tabulated-list-get-id)) calibre-library-mode)
-  (find-file-other-window (calibre-book--file book (calibre-book--pick-format 
book))))
+(defun calibre-library-open-book (book &optional arg)
+  "Open BOOK in its preferred format.
+If called with a prefix argument prompt the user for the format."
+  (interactive (list (tabulated-list-get-id)
+                     current-prefix-arg)
+               calibre-library-mode)
+  (let ((format (if arg
+                    (completing-read "Format: " (calibre-book-formats book) 
nil t)
+                  (calibre-book--pick-format book))))
+    (find-file (calibre-book--file book format))))
+
+(defun calibre-library-open-book-other-window (book &optional arg)
+  "Open BOOK in its preferred format, in another window.
+If called with a prefix argument prompt the user for the format."
+  (interactive (list (tabulated-list-get-id)
+                     current-prefix-arg)
+               calibre-library-mode)
+  (let ((format (if arg
+                    (completing-read "Format: " (calibre-book-formats book) 
nil t)
+                  (calibre-book--pick-format book))))
+    (find-file-other-window (calibre-book--file book format))))
 
 (defvar-keymap calibre-library-mode-map
   :doc "Local keymap for Calibre Library buffers."

Reply via email to