branch: master
commit d6fb3c58ce624a89b3e7f5dbf6e2764f950c7fc7
Author: Arash Esbati <arash.esb...@gmail.com>
Commit: Arash Esbati <arash.esb...@gmail.com>

    Be more resilient when parsing arguments
    
    * style/xparse.el (LaTeX-xparse-macro-parse): Locally bind
    `case-fold-search' to nil and be case-sensitive when parsing the
    argument.
    Accept only braces as delimiters when moving over balanced
    expressions.  (bug#62997)
---
 style/xparse.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/style/xparse.el b/style/xparse.el
index 397a0c4b..9961cc6a 100644
--- a/style/xparse.el
+++ b/style/xparse.el
@@ -1,6 +1,6 @@
 ;;; xparse.el --- AUCTeX style for `xparse.sty' version 2022-07-05  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2013, 2020--2022 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2020--2023 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Author: Mosè Giordano <m...@gnu.org>
@@ -111,6 +111,8 @@ TYPE is one of the symbols mac or env."
     (let ((name (nth 1 xcmd))
           (spec (nth 2 xcmd))
           (what (nth 3 xcmd))
+          (case-fold-search nil)
+          (syntax (TeX-search-syntax-table ?\{ ?\}))
           args opt-star opt-token)
       (with-temp-buffer
         (set-syntax-table LaTeX-mode-syntax-table)
@@ -128,7 +130,7 @@ TYPE is one of the symbols mac or env."
                 ;; over [>=] and a balanced {}
                 ((looking-at-p "[>=]")
                  (forward-char 1)
-                 (forward-sexp))
+                 (with-syntax-table syntax (forward-sexp)))
                 ;; Mandatory arguments:
                 ;; m: Ask for input with "Text" as prompt
                 ((looking-at-p "m")
@@ -144,7 +146,7 @@ TYPE is one of the symbols mac or env."
                 ;; R<token1><token2>{default}
                 ((looking-at-p "R")
                  (re-search-forward "R\\(.\\)\\(.\\)" (+ (point) 3) t)
-                 (forward-sexp)
+                 (with-syntax-table syntax (forward-sexp))
                  (push `(LaTeX-arg-xparse-query
                          ,(match-string-no-properties 1)
                          ,(match-string-no-properties 2))
@@ -168,12 +170,12 @@ TYPE is one of the symbols mac or env."
                 ;; O{default}
                 ((looking-at-p "O")
                  (forward-char 1)
-                 (forward-sexp)
+                 (with-syntax-table syntax (forward-sexp))
                  (push (vector "Text") args))
                 ;; D<token1><token2>{default}
                 ((looking-at-p "D")
                  (re-search-forward "D\\(.\\)\\(.\\)" (+ (point) 3) t)
-                 (forward-sexp)
+                 (with-syntax-table syntax (forward-sexp))
                  (push (vector #'LaTeX-arg-xparse-query
                                (match-string-no-properties 1)
                                (match-string-no-properties 2))
@@ -205,7 +207,7 @@ TYPE is one of the symbols mac or env."
                          ,(match-string-no-properties 1))
                        args)
                  (when (looking-at-p TeX-grop)
-                   (forward-sexp)))
+                   (with-syntax-table syntax (forward-sexp))))
                 ;; Finished:
                 (t nil))))
       (if (eq type 'env)

Reply via email to