Function: kview:map-expanded-tree

kview:map-expanded-tree is a byte-compiled function defined in kview.el.

Signature

(kview:map-expanded-tree FUNC KVIEW &optional TOP-P)

Documentation

Temporarily expand the tree at point, apply FUNC to the tree in the KVIEW.

Return results as a list. This is for a FUNC that requires all cells in the tree be fully visible and expanded before operating upon it. If this is not the case, use kview:map-tree instead. FUNC may not change the number of or the order of the cells.

With optional TOP-P non-nil, maps over all of kview's cells.

FUNC should take one argument, the kview with the tree to map, and should operate upon the cell at point.

The variable cell-indent contains the indentation value of the first cell mapped when FUNC is called so that it may be tested against this value. The variable lbl-sep-len contains the label separator length.

See also kview:map-region, kview:map-branch and kview:map-siblings.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kview.el
(defun kview:map-expanded-tree (func kview &optional top-p)
  "Temporarily expand the tree at point, apply FUNC to the tree in the KVIEW.
Return results as a list.
This is for a FUNC that requires all cells in the tree be fully visible and
expanded before operating upon it.  If this is not the case, use
`kview:map-tree' instead.  FUNC may not change the number of or the order of
the cells.

With optional TOP-P non-nil, maps over all of kview's cells.

FUNC should take one argument, the kview with the tree to map, and should
operate upon the cell at point.

The variable `cell-indent' contains the indentation value of the
first cell mapped when FUNC is called so that it may be tested
against this value.  The variable `lbl-sep-len' contains the label
separator length.

See also `kview:map-region', `kview:map-branch' and `kview:map-siblings'."
    (with-current-buffer (kview:buffer kview)
      (save-excursion
	;; Next line ensures point is in the root of the current tree if
	;; the tree is at all hidden.
	(unless top-p
	  (kotl-mode:beginning-of-line))
	(let* ((results)
	       (lbl-sep-len (kview:label-separator-length kview))
	       (start (set-marker (make-marker) (if top-p (point-min) (point))))
	       (end (set-marker (make-marker) (if top-p (point-max) (save-excursion (kotl-mode:tree-end)))))
	       (collapsed-cells (kview:get-cells-status kview start end))
	       cell-indent)
	  ;;
	  ;; Expand all cells in tree.
	  (outline-flag-region start end nil)
	  ;;
	  (if top-p
	      (progn (goto-char (point-min))
		     (kview:end-of-actual-line)
		     ;; Terminate when no further cells to process.
		     (while (progn (setq results (cons (funcall func kview) results))
				   (kcell-view:next nil lbl-sep-len))))
	    (setq cell-indent (kcell-view:indent nil lbl-sep-len))
	    ;; Terminate when no further cells or when reach a cell at an equal
	    ;; or higher level in the kotl than the first cell that we processed.
	    (while (and (setq results (cons (funcall func kview) results))
			(kcell-view:next nil lbl-sep-len)
			(>= (- (kcell-view:indent nil lbl-sep-len) cell-indent)
			    (kview:level-indent kview)))))
	  ;;
	  ;; Restore status of temporarily expanded cells.
	  (when (remq 0 collapsed-cells)
	    (kview:set-cells-status kview start end collapsed-cells))
	  ;;
	  ;; Remove markers.
	  (set-marker start nil)
	  (set-marker end nil)
	  (nreverse results)))))