Function: org-in-regexp

org-in-regexp is a byte-compiled function defined in org-macs.el.

Signature

(org-in-regexp REGEXP &optional NLINES VISUALLY)

Documentation

Check if point is inside a match of REGEXP.

Normally only the current line is checked, but you can include NLINES extra lines around point into the search. If VISUALLY is set, require that the cursor is not after the match but really on, so that the block visually is on the match.

Return nil or a cons cell (BEG . END) where BEG and END are, respectively, the positions at the beginning and the end of the match.

Aliases

org-at-regexp-p (obsolete since 8.3)

Source Code

;; Defined in ~/.emacs.d/elpa/org-9.8.2/org-macs.el
(defun org-in-regexp (regexp &optional nlines visually)
  "Check if point is inside a match of REGEXP.

Normally only the current line is checked, but you can include
NLINES extra lines around point into the search.  If VISUALLY is
set, require that the cursor is not after the match but really
on, so that the block visually is on the match.

Return nil or a cons cell (BEG . END) where BEG and END are,
respectively, the positions at the beginning and the end of the
match."
  (catch :exit
    (let ((pos (point))
          (eol (line-end-position (if nlines (1+ nlines) 1))))
      (save-excursion
	(forward-line (- (or nlines 0)))
	(while (and (re-search-forward regexp eol t)
		    (<= (match-beginning 0) pos))
	  (let ((end (match-end 0)))
	    (when (or (> end pos) (and (= end pos) (not visually)))
	      (throw :exit (cons (match-beginning 0) (match-end 0))))))))))