branch: externals/calibre
commit a3e559cd96f7b7faaa3590d5d01ff8d5976f1c2e
Author: Kjartan Oli Agustsson <[email protected]>
Commit: Kjartan Oli Agustsson <[email protected]>

    Add a mapcar like utility macro
    
    * calibre-util.el (calibre-util--macro-map): New macro.
    
    Significant amounts of book metadata related functions are generated
    by macros.  This leads to blocks like:
    (<macro-name> <field1>)
    (<macro-name> <field2>)
    ...
    (<macro-name> <fieldN>)
    
    With calibre-util--macro-map this becomes the significantly more
    concise:
    (calibre-util--macro-map <macro-name> (field1 field2 ... fieldN))
---
 calibre-util.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/calibre-util.el b/calibre-util.el
index 2510443dfd..c9aacfa3ea 100644
--- a/calibre-util.el
+++ b/calibre-util.el
@@ -26,6 +26,11 @@
 (require 'calibre)
 (require 'calibre-book)
 
+(defmacro calibre-util--macro-map (macro list)
+  "Apply MACRO to each element in LIST."
+  `(progn
+     ,@(mapcar (lambda (el) `(,macro ,el)) list)))
+
 (defun calibre-util-find-book (book seq)
   "Find BOOK in SEQ."
   (seq-find (lambda (b)

Reply via email to