Function: hyrolo-map-matches

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

Signature

(hyrolo-map-matches FUNC &optional NARROW-FLAG)

Documentation

Map FUNC with no arguments over the current buffer of entries.

FUNC must not move point, as this function will restore it. If on a display match entry, set the appropriate major mode based on its source location.

With point in the HyRolo display matches buffer and optional NARROW-FLAG non-nil, narrow to the current file of matches prior to applying FUNC.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hyrolo.el
(defun hyrolo-map-matches (func &optional narrow-flag)
  "Map FUNC with no arguments over the current buffer of entries.
FUNC must not move point, as this function will restore it.  If
on a display match entry, set the appropriate major mode based on
its source location.

With point in the HyRolo display matches buffer and optional
NARROW-FLAG non-nil, narrow to the current file of matches
prior to applying FUNC."
  (when (zerop (buffer-size (current-buffer)))
    (error "(hryolo-map-matches): No HyRolo matches in current buffer"))
  (let ((display-buf (get-buffer hyrolo-display-buffer)))
    (if (eq (current-buffer) display-buf)
	(let ((bounds hyrolo--cache-loc-match-bounds)
	      (ofont-lock font-lock-mode)
	      (omode major-mode)
	      (ostart (point-min))
	      (oend (point-max))
	      start
	      end)
	  (unwind-protect
	      (save-excursion
		(while (setq start (car bounds)
			     end (cadr bounds))
		  (setq end (1- (or end (point-max)))
			bounds (cdr bounds))
		  (when narrow-flag
		    (narrow-to-region start end))
		  (goto-char start)
		  (let ((font-lock-mode)
                        (pos (1+ start)))
                    (save-excursion
                      (goto-char pos)
		      (hyrolo--pre-display-buffer))
		    (setq font-lock-mode nil) ;; Prevent Org mode from font-locking
		    (hyrolo--funcall-with-outline-regexp func))))
	    (when narrow-flag
	      ;; Restore original restriction
	      (narrow-to-region ostart oend))
	    ;; Restore original mode and font-locking
	    (funcall omode)
	    (font-lock-mode (if ofont-lock 1 0))
	    (when (and (fboundp 'orgtbl-mode) orgtbl-mode)
	      ;; Disable as overrides single letter keys
	      (orgtbl-mode 0))
	    ;; Need to leave point on a visible character or since
	    ;; hyrolo uses reveal-mode, redisplay will rexpand
	    ;; hidden entries to make point visible.
	    (hyrolo-back-to-visible-point)
	    ;; This pause forces a window redisplay that maximizes the
	    ;; entries displayed for any final location of point.
	    (sit-for 0.001)))
      (save-excursion
        (hyrolo--funcall-with-outline-regexp func)))))