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

    Use constants instead of magic literals for marks
    
    * calibre-edit.el (eieio-done-customizing): Use calibre-mod-marker.
    * calibre-library.el (calibre-library-mark-remove,
    calibre-library-execute): Use calibre-del-marker and calibre-mod-marker.
    * calibre.el (calibre-del-marker, calibre-mod-marker): Create.
---
 calibre-edit.el    | 3 ++-
 calibre-library.el | 6 +++---
 calibre.el         | 5 +++++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/calibre-edit.el b/calibre-edit.el
index fc7e1802ef..53a90862d2 100644
--- a/calibre-edit.el
+++ b/calibre-edit.el
@@ -34,10 +34,11 @@
   (eieio-customize-object book))
 
 (cl-defmethod eieio-done-customizing ((book calibre-book))
+  "Finalise the editing of BOOK."
   (calibre-library--refresh)
   (with-current-buffer (get-buffer calibre-library-buffer)
     (calibre-library--find-book book)
-    (tabulated-list-put-tag "M")))
+    (tabulated-list-put-tag (char-to-string calibre-mod-marker))))
 
 (defun calibre-edit-revert (book)
   "Undo any edits performed to BOOK in this session."
diff --git a/calibre-library.el b/calibre-library.el
index 65ea40e35e..7d7558348a 100644
--- a/calibre-library.el
+++ b/calibre-library.el
@@ -58,7 +58,7 @@
 (defun calibre-library-mark-remove (&optional _num)
   "Mark a book for removal and move to the next line."
   (interactive "p" calibre-library-mode)
-  (tabulated-list-put-tag "D" t))
+  (tabulated-list-put-tag (char-to-string calibre-del-marker) t))
 
 (defun calibre-library-mark-unmark (&optional _num)
   "Clear any marks on a book and move to the next line."
@@ -80,8 +80,8 @@
         (setf mark (char-after))
         (let ((book (tabulated-list-get-id)))
           (cl-case mark
-            (?D (push book remove-list))
-            (?M (push book modified-list))))
+            (calibre-del-marker (push book remove-list))
+            (calibre-mod-marker (push book modified-list))))
         (forward-line)))
     (when remove-list (calibre-library-remove-books remove-list))
     (when modified-list (calibre-edit-commit-edits modified-list)))
diff --git a/calibre.el b/calibre.el
index fb25ffd7b2..634bfb9c25 100644
--- a/calibre.el
+++ b/calibre.el
@@ -50,5 +50,10 @@
   "Return a list of the names of defined libraries."
   (mapcar #'car calibre-libraries))
 
+(defconst calibre-del-marker ?D
+  "Character used to flag books for deletion.")
+(defconst calibre-mod-marker ?M
+  "Character used to flag books that have been modified.")
+
 (provide 'calibre)
 ;;; calibre.el ends here

Reply via email to