aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2007-09-21 03:07:52 +0000
committerGlenn Morris2007-09-21 03:07:52 +0000
commit09b33024ce8d07cba0d27aaca78746ad5c812ee2 (patch)
tree616a4def510fac173afe1bfec1b2d9ed1c8ed2f5
parent007306f92da51d1e4b06d50e6937a51335e07577 (diff)
downloademacs-09b33024ce8d07cba0d27aaca78746ad5c812ee2.tar.gz
emacs-09b33024ce8d07cba0d27aaca78746ad5c812ee2.zip
(tex-validate-region): Handle escaped parens.
(tex-next-unmatched-eparen): New function. (latex-forward-sexp-1): Doc fix. Handle escaped parens. (latex-forward-sexp): Doc fix.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/textmodes/tex-mode.el29
2 files changed, 32 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 381728aef3f..1b8c6488fd2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12007-09-21 Glenn Morris <rgm@gnu.org> 12007-09-21 Glenn Morris <rgm@gnu.org>
2 2
3 * textmodes/tex-mode.el (tex-validate-region): Handle escaped parens.
4 (tex-next-unmatched-eparen): New function.
5 (latex-forward-sexp-1): Doc fix. Handle escaped parens.
6 (latex-forward-sexp): Doc fix.
7
3 * eshell/esh-mode.el (eshell-output-filter-functions): Add 8 * eshell/esh-mode.el (eshell-output-filter-functions): Add
4 eshell-postoutput-scroll-to-bottom. 9 eshell-postoutput-scroll-to-bottom.
5 10
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index f39502ecd27..3da099f2cb3 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1262,6 +1262,7 @@ area if a mismatch is found."
1262 (save-excursion 1262 (save-excursion
1263 (let ((pos (match-beginning 0))) 1263 (let ((pos (match-beginning 0)))
1264 (goto-char pos) 1264 (goto-char pos)
1265 (skip-chars-backward "\\\\") ; escaped parens
1265 (forward-sexp 1) 1266 (forward-sexp 1)
1266 (or (eq (preceding-char) (cdr (syntax-after pos))) 1267 (or (eq (preceding-char) (cdr (syntax-after pos)))
1267 (eq (char-after pos) (cdr (syntax-after (1- (point))))) 1268 (eq (char-after pos) (cdr (syntax-after (1- (point)))))
@@ -1400,6 +1401,21 @@ Return the value returned by the last execution of BODY."
1400 (looking-at "\\\\begin"))) 1401 (looking-at "\\\\begin")))
1401 (tex-next-unmatched-end))) 1402 (tex-next-unmatched-end)))
1402 1403
1404(defun tex-next-unmatched-eparen (otype)
1405 "Leave point after the next unmatched escaped closing parenthesis.
1406The string OPAREN is an opening parenthesis type: `(', `{', or `['."
1407 (condition-case nil
1408 (let ((ctype (char-to-string (cdr (aref (syntax-table)
1409 (string-to-char otype))))))
1410 (while (and (tex-search-noncomment
1411 (re-search-forward (format "\\\\[%s%s]" ctype otype)))
1412 (save-excursion
1413 (goto-char (match-beginning 0))
1414 (looking-at (format "\\\\%s" (regexp-quote otype)))))
1415 (tex-next-unmatched-eparen otype)))
1416 (wrong-type-argument (error "Unknown opening parenthesis type: %s" otype))
1417 (search-failed (error "Couldn't find closing escaped paren"))))
1418
1403(defun tex-goto-last-unclosed-latex-block () 1419(defun tex-goto-last-unclosed-latex-block ()
1404 "Move point to the last unclosed \\begin{...}. 1420 "Move point to the last unclosed \\begin{...}.
1405Mark is left at original location." 1421Mark is left at original location."
@@ -1429,8 +1445,10 @@ Mark is left at original location."
1429 (tex-last-unended-begin) 1445 (tex-last-unended-begin)
1430 (goto-char newpos)))))))) 1446 (goto-char newpos))))))))
1431 1447
1448;; Note this does not handle things like mismatched brackets inside
1449;; begin/end blocks.
1432(defun latex-forward-sexp-1 () 1450(defun latex-forward-sexp-1 ()
1433 "Like (forward-sexp 1) but aware of multi-char elements." 1451 "Like (forward-sexp 1) but aware of multi-char elements and escaped parens."
1434 (let ((pos (point)) 1452 (let ((pos (point))
1435 (forward-sexp-function)) 1453 (forward-sexp-function))
1436 (forward-sexp 1) 1454 (forward-sexp 1)
@@ -1447,10 +1465,17 @@ Mark is left at original location."
1447 ((looking-at "\\\\begin\\>") 1465 ((looking-at "\\\\begin\\>")
1448 (goto-char (match-end 0)) 1466 (goto-char (match-end 0))
1449 (tex-next-unmatched-end)) 1467 (tex-next-unmatched-end))
1468 ((looking-back "\\\\[])}]")
1469 (signal 'scan-error
1470 (list "Containing expression ends prematurely"
1471 (- (point) 2) (prog1 (point)
1472 (goto-char pos)))))
1473 ((looking-back "\\\\\\([({[]\\)")
1474 (tex-next-unmatched-eparen (match-string 1)))
1450 (t (goto-char newpos)))))) 1475 (t (goto-char newpos))))))
1451 1476
1452(defun latex-forward-sexp (&optional arg) 1477(defun latex-forward-sexp (&optional arg)
1453 "Like `forward-sexp' but aware of multi-char elements." 1478 "Like `forward-sexp' but aware of multi-char elements and escaped parens."
1454 (interactive "P") 1479 (interactive "P")
1455 (unless arg (setq arg 1)) 1480 (unless arg (setq arg 1))
1456 (let ((pos (point))) 1481 (let ((pos (point)))