[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 380bc4a 06/71: Handle optional em
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex 380bc4a 06/71: Handle optional embellishment arguments correctly |
Date: |
Fri, 17 Dec 2021 15:00:25 -0500 (EST) |
branch: externals/auctex
commit 380bc4a2ef1eceb3e8536bc3e0c7ddcc978e63e9
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Handle optional embellishment arguments correctly
* style/xparse.el (LaTeX-xparse-macro-regexp)
(LaTeX-xparse-environment-regexp): Include the entire match text
to avoid ambiguity.
(LaTeX-arg-xparse-embellishment-query): New function.
(LaTeX-xparse-macro-parse): Handle embellishments (e/E argument
type) correctly.
---
style/xparse.el | 94 ++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 66 insertions(+), 28 deletions(-)
diff --git a/style/xparse.el b/style/xparse.el
index 2a9dff4..314938e 100644
--- a/style/xparse.el
+++ b/style/xparse.el
@@ -1,6 +1,6 @@
;;; xparse.el --- AUCTeX style for `xparse.sty' version 2020-03-06 -*-
lexical-binding: t; -*-
-;; Copyright (C) 2013, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2020, 2021 Free Software Foundation, Inc.
;; Maintainer: auctex-devel@gnu.org
;; Author: Mosè Giordano <mose@gnu.org>
@@ -28,10 +28,8 @@
;; This file adds basic support for `xparse.sty' version 2020-03-06.
;; It parses argument specification of macros and environments.
-;; Currently, this style doesn't parse the embellishments specifiers
-;; `e' and `E'. The "yet not more supported" specifiers `l', `u', `g'
-;; and `G' are ignored completely and may lead to wrong parsing
-;; results.
+;; The "yet not more supported" specifiers `l', `u', `g' and `G' are
+;; ignored completely and may lead to wrong parsing results.
;;; Code:
@@ -48,7 +46,7 @@
(defvar LaTeX-xparse-macro-regexp
`(,(concat
(regexp-quote TeX-esc)
- "\\(?:New\\|Renew\\|Provide\\|Declare\\)"
+ "\\(New\\|Renew\\|Provide\\|Declare\\)"
"\\(?:Expandable\\)?"
"DocumentCommand"
"[ \t\n\r]*"
@@ -60,7 +58,7 @@
"}?"
"[ \t\n\r]*"
"{\\([^}{]*\\({[^}{]*\\({[^}{]*\\({[^}{]*}[^}{]*\\)*}[^}{]*\\)*}[^}{]*\\)*\\)}")
- (1 2) LaTeX-auto-xparse-macro)
+ (0 2 3 1) LaTeX-auto-xparse-macro)
"Matches macros by xparse package.")
(TeX-auto-add-type "xparse-environment" "LaTeX")
@@ -68,7 +66,7 @@
(defvar LaTeX-xparse-environment-regexp
`(,(concat
(regexp-quote TeX-esc)
- "\\(?:New\\|Renew\\|Provide\\|Declare\\)"
+ "\\(New\\|Renew\\|Provide\\|Declare\\)"
"DocumentEnvironment"
"[ \t\n\r]*"
"{"
@@ -78,7 +76,7 @@
"}"
"[ \t\n\r]*"
"{\\([^}{]*\\({[^}{]*\\({[^}{]*\\({[^}{]*}[^}{]*\\)*}[^}{]*\\)*}[^}{]*\\)*\\)}")
- (1 2) LaTeX-auto-xparse-environment)
+ (0 2 3 1) LaTeX-auto-xparse-environment)
"Matches environments by xparse package.")
(defun LaTeX-arg-xparse-query (optional op-brace cl-brace &optional prompt)
@@ -92,14 +90,27 @@ replaces the standard one."
(TeX-read-string (TeX-argument-prompt optional prompt "Text"))
optional)))
+(defun LaTeX-arg-xparse-embellishment-query (_optional embellish)
+ "Special insert function for embellishments from xparse package.
+Compatibility argument OPTIONAL is ignored. EMBELLISH is a
+string with parsed elements inserted in the buffer. This
+function also sets the value of `TeX-exit-mark' where the point
+will be once the insertion is completed."
+ (let (p)
+ (just-one-space)
+ (setq p (point))
+ (insert embellish)
+ (set-marker TeX-exit-mark (1+ p))))
+
(defun LaTeX-xparse-macro-parse (type)
"Process parsed macro and environment definitions.
-TYPE is one of the symobols mac or env."
+TYPE is one of the symbols mac or env."
(dolist (xcmd (if (eq type 'mac)
(LaTeX-xparse-macro-list)
(LaTeX-xparse-environment-list)))
- (let ((name (car xcmd))
- (spec (cadr xcmd))
+ (let ((name (nth 1 xcmd))
+ (spec (nth 2 xcmd))
+ (what (nth 3 xcmd))
args opt-star opt-token)
(with-temp-buffer
(set-syntax-table LaTeX-mode-syntax-table)
@@ -175,29 +186,56 @@ TYPE is one of the symobols mac or env."
((looking-at-p "t")
(re-search-forward "t\\(.\\)" (+ (point) 2) t)
(setq opt-token (match-string-no-properties 1)))
- ;; e & E are currently ignored. e: If looking at a
- ;; {, move one balanced expression, otherwise only
- ;; one character.
+ ;; e{tokes} a set of optional embellishments
((looking-at-p "e")
(forward-char)
(if (looking-at-p TeX-grop)
- (forward-sexp)
- (forward-char)))
- ;; E
+ (re-search-forward "{\\([^}]+\\)}" nil t)
+ (re-search-forward "\\(.\\)" (1+ (point)) t))
+ (push `(LaTeX-arg-xparse-embellishment-query
+ ,(match-string-no-properties 1))
+ args))
+ ;; E{tokes}{defaults}
((looking-at-p "E")
(forward-char)
(if (looking-at-p TeX-grop)
- (forward-sexp)
- (forward-char))
- (if (looking-at-p TeX-grop)
- (forward-sexp)
- (forward-char)))
+ (re-search-forward "{\\([^}]+\\)}" nil t)
+ (re-search-forward "\\(.\\)" (1+ (point)) t))
+ (push `(LaTeX-arg-xparse-embellishment-query
+ ,(match-string-no-properties 1))
+ args)
+ (when (looking-at-p TeX-grop)
+ (forward-sexp)))
;; Finished:
(t nil))))
(if (eq type 'env)
- (LaTeX-add-environments `(,name
- LaTeX-env-args
- ,@(reverse (copy-sequence args))))
+ ;; Parsed enviroments: If we are Renew'ing or Delare'ing, we
+ ;; delete the enviroment first from `LaTeX-environment-list'
+ ;; before adding the new one. We have to sort the value of
+ ;; `LaTeX-environment-list' by running the function of the
+ ;; same name:
+ (progn
+ (when (member what '("Renew" "Declare"))
+ (LaTeX-environment-list)
+ (setq LaTeX-environment-list
+ (assoc-delete-all name LaTeX-environment-list)))
+ (LaTeX-add-environments `(,name
+ LaTeX-env-args
+ ,@(reverse (copy-sequence args)))))
+ ;; Parsed macros: If we are Renew'ing or Delare'ing, we delete
+ ;; the macros first from `TeX-symbol-list' before adding the
+ ;; new ones. We have to sort the value of `TeX-symbol-list'
+ ;; by running the function of the same name:
+ (when (member what '("Renew" "Declare"))
+ (TeX-symbol-list)
+ (setq TeX-symbol-list
+ (assoc-delete-all name TeX-symbol-list))
+ (when opt-star
+ (setq TeX-symbol-list
+ (assoc-delete-all (concat name "*" TeX-symbol-list))))
+ (when opt-token
+ (setq TeX-symbol-list
+ (assoc-delete-all (concat name opt-token TeX-symbol-list)))))
(TeX-add-symbols (cons name
(reverse (copy-sequence args))))
(when opt-star
@@ -275,9 +313,9 @@ TYPE is one of the symobols mac or env."
"ProcessedArgument"
"ReverseBoolean"
'("SplitArgument" "Number" "Token")
- "SplitList"
+ '("SplitList" "Token")
"TrimSpaces"
- '("ProcessList" "List" "Functiom")
+ '("ProcessList" "List" "Function")
;; Access to the argument specification
'("GetDocumentCommandArgSpec" TeX-arg-macro)
'("GetDocumentEnvironmmentArgSpec" TeX-arg-environment)
- [AUCTeX-diffs] [elpa] externals/auctex 6902d05 42/71: Improve handling of key=vals in style/minted.el, (continued)
- [AUCTeX-diffs] [elpa] externals/auctex 6902d05 42/71: Improve handling of key=vals in style/minted.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex fd73414 11/71: ; * doc/changes.texi: Add supplementary notice., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 464fd34 20/71: * tests/latex/latex-test.el (LaTeX-flush-left-indent): New test., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 16bcc8d 21/71: ; * tex.el (TeX-source-correlate-mode): Quote function name by #'., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2af20f4 27/71: ; Silence TeX warnings, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 363b778 56/71: Update style/multicol.el to package version 1.9b, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 7fa094f 14/71: ; * style/tabulary.el ("tabulary"): Really append the entry., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2ee9a07 71/71: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0752650 44/71: Don't use obsolete @inforef, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex bc5f7bc 60/71: Add new style/cancel.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 380bc4a 06/71: Handle optional embellishment arguments correctly,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex db45d9e 41/71: Improve handling of key=vals in style/mdframed.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 9f3e760 10/71: Recognize L3 \msg_line_context: on warning parsing, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 3684fde 17/71: Explain how to support option completion, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 44a8a42 09/71: ; Don't use `assoc-delete-all', Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 22e4415 68/71: Add styles for packages from sttools collection, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex ae2d7ef 23/71: Silence compiler warning, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 6433dc3 30/71: Extend `TeX-read-key-val' to accept a function call, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex c6350aa 07/71: Track standardized generic hook names in LaTeX kernel, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in style/listings.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex accfe51 58/71: Add new style/xr-hyper.el, Tassilo Horn, 2021/12/17