Function: hierarchy-map-hierarchy
hierarchy-map-hierarchy is a byte-compiled function defined in
hierarchy.el.gz.
Signature
(hierarchy-map-hierarchy FUNCTION HIERARCHY)
Documentation
Apply FUNCTION to each item of HIERARCHY in a new hierarchy.
FUNCTION should take 2 parameters, the current item and its indentation level (a number), and should return an item to be added to the new hierarchy.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/hierarchy.el.gz
(defun hierarchy-map-hierarchy (function hierarchy)
"Apply FUNCTION to each item of HIERARCHY in a new hierarchy.
FUNCTION should take 2 parameters, the current item and its
indentation level (a number), and should return an item to be
added to the new hierarchy."
(let* ((items (make-hash-table :test #'equal))
(transform (lambda (item) (map-elt items item))))
;; Make 'items', a table mapping original items to their
;; transformation
(hierarchy-map (lambda (item indent)
(map-put! items item (funcall function item indent)))
hierarchy)
(hierarchy--make
:roots (mapcar transform (hierarchy-roots hierarchy))
:parents (let ((result (make-hash-table :test #'equal)))
(map-apply (lambda (child parent)
(map-put! result
(funcall transform child)
(funcall transform parent)))
(hierarchy--parents hierarchy))
result)
:children (let ((result (make-hash-table :test #'equal)))
(map-apply (lambda (parent children)
(map-put! result
(funcall transform parent)
(seq-map transform children)))
(hierarchy--children hierarchy))
result)
:seen-items (let ((result (make-hash-table :test #'equal)))
(map-apply (lambda (item v)
(map-put! result
(funcall transform item)
v))
(hierarchy--seen-items hierarchy))
result))))