Function: hyrolo-map-level

hyrolo-map-level is a byte-compiled function defined in hyrolo.el.

Signature

(hyrolo-map-level FUNC LEVEL-REGEXP &optional MAX-GROUPINGS)

Documentation

Perform FUNC in current buffer on groupings of entries at level LEVEL-REGEXP.

Current buffer should be an editable HyRolo source location, not the match buffer.

Limit to a maximum of optional argument MAX-GROUPINGS. Nil value of MAX-GROUPINGS means all groupings at the given level. FUNC should take two arguments, the start and the end of the region that it should manipulate. LEVEL-REGEXP should match the prefix text of any rolo entry of the given level, not the beginning of a line (^); an example, might be (regexp-quote "**") to match level two.

Return number of groupings matched.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hyrolo.el
(defun hyrolo-map-level (func level-regexp &optional max-groupings)
  "Perform FUNC in current buffer on groupings of entries at level LEVEL-REGEXP.
Current buffer should be an editable HyRolo source location, not
the match buffer.

Limit to a maximum of optional argument MAX-GROUPINGS.  Nil value
of MAX-GROUPINGS means all groupings at the given level.  FUNC
should take two arguments, the start and the end of the region
that it should manipulate.  LEVEL-REGEXP should match the prefix
text of any rolo entry of the given level, not the beginning of a
line (^); an example, might be (regexp-quote \"**\") to match
level two.

Return number of groupings matched."
  (if (not (or (null max-groupings) (< 0 max-groupings)))
      0
    (let* ((num-found 0)
	   (total-found 0)
	   (exact-level-regexp (concat "^\\(" level-regexp "\\)[ \t\n\r\f]"))
	   (buffer-read-only)
	   (level-len (/ (length level-regexp) 2)))
      (goto-char (point-min))
      ;; Pass buffer header if it exists
      (hyrolo-hdr-move-after-p)
      ;; With 'max-groupings' non-nil, loop over all following entries
      ;; with the same parent matching 'level-regexp'.  Otherwise, maximally
      ;; loop over 'max-groupings' such entries.
      (while (and (> level-len 0) (or (null max-groupings) (< total-found max-groupings))
		  (< 0 (setq num-found
			     (hyrolo-map-single-subtree func exact-level-regexp level-len buffer-read-only))))
	(setq total-found (+ num-found total-found)))
      ;; Caller may have adjusted entry visibility, so don't do this: (outline-show-all)
      total-found)))