Function: hyrolo-map-entries

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

Signature

(hyrolo-map-entries SEXP HYROLO-BUF DISPLAY-BUF HDR-POS &optional COUNT-ONLY INCLUDE-SUB-ENTRIES)

Documentation

Apply logical SEXP to each entry in HYROLO-BUF.

Write out matching entries to DISPLAY-BUF. HDR-POS is a cons of
(start . end) positions of HYROLO-BUF's file header, if any;
otherwise, nil.

If optional COUNT-ONLY is non-nil, don't display entries, return count of matching entries only. If optional INCLUDE-SUB-ENTRIES flag is non-nil, apply SEXP across all sub-entries at once. Default is to apply SEXP to each entry and sub-entry separately. Entries are displayed with all of their sub-entries unless INCLUDE-SUB-ENTRIES is nil.

SEXP should utilize the free variables start and end as the region on which to operate.

Return the number of evaluations of SEXP that match entries.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hyrolo-logic.el
;;
;; INTERNAL FUNCTIONS.
;;

(defun hyrolo-map-entries (sexp hyrolo-buf display-buf hdr-pos &optional count-only include-sub-entries)
  "Apply logical SEXP to each entry in HYROLO-BUF.
Write out matching entries to DISPLAY-BUF.  HDR-POS is a cons of
\(start . end) positions of HYROLO-BUF's file header, if any;
otherwise, nil.

If optional COUNT-ONLY is non-nil, don't display entries, return
count of matching entries only.  If optional INCLUDE-SUB-ENTRIES
flag is non-nil, apply SEXP across all sub-entries at once.
Default is to apply SEXP to each entry and sub-entry separately.
Entries are displayed with all of their sub-entries unless
INCLUDE-SUB-ENTRIES is nil.

SEXP should utilize the free variables `start' and `end' as the
region on which to operate.

Return the number of evaluations of SEXP that match entries."
  (let* ((start)
	 (end)
	 (end-entry-hdr)
	 (num-found 0))
    (while (re-search-forward hyrolo-hdr-and-entry-regexp nil t)
      (setq end-entry-hdr (match-end hyrolo-entry-group-number)
	    start (match-beginning hyrolo-entry-group-number)
	    end (hyrolo-to-entry-end include-sub-entries))
      (let ((result (eval sexp `((start . ,start) (end . ,end)))))
	(unless count-only
	  (and result (= num-found 0)
	       (let* ((src (or (hypb:buffer-file-name hyrolo-buf)
			       hyrolo-buf))
		      (src-line
		       (format
			(concat (if (boundp 'hbut:source-prefix)
				    hbut:source-prefix
				  "@loc> ")
				"%s")
			(prin1-to-string src))))
		 (set-buffer display-buf)
		 (goto-char (point-max))
		 (if hdr-pos
		     (progn
		       (insert-buffer-substring
			hyrolo-buf (car hdr-pos) (cdr hdr-pos))
		       (insert src-line "\n\n"))
		   (insert (format hyrolo-hdr-format src-line)))
		 (set-buffer hyrolo-buf))))
	(if result
	    (progn (goto-char end)
		   (setq num-found (1+ num-found))
		   (unless count-only
		     (append-to-buffer display-buf start end)
		     (hyrolo--cache-major-mode hyrolo-buf)))
	  (goto-char end-entry-hdr))))
    num-found))