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

    Move calibre--library to calibre-util
    
    * calibre-util.el: Require calibre to fix byte compilation warning.
    (calibre--library): Create/Move from somewhere.
    (calibre-select-library): Declare function.
---
 calibre-util.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/calibre-util.el b/calibre-util.el
index 03974626a1..6c171422dc 100644
--- a/calibre-util.el
+++ b/calibre-util.el
@@ -23,6 +23,7 @@
 ;; circular dependency issues.
 
 ;;; Code:
+(require 'calibre)
 (require 'calibre-book)
 
 (defun calibre-util-find-book (book seq)
@@ -76,5 +77,16 @@ discard any modifications."
      (unwind-protect (progn ,@body)
        (calibre-library--restore-marks marks))))
 
+(defvar calibre--library nil
+  "The active library.")
+
+(declare-function calibre-select-library "calibre-core.el")
+(defun calibre--library ()
+  "Return the active library.
+If no library is active, prompt the user to select one."
+  (unless calibre--library
+    (calibre-select-library))
+  (alist-get calibre--library calibre-libraries nil nil #'string=))
+
 (provide 'calibre-util)
 ;;; calibre-util.el ends here

Reply via email to