Function: latex-backward-sexp-1

latex-backward-sexp-1 is a byte-compiled function defined in tex-mode.el.gz.

Signature

(latex-backward-sexp-1)

Documentation

Like (backward-sexp 1) but aware of multi-char elements and escaped parens.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/tex-mode.el.gz
;; Don't think this one actually _needs_ (for the purposes of
;; tex-mode) to handle escaped parens.
;; Does not handle escaped parens when latex-handle-escaped-parens is nil.
(defun latex-backward-sexp-1 ()
  "Like (backward-sexp 1) but aware of multi-char elements and escaped parens."
  (let ((pos (point))
	(forward-sexp-function))
    (backward-sexp 1)
    (cond ((looking-at
	    (if latex-handle-escaped-parens
		"\\\\\\(begin\\>\\|[[({]\\)"
	      "\\\\begin\\>"))
	   (signal 'scan-error
		   (list "Containing expression ends prematurely"
			 (point) (prog1 (point) (goto-char pos)))))
	  ((and latex-handle-escaped-parens
		(looking-at "\\\\\\([])}]\\)"))
	   (tex-last-unended-eparen (match-string 1)))
	  ((eq (char-after) ?{)
	   (let ((newpos (point)))
	     (when (ignore-errors (backward-sexp 1) t)
	       (if (or (looking-at "\\\\end\\>")
		       ;; In case the \\ ends a verbatim section.
		       (and (looking-at "end\\>") (eq (char-before) ?\\)))
		   (tex-last-unended-begin)
		 (goto-char newpos))))))))