[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/calibre 4a0d5b9606 32/76: Factor the setting of the Lib
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/calibre 4a0d5b9606 32/76: Factor the setting of the Library header into a function |
|
Date: |
Thu, 18 May 2023 09:57:43 -0400 (EDT) |
branch: externals/calibre
commit 4a0d5b9606455c50dc5ea69d93fcf09bb0c755d3
Author: Kjartan Óli Ágústsson <kjartanoli@disroot.org>
Commit: Kjartan Óli Ágústsson <kjartanoli@disroot.org>
Factor the setting of the Library header into a function
* calibre-db.el (calibre-library--set-header): Create
(calibre-library--header-format): Move from calibre-library.el.
* calibre-library.el (calibre-library--header-format): Move to calibre-db.el
(calibre-library-mode): Call calibre-library--set-header instead of
using setf.
---
calibre-db.el | 29 +++++++++++++++++++++++++++++
calibre-library.el | 31 +++----------------------------
2 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/calibre-db.el b/calibre-db.el
index 9f865a269d..60cd02163e 100644
--- a/calibre-db.el
+++ b/calibre-db.el
@@ -153,6 +153,35 @@ If FORCE is non-nil fetch book data from the database."
(calibre--books force)))
(tabulated-list-print)))))
+(defun calibre-library--set-header ()
+ "Set the header of the Library buffer."
+ (setf tabulated-list-format (calibre-library--header-format)))
+
+(defun calibre-library--header-format ()
+ "Create the header for the Library buffer.
+Return a vector suitable as the value of `tabulated-list-format'
+with values determined by `calibre-library-columns'."
+ (vconcat
+ (mapcar (lambda (x)
+ (let ((column (car x))
+ (width (cdr x)))
+ (cl-case column
+ (id `("ID" ,width (lambda (a b)
+ (< (calibre-book-id (car a))
+ (calibre-book-id (car b))))
+ :right-align t))
+ (title `("Title" ,width t))
+ (authors `("Author(s)" ,width t))
+ (publishers `("Publisher(s)" ,width t))
+ (series `("Series" ,width (lambda (a b)
+ (calibre-book-sort-by-series (car
a) (car b)))))
+ (series-index `("#" ,width (lambda (a b)
+ (calibre-book-sort-by-series
(car a) (car b)))
+ :right-align t))
+ (tags `("Tags" ,width))
+ (formats `("Formats" ,width)))))
+ calibre-library-columns)))
+
(defun calibre-book--print-info (book)
"Return list suitable as a value of `tabulated-list-entries'.
BOOK is a `calibre-book'."
diff --git a/calibre-library.el b/calibre-library.el
index 1f8ba1a744..7e5b5db7da 100644
--- a/calibre-library.el
+++ b/calibre-library.el
@@ -98,31 +98,6 @@ ARGS should be a list of strings. SENTINEL is a process
sentinel to install."
(interactive (list (tabulated-list-get-id)) calibre-library-mode)
(find-file (calibre-book--file book (calibre-book--pick-format book))))
-(defun calibre-library--header-format ()
- "Create the header for the Library buffer.
-Return a vector suitable as the value of `tabulated-list-format'
-with values determined by `calibre-library-columns'."
- (vconcat
- (mapcar (lambda (x)
- (let ((column (car x))
- (width (cdr x)))
- (cl-case column
- (id `("ID" ,width (lambda (a b)
- (< (calibre-book-id (car a))
- (calibre-book-id (car b))))
- :right-align t))
- (title `("Title" ,width t))
- (authors `("Author(s)" ,width t))
- (publishers `("Publisher(s)" ,width t))
- (series `("Series" ,width (lambda (a b)
- (calibre-book-sort-by-series (car
a) (car b)))))
- (series-index `("#" ,width (lambda (a b)
- (calibre-book-sort-by-series
(car a) (car b)))
- :right-align t))
- (tags `("Tags" ,width))
- (formats `("Formats" ,width)))))
- calibre-library-columns)))
-
(defvar-keymap calibre-library-mode-map
:doc "Local keymap for Calibre Library buffers."
:parent tabulated-list-mode-map
@@ -133,9 +108,9 @@ with values determined by `calibre-library-columns'."
"RET" #'calibre-library-open-book)
(define-derived-mode calibre-library-mode tabulated-list-mode
- (setf tabulated-list-padding 2
- tabulated-list-format (calibre-library--header-format))
- (tabulated-list-init-header))
+ (setf tabulated-list-padding 2)
+ (calibre-library--set-header)
+ (add-hook 'tabulated-list-revert-hook #'calibre-library--revert))
;;;###autoload
(defun calibre-library ()
- [elpa] externals/calibre 8ae08bd7fb 68/76: Update README, (continued)
- [elpa] externals/calibre 8ae08bd7fb 68/76: Update README, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 5e81e98079 18/76: Add README, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre bdb11248c9 20/76: Move metadata into calibre.el, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 1c0bf191d5 35/76: Refresh Library buffer when calibre-library-columns is changed, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre c644d0761d 40/76: Slight improvement to README, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre be94be6962 46/76: Add ability to filter by series and format, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 89e52d61c0 50/76: Only allow single publisher per book, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre c6a5772da0 29/76: Fix docstring, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 7396636341 30/76: Only refresh Library buffer if it exists, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 6d7ed97ab6 31/76: Use the value of calibre-calibredb-executable, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 4a0d5b9606 32/76: Factor the setting of the Library header into a function,
ELPA Syncer <=
- [elpa] externals/calibre 85e3ac6337 48/76: Add missing space in completing-read prompt, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 6366966c9b 60/76: Add abstraction layer on top of calibre-db, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 9a54c7a6b4 09/76: Add function to add books from dired, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 533c68f55f 27/76: Do right alignment correctly, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 3e6ce3abc2 39/76: Bump package version, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 569c096746 45/76: Use macros to avoid repeating similar function definitions, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 04c484a2ef 55/76: Preserve marks when refreshing library, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre d51ac1d3e6 54/76: Don't use message to format string, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 30ec9ca2da 56/76: Use queuing to avoid multiple concurrent calls to calibredb, ELPA Syncer, 2023/05/18
- [elpa] externals/calibre 48fc9eb57b 61/76: Don't create buffer for processes, ELPA Syncer, 2023/05/18