branch: externals/taxy commit f5458d086226f9696f4d3d8b1403f408589df634 Author: Adam Porter <a...@alphapapa.net> Commit: Adam Porter <a...@alphapapa.net>
Change: taxy-map -> taxy-mapcar --- README.org | 16 ++++++++-------- taxy.el | 8 +++++--- taxy.info | 34 +++++++++++++++++----------------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/README.org b/README.org index ff82761..3aadc4a 100644 --- a/README.org +++ b/README.org @@ -247,7 +247,7 @@ The ~:then~ function determines what happens to an object after being taken in: After defining a taxy, call ~taxy-fill~ with it and a list of objects to fill the taxy's hierarchy. *Note:* ~taxy-fill~ modifies the taxy given to it (filling its ~:objects~ and those of its ~:taxys~), so when using a statically defined taxy (e.g. one defined with ~defvar~), you should pass ~taxy-fill~ a taxy copied with ~taxy-emptied~, which recursively copies a taxy without ~:objects~. -To return a taxy in a more human-readable format (with only relevant fields included), use ~taxy-plain~. You may also use ~taxy-map~ to replace objects in a taxy with, e.g. a more useful representation. +To return a taxy in a more human-readable format (with only relevant fields included), use ~taxy-plain~. You may also use ~taxy-mapcar~ to replace objects in a taxy with, e.g. a more useful representation. ** Dynamic taxys :PROPERTIES: @@ -399,13 +399,13 @@ Since taxys are structs, they may be stored in variables and used in other struc Note how the taxys defined in the first three variables are used in subsequent taxys. As well, the ~ement-roomy-opened~ taxy has an "anonymous" taxy, which collects any rooms that aren't collected by its sibling taxy (otherwise those objects would be collected into the parent, "Opened" taxy, which may not always be the most useful way to present the objects). -Using those defined taxys, we then fill the ~ement-roomy~ taxy with all of the rooms in the user's session, and then use ~taxy-map~ to replace the room structs with useful representations for display: +Using those defined taxys, we then fill the ~ement-roomy~ taxy with all of the rooms in the user's session, and then use ~taxy-mapcar~ to replace the room structs with useful representations for display: #+BEGIN_SRC elisp (taxy-plain - (taxy-map (lambda (room) - (list (ement-room--room-display-name room) - (ement-room-id room))) + (taxy-mapcar (lambda (room) + (list (ement-room--room-display-name room) + (ement-room-id room))) (taxy-fill (ement-session-rooms ement-session) (taxy-emptied ement-roomy)))) #+END_SRC @@ -450,9 +450,9 @@ If you happen to like macros, ~taxy~ works well with threading (i.e. ~thread-las (thread-last ement-roomy taxy-emptied (taxy-fill (ement-session-rooms ement-session)) - (taxy-map (lambda (room) - (list (ement-room--room-display-name room) - (ement-room-id room)))) + (taxy-mapcar (lambda (room) + (list (ement-room--room-display-name room) + (ement-room-id room)))) taxy-plain) #+END_SRC diff --git a/taxy.el b/taxy.el index 47bfb8c..335f7dd 100644 --- a/taxy.el +++ b/taxy.el @@ -101,8 +101,8 @@ when reusing taxy definitions." (taxy-taxys taxy) (mapcar #'taxy-emptied (taxy-taxys taxy))) taxy) -(defun taxy-map (fn taxy) - "Return TAXY, having replaced each object in it with the value of FN on it. +(defun taxy-mapcar-objects (fn taxy) + "Return copy of TAXY, having replaced its objects with the value of FN on each. Replaces every object in TAXY and its descendants. Useful to replace objects with a more useful form after classification." (declare (indent defun)) @@ -111,9 +111,11 @@ replace objects with a more useful form after classification." ;; (even `cl-loop' with `in-ref' hasn't worked). (setf (taxy-objects taxy) (mapcar fn (taxy-objects taxy)) (taxy-taxys taxy) (cl-loop for taxy in (taxy-taxys taxy) - collect (taxy-map fn taxy))) + collect (taxy-mapcar-objects fn taxy))) taxy) +(defalias 'taxy-mapcar #'taxy-mapcar-objects) + (cl-defun taxy-take-keyed (key-fn object taxy &key (key-name-fn #'identity)) "Take OBJECT into TAXY, adding new taxys dynamically. Places OBJECT into a taxy in TAXY for the value returned by diff --git a/taxy.info b/taxy.info index ac6b346..23a84a8 100644 --- a/taxy.info +++ b/taxy.info @@ -249,7 +249,7 @@ should pass ‘taxy-fill’ a taxy copied with ‘taxy-emptied’, which recursively copies a taxy without ‘:objects’. To return a taxy in a more human-readable format (with only relevant -fields included), use ‘taxy-plain’. You may also use ‘taxy-map’ to +fields included), use ‘taxy-plain’. You may also use ‘taxy-mapcar’ to replace objects in a taxy with, e.g. a more useful representation. * Menu: @@ -434,13 +434,13 @@ parent, "Opened" taxy, which may not always be the most useful way to present the objects). Using those defined taxys, we then fill the ‘ement-roomy’ taxy with -all of the rooms in the user’s session, and then use ‘taxy-map’ to +all of the rooms in the user’s session, and then use ‘taxy-mapcar’ to replace the room structs with useful representations for display: (taxy-plain - (taxy-map (lambda (room) - (list (ement-room--room-display-name room) - (ement-room-id room))) + (taxy-mapcar (lambda (room) + (list (ement-room--room-display-name room) + (ement-room-id room))) (taxy-fill (ement-session-rooms ement-session) (taxy-emptied ement-roomy)))) @@ -486,9 +486,9 @@ If you happen to like macros, ‘taxy’ works well with threading (i.e. (thread-last ement-roomy taxy-emptied (taxy-fill (ement-session-rooms ement-session)) - (taxy-map (lambda (room) - (list (ement-room--room-display-name room) - (ement-room-id room)))) + (taxy-mapcar (lambda (room) + (list (ement-room--room-display-name room) + (ement-room-id room)))) taxy-plain) @@ -552,15 +552,15 @@ Tag Table: Node: Top218 Node: Examples1101 Node: Usage9001 -Node: Dynamic taxys11084 -Node: Multi-level dynamic taxys13502 -Node: Reusable taxys15662 -Node: Threading macros19819 -Node: Magit section20340 -Node: Changelog20935 -Node: 01-pre21073 -Node: Development21167 -Node: License21338 +Node: Dynamic taxys11087 +Node: Multi-level dynamic taxys13505 +Node: Reusable taxys15665 +Node: Threading macros19834 +Node: Magit section20364 +Node: Changelog20959 +Node: 01-pre21097 +Node: Development21191 +Node: License21362 End Tag Table