emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/taxy 9d44dba 13/39: Change: taxy-apply -> taxy-map


From: ELPA Syncer
Subject: [elpa] externals/taxy 9d44dba 13/39: Change: taxy-apply -> taxy-map
Date: Fri, 27 Aug 2021 10:57:31 -0400 (EDT)

branch: externals/taxy
commit 9d44dba49984928c4b049cf6f6ce2df78f228fd6
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Change: taxy-apply -> taxy-map
---
 README.org | 10 +++++-----
 taxy.el    | 15 ++++++++-------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/README.org b/README.org
index fcef2ee..f6bbb51 100644
--- a/README.org
+++ b/README.org
@@ -158,7 +158,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-copy~, 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-apply~ 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-map~ to replace objects in 
a taxy with, e.g. a more useful representation.
 
 ** Dynamic taxys
 
@@ -262,14 +262,14 @@ 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-apply~ 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-map~ to replace the room 
structs with useful representations for display:
 
 #+BEGIN_SRC elisp
   (let ((ement-session (alist-get "@USER:HOST" ement-sessions nil nil 
#'equal)))
     (taxy-plain
-     (taxy-apply (lambda (room)
-                   (setf room (list (ement-room--room-display-name room)
-                                    (ement-room-id room))))
+     (taxy-map (lambda (room)
+                   (list (ement-room--room-display-name room)
+                         (ement-room-id room)))
        (taxy-fill (ement-session-rooms ement-session)
                   (taxy-copy ement-roomy)))))
 #+END_SRC
diff --git a/taxy.el b/taxy.el
index a7d4073..adbf69e 100644
--- a/taxy.el
+++ b/taxy.el
@@ -83,16 +83,17 @@ Clears TAXY's objects and those of its descendant taxys."
         (taxy-taxys taxy) (mapcar #'taxy-copy (taxy-taxys taxy)))
   taxy)
 
-(defun taxy-apply (fn taxy)
-  "Return TAXY, having applied FN to each object in it, including descendants.
-Used to apply side effects, e.g. to transform objects into a more
-useful form after classification."
+(defun taxy-map (fn taxy)
+  "Return TAXY, having replaced each object in it with the value of FN on it.
+Replaces every object in TAXY and its descendants.  Useful to
+replace objects with a more useful form after classification."
   (declare (indent defun))
-  ;; I can't seem to find a way to do this without consing new lists.
-  ;; Even using `cl-loop' with `in-ref' didn't work.
+  ;; It might be preferable to destructively replace objects rather
+  ;; than consing new lists, but I haven't found a way that works
+  ;; (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-apply fn taxy)))
+                                   collect (taxy-map fn taxy)))
   taxy)
 
 (cl-defun taxy-take-keyed (key-fn object taxy &key (key-name-fn #'identity))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]