branch: externals/taxy commit 0413fe219b8d572ad073fd59cea545ba902ae374 Author: Adam Porter <a...@alphapapa.net> Commit: Adam Porter <a...@alphapapa.net>
Add: (cl-defstruct taxy) :make And use in taxy-take-keyed*. --- README.org | 4 ++++ taxy.el | 34 ++++++++++++++++++++-------------- taxy.info | 59 ++++++++++++++++++++++++++++++++++++----------------------- 3 files changed, 60 insertions(+), 37 deletions(-) diff --git a/README.org b/README.org index ca60ab2..7f232c8 100644 --- a/README.org +++ b/README.org @@ -717,6 +717,10 @@ Note that =taxy-magit-section.el= is not installed with the =taxy= package by de ** 0.2-pre +*** Additions + ++ Struct ~taxy~ now has a ~:make~ slot, a function called to make new sub-taxys by ~take-take-keyed*~ (defaulting to ~make-taxy~). This is useful when defining structs specialized on ~taxy~. + *** Fixes + ~taxy-magit-section~'s ~insert-object~ function. diff --git a/taxy.el b/taxy.el index b6755ac..f39ec18 100644 --- a/taxy.el +++ b/taxy.el @@ -54,6 +54,7 @@ (cl-defstruct taxy name description key objects taxys (predicate #'identity) (then #'ignore) + (make #'make-taxy) take) ;;;; Variables @@ -162,20 +163,25 @@ recursively as necessary. Each new taxy's name is that returned by KEY-NAME-FN called with OBJECT." (let ((key-fn (car key-fns))) (if-let ((key (funcall key-fn object))) - (let ((key-taxy (or (cl-find-if (lambda (taxy-key) - (equal key taxy-key)) - (taxy-taxys taxy) - :key #'taxy-key) - (car - (push (make-taxy - :name (funcall key-name-fn key) :key key - :predicate (lambda (object) - (equal key (funcall key-fn object))) - :take (when (cdr key-fns) - (lambda (object taxy) - (taxy-take-keyed* (cdr key-fns) object taxy))) - :then then) - (taxy-taxys taxy)))))) + (let ((key-taxy + (or (cl-find-if (lambda (taxy-key) + (equal key taxy-key)) + (taxy-taxys taxy) + :key #'taxy-key) + (car + ;; Calling `make-taxy' directly might offer the compiler a chance to optimize + ;; compared to using `funcall', but allowing taxy structs to specify their + ;; own MAKE functions is very helpful when using specialized structs. + (push (funcall (taxy-make taxy) + :name (funcall key-name-fn key) + :key key + :predicate (lambda (object) + (equal key (funcall key-fn object))) + :take (when (cdr key-fns) + (lambda (object taxy) + (taxy-take-keyed* (cdr key-fns) object taxy))) + :then then) + (taxy-taxys taxy)))))) (if (cdr key-fns) (taxy-take-keyed* (cdr key-fns) object key-taxy) (push object (taxy-objects key-taxy)))) diff --git a/taxy.info b/taxy.info index abbb7f6..9cb7c6c 100644 --- a/taxy.info +++ b/taxy.info @@ -52,6 +52,7 @@ Changelog 0.2-pre +* Additions:: * Fixes:: Development @@ -814,12 +815,23 @@ File: README.info, Node: 02-pre, Next: 01, Up: Changelog * Menu: +* Additions:: * Fixes:: -File: README.info, Node: Fixes, Up: 02-pre +File: README.info, Node: Additions, Next: Fixes, Up: 02-pre -4.1.1 Fixes +4.1.1 Additions +--------------- + + • Struct ‘taxy’ now has a ‘:make’ slot, a function called to make new + sub-taxys by ‘take-take-keyed*’ (defaulting to ‘make-taxy’). This + is useful when defining structs specialized on ‘taxy’. + + +File: README.info, Node: Fixes, Prev: Additions, Up: 02-pre + +4.1.2 Fixes ----------- • ‘taxy-magit-section’’s ‘insert-object’ function. @@ -881,27 +893,28 @@ GPLv3 Tag Table: Node: Top218 -Node: Examples1365 -Node: Numbery (starting basically)1684 -Node: Lettery (filling incrementally)7443 -Node: Sporty (understanding completely)9892 -Node: Applications16371 -Node: Installation16771 -Node: Usage17072 -Node: Dynamic taxys19193 -Node: Multi-level dynamic taxys21611 -Node: Reusable taxys23774 -Node: Threading macros27943 -Node: Modifying filled taxys28482 -Node: Magit section29575 -Node: Changelog30176 -Node: 02-pre30326 -Node: Fixes30434 -Node: 0130666 -Node: Development30769 -Node: Copyright assignment30975 -Node: Credits31574 -Node: License31764 +Node: Examples1379 +Node: Numbery (starting basically)1698 +Node: Lettery (filling incrementally)7457 +Node: Sporty (understanding completely)9906 +Node: Applications16385 +Node: Installation16785 +Node: Usage17086 +Node: Dynamic taxys19207 +Node: Multi-level dynamic taxys21625 +Node: Reusable taxys23788 +Node: Threading macros27957 +Node: Modifying filled taxys28496 +Node: Magit section29589 +Node: Changelog30190 +Node: 02-pre30340 +Node: Additions30462 +Node: Fixes30789 +Node: 0131039 +Node: Development31142 +Node: Copyright assignment31348 +Node: Credits31947 +Node: License32137 End Tag Table