Function: hypb:narrow-to-max-lines

hypb:narrow-to-max-lines is a byte-compiled function defined in hypb.el.

Signature

(hypb:narrow-to-max-lines MAX-LINES FUNC &rest ARGS)

Documentation

Narrow buffer to +/- (+ 1 MAX-LINES) including current line.

Then call FUNC with rest of ARGS and afterwards restore prior narrowing and prior point.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hypb.el
(defun hypb:narrow-to-max-lines (max-lines func &rest args)
  "Narrow buffer to +/- (+ 1 MAX-LINES) including current line.
Then call FUNC with rest of ARGS and afterwards restore prior narrowing and
prior point."
  (save-excursion
    (save-restriction
      (when (integerp max-lines)
	(if (zerop max-lines)
	    (narrow-to-region (point) (point)) ;; Empty range
	  ;; Allow for +/- (+ 1 max-lines) including current line so start
	  ;; and end delimiters can be on separate lines.  Before returning,
	  ;; this function checks that any matched string has <= max-lines.
	  (narrow-to-region (line-beginning-position
			     (when max-lines (1+ (- max-lines))))
			    (line-end-position (1+ max-lines)))))
      (apply func args))))