Function: texmathp-match-macro
texmathp-match-macro is a byte-compiled function defined in
texmathp.el.
Signature
(texmathp-match-macro BOUND)
Documentation
Find out if point is within the arguments of any of the Math macros.
Limit searches to BOUND. The return value is like ("\\macro" . (point)).
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/texmathp.el
(defun texmathp-match-macro (bound)
"Find out if point is within the arguments of any of the Math macros.
Limit searches to BOUND. The return value is like (\"\\macro\" . (point))."
(catch 'exit
(and (null texmathp-macros) (throw 'exit nil))
(let (pos cmd (syntax-table (syntax-table)))
(unwind-protect
(save-restriction
(save-excursion
(set-syntax-table texmathp-syntax-table)
(narrow-to-region (max 1 bound) (point))
;; Move back out of the current parenthesis
(while (condition-case nil (progn (up-list -1) t) (error nil))
;; Move back over any touching sexps (in fact also non-touching)
(while
(and
(cond
((memq (preceding-char) '(?\] ?\})))
((and
texmathp-allow-detached-args
(re-search-backward
"[]}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\="
bound t))
(goto-char (1+ (match-beginning 0))) t))
(if (eq (preceding-char) ?\})
;; Jump back over {}
(condition-case nil
(progn (backward-sexp) t)
(error nil))
;; Jump back over []. Modify syntax temporarily for this.
(unwind-protect
(progn
(modify-syntax-entry ?\{ ".")
(modify-syntax-entry ?\} ".")
(modify-syntax-entry ?\[ "(]")
(modify-syntax-entry ?\] ")[")
(condition-case nil
(progn (backward-sexp) t)
(error nil)))
(modify-syntax-entry ?\{ "(}")
(modify-syntax-entry ?\} "){")
(modify-syntax-entry ?\[ ".")
(modify-syntax-entry ?\] ".")
nil))))
(setq pos (point))
(and (memq (following-char) '(?\[ ?\{))
(re-search-backward "\\\\[*a-zA-Z]+\\=" nil t)
(setq cmd (buffer-substring-no-properties
(match-beginning 0) (match-end 0)))
(member cmd texmathp-macros)
(throw 'exit (cons cmd (point))))
(goto-char pos))
(throw 'exit nil)))
(set-syntax-table syntax-table)))))