emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/calibre 2b64cb76ad 49/76: Add support for displaying pu


From: ELPA Syncer
Subject: [elpa] externals/calibre 2b64cb76ad 49/76: Add support for displaying publication date
Date: Thu, 18 May 2023 09:57:45 -0400 (EDT)

branch: externals/calibre
commit 2b64cb76ad8d1e8de227c71bb01dd091eeab3b21
Author: Kjartan Óli Ágústsson <kjartanoli@disroot.org>
Commit: Kjartan Óli Ágústsson <kjartanoli@disroot.org>

    Add support for displaying publication date
    
    * calibre-book.el (calibre-book-pubdate): Add a getter for a book's
    publication date.
    * calibre-db.el (calibre-library-time-format): Add a new defcustom to
    control the format of time related metadata fields.
    (calibre-library-columns): Add a new column option to display
    publication date.
    (calibre-library--header-format, calibre-book--print-info): Handle the
    new option of displaying publication date.
---
 calibre-book.el |  1 +
 calibre-db.el   | 24 ++++++++++++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/calibre-book.el b/calibre-book.el
index b3a4edaa44..801c78f86e 100644
--- a/calibre-book.el
+++ b/calibre-book.el
@@ -91,6 +91,7 @@ for private functions."
 (calibre-book--slot formats)
 (calibre-book--slot path t)
 (calibre-book--slot file-name)
+(calibre-book--slot pubdate)
 
 (defcustom calibre-format-preferences '(pdf epub)
   "The preference order of file formats."
diff --git a/calibre-db.el b/calibre-db.el
index 3f6c42bdb1..55a25301fa 100644
--- a/calibre-db.el
+++ b/calibre-db.el
@@ -283,6 +283,17 @@ If FORCE is non-nil fetch book data from the database."
         (setf tabulated-list-format (calibre-library--header-format))
         (tabulated-list-init-header)))))
 
+(defcustom calibre-library-time-format "%x"
+  "String specifying format for displaying time related metadata.
+See `format-time-string' for an explanation of how to write this
+string."
+  :type 'string
+  :set (lambda (symbol value)
+         (set-default symbol value)
+         (calibre-library--refresh))
+  :group 'calibre
+  :package-version '("calibre" . "1.1.0"))
+
 (defcustom calibre-library-columns '((id . 4)
                                      (title . 35)
                                      (authors . 20)
@@ -305,7 +316,8 @@ column should have."
                    (const :tag "Series" series)
                    (const :tag "Series Index" series-index)
                    (const :tag "Tags" tags)
-                   (const :tag "Formats" formats))
+                   (const :tag "Formats" formats)
+                   (const :tag "Publication date" pubdate))
                   (integer :tag "Width")))
   :set (lambda (symbol value)
          (set-default symbol value)
@@ -336,14 +348,17 @@ with values determined by `calibre-library-columns'."
                                               (calibre-book-sort-by-series 
(car a) (car b)))
                                  :right-align t))
                  (tags `("Tags" ,width))
-                 (formats `("Formats" ,width)))))
+                 (formats `("Formats" ,width))
+                 (pubdate `("Publication Date" ,width (lambda (a b)
+                                                        (time-less-p 
(calibre-book-pubdate (car a))
+                                                                     
(calibre-book-pubdate (car b)))))))))
            calibre-library-columns)))
 
 (defun calibre-book--print-info (book)
   "Return list suitable as a value of `tabulated-list-entries'.
 BOOK is a `calibre-book'."
   (list book
-        (with-slots (id title authors publishers series series-index tags 
formats) book
+        (with-slots (id title authors publishers series series-index tags 
formats pubdate) book
           (vconcat (mapcar (lambda (x)
                              (let ((column (car x)))
                                (cl-case column
@@ -354,7 +369,8 @@ BOOK is a `calibre-book'."
                                  (series (if (not series) "" series))
                                  (series-index (if series (format "%.1f" 
series-index) ""))
                                  (tags (string-join tags ", "))
-                                 (formats (string-join (mapcar (lambda (f) 
(upcase (symbol-name f))) formats) ", ")))))
+                                 (formats (string-join (mapcar (lambda (f) 
(upcase (symbol-name f))) formats) ", "))
+                                 (pubdate (format-time-string 
calibre-library-time-format pubdate)))))
                            calibre-library-columns)))))
 
 (defun calibre-book--file (book format)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]