auctex-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex 05d28dfe06 12/30: Improve check for verbatim con


From: Tassilo Horn
Subject: [elpa] externals/auctex 05d28dfe06 12/30: Improve check for verbatim content
Date: Thu, 7 Dec 2023 03:51:07 -0500 (EST)

branch: externals/auctex
commit 05d28dfe06a54c27fd889d3f0c0e43f27fcc514e
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>

    Improve check for verbatim content
    
    * tex.el (TeX-brace-count-line): Take into account the return
    value of the function `TeX-verbatim-p' depending on the last
    detected character.
---
 tex.el | 46 ++++++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/tex.el b/tex.el
index 6ab2181654..7c3c17ea16 100644
--- a/tex.el
+++ b/tex.el
@@ -5491,22 +5491,36 @@ additional characters."
                                           '(?\{ ?\} ?\\))
                                     (TeX-in-comment))))
                  (forward-char)
-                 ;; If inside a verbatim construct, just return t and
-                 ;; proceed, otherwise start counting:
-                 (if (TeX-verbatim-p)
-                     t
-                   (cond ((memq char (append
-                                      TeX-indent-open-delimiters
-                                      '(?\{)))
-                          (setq count (+ count TeX-brace-indent-level)))
-                         ((memq char (append
-                                      TeX-indent-close-delimiters
-                                      '(?\})))
-                          (setq count (- count TeX-brace-indent-level)))
-                         ((eq char ?\\)
-                          (when (< (point) limit)
-                            (forward-char)
-                            t)))))))
+                 ;; We have to cater for verb-macros with braces and
+                 ;; what the function `TeX-verbatim-p' returns dep. on
+                 ;; the position of point:
+                 ;;       \Verb{\ or { or } are not special}.
+                 ;;            ^-> nil                     ^-> t
+                 (cond ((memq char (append
+                                    TeX-indent-open-delimiters
+                                    '(?\{)))
+                        ;; Point is one char after `{', so check if
+                        ;; we're inside a verb macro and return t,
+                        ;; otherwise increase `count':
+                        (if (TeX-verbatim-p)
+                            t
+                          (setq count (+ count TeX-brace-indent-level))))
+                       ((memq char (append
+                                    TeX-indent-close-delimiters
+                                    '(?\})))
+                        ;; Point if one char after `}', so check if the
+                        ;; char before point is inside a verb macro:
+                        (if (TeX-verbatim-p (1- (point)))
+                            t
+                          (setq count (- count TeX-brace-indent-level))))
+                       ((eq char ?\\)
+                        ;; Point is one char-after after `\', so check
+                        ;; if the char before point is inside a verb
+                        ;; macro:
+                        (when (< (point) limit)
+                          (unless (TeX-verbatim-p (1- (point)))
+                            (forward-char))
+                          t))))))
       count)))
 
 ;;; Navigation




reply via email to

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