Function: TeX-search-unescaped

TeX-search-unescaped is a byte-compiled function defined in tex.el.

Signature

(TeX-search-unescaped PATTERN &optional DIRECTION REGEXP-FLAG BOUND NOERROR)

Documentation

Search for unescaped PATTERN in a certain DIRECTION.

DIRECTION can be indicated by the symbols forward and backward. If DIRECTION is omitted, a forward search is carried out. If REGEXP-FLAG is non-nil, PATTERN may be a regular expression, otherwise a string. The optional argument BOUND limits the search to the respective buffer position. If NOERROR is non-nil, return nil if the search failed instead of throwing an error. A pattern is escaped, if it is preceded by an odd number of escape characters.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-search-unescaped (pattern
                             &optional direction regexp-flag bound noerror)
  "Search for unescaped PATTERN in a certain DIRECTION.
DIRECTION can be indicated by the symbols `forward' and `backward'.
If DIRECTION is omitted, a forward search is carried out.
If REGEXP-FLAG is non-nil, PATTERN may be a regular expression,
otherwise a string.
The optional argument BOUND limits the search to the respective
buffer position.
If NOERROR is non-nil, return nil if the search failed instead of
throwing an error.
A pattern is escaped, if it is preceded by an odd number of escape
characters."
  (let ((search-fun (if (eq direction 'backward)
                        (if regexp-flag #'re-search-backward #'search-backward)
                      (if regexp-flag #'re-search-forward #'search-forward))))
    (catch 'found
      (while (funcall search-fun pattern bound noerror)
        (when (not (TeX-escaped-p (match-beginning 0)))
          (throw 'found (point)))))))