emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/textmodes/tex-mode.el,v


From: Martin Rudalics
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/tex-mode.el,v
Date: Thu, 25 Sep 2008 08:37:06 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Martin Rudalics <m061211>       08/09/25 08:37:06

Index: tex-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/tex-mode.el,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -b -r1.218 -r1.219
--- tex-mode.el 23 Sep 2008 08:25:44 -0000      1.218
+++ tex-mode.el 25 Sep 2008 08:37:06 -0000      1.219
@@ -1482,18 +1482,25 @@
     (push-mark)
     (goto-char spot)))
 
+(defvar latex-handle-escaped-parens t)
+
 ;; 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 "\\\\\\(begin\\>\\|[[({]\\)")
+    (cond ((looking-at
+           (if latex-handle-escaped-parens
+               "\\\\\\(begin\\>\\|[[({]\\)"
+             "\\\\begin\\>"))
           (signal 'scan-error
                   (list "Containing expression ends prematurely"
                         (point) (prog1 (point) (goto-char pos)))))
-         ((looking-at "\\\\\\([])}]\\)")
+         ((and latex-handle-escaped-parens
+               (looking-at "\\\\\\([])}]\\)"))
           (tex-last-unended-eparen (match-string 1)))
          ((eq (char-after) ?{)
           (let ((newpos (point)))
@@ -1508,6 +1515,7 @@
 ;; begin/end blocks.
 ;; Needs to handle escaped parens for tex-validate-*.
 ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2007-09/msg00038.html
+;; Does not handle escaped parens when latex-handle-escaped-parens is nil.
 (defun latex-forward-sexp-1 ()
   "Like (forward-sexp 1) but aware of multi-char elements and escaped parens."
   (let ((pos (point))
@@ -1528,12 +1536,14 @@
        (tex-next-unmatched-end))
        ;; A better way to handle this, \( .. \) etc, is probably to
        ;; temporarily change the syntax of the \ in \( to punctuation.
-       ((looking-back "\\\\[])}]")
+       ((and latex-handle-escaped-parens
+            (looking-back "\\\\[])}]"))
        (signal 'scan-error
                (list "Containing expression ends prematurely"
                      (- (point) 2) (prog1 (point)
                                      (goto-char pos)))))
-       ((looking-back "\\\\\\([({[]\\)")
+       ((and latex-handle-escaped-parens
+            (looking-back "\\\\\\([({[]\\)"))
        (tex-next-unmatched-eparen (match-string 1)))
        (t (goto-char newpos))))))
 
@@ -2568,11 +2578,22 @@
            (indent-line-to indent)
          (save-excursion (indent-line-to indent)))))))
 
+(defcustom latex-indent-within-escaped-parens nil
+  "Non-nil means add extra indent to text within escaped parens.
+When this is non-nil, text within matching pairs of escaped
+parens is indented at the column following the open paren.  The
+default value does not add any extra indent thus providing the
+behavior of Emacs 22 and earlier."
+  :type 'boolean
+  :group 'tex
+  :version "23.1")
+
 (defun latex-find-indent (&optional virtual)
   "Find the proper indentation of text after point.
 VIRTUAL if non-nil indicates that we're only trying to find the indentation
   in order to determine the indentation of something else.
 There might be text before point."
+  (let ((latex-handle-escaped-parens latex-indent-within-escaped-parens))
   (save-excursion
     (skip-chars-forward " \t")
     (or
@@ -2588,9 +2609,10 @@
      ;; Put leading close-paren where the matching open paren would be.
      (let (escaped)
        (and (or (eq (latex-syntax-after) ?\))
-               ;; Try to handle escaped close parens but keep original
-               ;; position if it doesn't work out.
-               (setq escaped (looking-at "\\\\\\([])}]\\)")))
+                 ;; Try to handle escaped close parens but keep
+                 ;; original position if it doesn't work out.
+                 (and latex-handle-escaped-parens
+                      (setq escaped (looking-at "\\\\\\([])}]\\)"))))
            (ignore-errors
             (save-excursion
               (when escaped
@@ -2664,7 +2686,7 @@
                 ;; we're indenting the first argument.
                 (min (current-column) (+ tex-indent-arg col))
               (skip-syntax-forward " ")
-              (current-column))))))))))
+                (current-column)))))))))))
 ;;; DocTeX support
 
 (defun doctex-font-lock-^^A ()




reply via email to

[Prev in Thread] Current Thread [Next in Thread]