[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex f9b378a45c 70/76: Support detached arguments
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex f9b378a45c 70/76: Support detached arguments |
Date: |
Fri, 13 Jan 2023 14:31:07 -0500 (EST) |
branch: externals/auctex
commit f9b378a45c89b16a183f46830e4c7ec7b2aec7c5
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>
Support detached arguments
* tex.el (TeX-find-macro-boundaries): Skip white spaces between a
macro argument and comment starter.
Fix doc string.
Add FIXME comment.
(TeX-find-macro-end-helper): Skip white spaces at the beginning of
line even when the preceding line doesn't end with comment.
* tests/tex/navigation.el (TeX-check-f-m-b): New function.
(TeX-find-macro-boundaries-detached-arg): New test.
(TeX-find-macro-end-helper): Integrate similar tests into one test.
(TeX-check-f-m-e-h): Adapt according to the above integration.
---
tests/tex/navigation.el | 75 ++++++++++++++++++++++++++++++++++++-------------
tex.el | 17 ++++++++---
2 files changed, 69 insertions(+), 23 deletions(-)
diff --git a/tests/tex/navigation.el b/tests/tex/navigation.el
index 4debb44f5c..45071bf2b8 100644
--- a/tests/tex/navigation.el
+++ b/tests/tex/navigation.el
@@ -1,6 +1,6 @@
;;; navigation.el --- tests for navigation function in TeX buffer -*-
lexical-binding: t; -*-
-;; Copyright (C) 2019-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2019-2023 Free Software Foundation, Inc.
;; This file is part of AUCTeX.
@@ -26,29 +26,66 @@
(defun TeX-check-f-m-e-h (string &optional position)
"Check whether `TeX-find-macro-end-helper' works for exceptional case."
+ (erase-buffer)
+ (insert string)
+ (should (= (or position (point-max))
+ (TeX-find-macro-end-helper (point-min)))))
+
+(ert-deftest TeX-find-macro-end-helper ()
(with-temp-buffer
- (insert string)
- (should (= (or position (point-max))
- (TeX-find-macro-end-helper (point-min))))))
+ (LaTeX-mode)
+
+ ;; single macro ending at EOB
+ (TeX-check-f-m-e-h "\\foo")
+
+ ;; curly braces ending at EOB
+ (TeX-check-f-m-e-h "\\foo{bar}")
+
+ ;; curly brace failing to close at EOB
+ (TeX-check-f-m-e-h "\\foo{bar")
+
+ ;; square brackets ending at EOB
+ (TeX-check-f-m-e-h "\\foo{bar}[baz]")
+
+ ;; square bracket failing to close at EOB
+ (TeX-check-f-m-e-h "\\foo{bar}[baz" (1+ (length "\\foo{bar}")))))
+
+(defun TeX-check-f-m-b (string &optional chars)
+ "Check whether `TeX-find-macro-boundaries' works for exceptional case."
+ (erase-buffer)
+ (insert string)
+ (if chars (backward-char chars))
+ (let ((result (TeX-find-macro-boundaries)))
+ (should (= (point-min)
+ (car result)))
+ (should (= (point-max)
+ (cdr result)))))
+
+(ert-deftest TeX-find-macro-boundaries-detached-arg ()
+ (with-temp-buffer
+ ;; necessary to set comment syntax properly
+ (LaTeX-mode)
+
+ ;; argument separated by newline
+ (TeX-check-f-m-e-h "\\foo{bar}
+{baz}")
+
+ (TeX-check-f-m-e-h "\\foo{bar}
+ {baz}")
-(ert-deftest TeX-find-macro-end-helper-single ()
- ;; single macro ending at EOB
- (TeX-check-f-m-e-h "\\foo"))
+ (TeX-check-f-m-e-h "\\foo{bar} % comment
+ {baz}")
-(ert-deftest TeX-find-macro-end-helper-curly ()
- ;; curly braces ending at EOB
- (TeX-check-f-m-e-h "\\foo{bar}"))
+ (TeX-check-f-m-b "\\foo{bar}
+{baz}" 2)
-(ert-deftest TeX-find-macro-end-helper-curly-fail ()
- ;; curly brace failing to close at EOB
- (TeX-check-f-m-e-h "\\foo{bar"))
+ (TeX-check-f-m-b "\\foo{bar}
+ {baz}" 2)
-(ert-deftest TeX-find-macro-end-helper-square ()
- ;; square brackets ending at EOB
- (TeX-check-f-m-e-h "\\foo{bar}[baz]"))
+ (TeX-check-f-m-b "\\foo{bar} % comment
+ {baz}" 2)
-(ert-deftest TeX-find-macro-end-helper-square-fail ()
- ;; square bracket failing to close at EOB
- (TeX-check-f-m-e-h "\\foo{bar}[baz" (1+ (length "\\foo{bar}"))))
+ (TeX-check-f-m-b "\\foo{bar}% comment
+ {baz}" 2)))
;;; navigation.el ends here
diff --git a/tex.el b/tex.el
index e032d8c5e5..456c0310a1 100644
--- a/tex.el
+++ b/tex.el
@@ -1,6 +1,6 @@
;;; tex.el --- Support for TeX documents. -*- lexical-binding: t; -*-
-;; Copyright (C) 1985-2022 Free Software Foundation, Inc.
+;; Copyright (C) 1985-2023 Free Software Foundation, Inc.
;; Maintainer: auctex-devel@gnu.org
;; Keywords: tex
@@ -5573,10 +5573,18 @@ in the buffer."
(TeX-find-balanced-brace -1 depth limit))
(defun TeX-find-macro-boundaries (&optional lower-bound)
- "Return a list containing the start and end of a macro.
+ "Return a cons containing the start and end of a macro.
If LOWER-BOUND is given, do not search backward further than this
point in buffer. Arguments enclosed in brackets or braces are
considered part of the macro."
+ ;; FIXME: Pay attention to `texmathp-allow-detached-args' and
+ ;; `reftex-allow-detached-macro-args'.
+ ;; Should we handle cases like \"{o} and \\[3mm] (that is, a macro
+ ;; whose name is a symbol and takes some arguments) as well? Note
+ ;; that amsmath package arranges the macro \\ so that white spaces
+ ;; between \\ and [something] prevents the latter to be interpreted
+ ;; as an optional argument. mathtools package arranges some
+ ;; environments including gathered similarly.
(save-restriction
(when lower-bound
(narrow-to-region lower-bound (point-max)))
@@ -5603,6 +5611,7 @@ considered part of the macro."
(condition-case nil (backward-sexp)
(error (throw 'abort nil)))
(forward-comment -1)
+ (skip-chars-backward " \t")
(and (memq (char-before) '(?\] ?\}))
(not (TeX-escaped-p (1- (point)))))))
(skip-chars-backward "A-Za-z@*")
@@ -5632,7 +5641,7 @@ those will be considered part of it."
(while (not (eobp))
(cond
;; Skip over pairs of square brackets
- ((or (looking-at "[ \t]*\n?\\(\\[\\)") ; Be conservative: Consider
+ ((or (looking-at "[ \t]*\n?[ \t]*\\(\\[\\)") ; Be conservative:
Consider
; only consecutive lines.
(and (looking-at (concat "[ \t]*" TeX-comment-start-regexp))
(save-excursion
@@ -5643,7 +5652,7 @@ those will be considered part of it."
(forward-sexp)
(scan-error (throw 'found (point)))))
;; Skip over pairs of curly braces
- ((or (looking-at "[ \t]*\n?{") ; Be conservative: Consider
+ ((or (looking-at "[ \t]*\n?[ \t]*{") ; Be conservative: Consider
; only consecutive lines.
(and (looking-at (concat "[ \t]*" TeX-comment-start-regexp))
(save-excursion
- [elpa] externals/auctex 1c7a1b582e 23/76: Simplify implementation of style/csquotes.el, (continued)
- [elpa] externals/auctex 1c7a1b582e 23/76: Simplify implementation of style/csquotes.el, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex eca0fadbc3 18/76: ; Trivial cleanups, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex b2b899a450 66/76: ; * style/pstricks.el (LaTeX-package-parameter-value): Pacify compiler., Tassilo Horn, 2023/01/13
- [elpa] externals/auctex d43bfae3fa 54/76: Overhaul beamer.el, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 287da56401 30/76: Revert "Bind a value to `LaTeX-current-environment' locally", Tassilo Horn, 2023/01/13
- [elpa] externals/auctex ee9e8a2b6e 11/76: Move `TeX-TikZ-point-name-regexp' to tex-style.el, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex a648993763 22/76: * style/comment.el ("comment"): Replace `TeX-arg-eval'., Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 5f129b5dca 58/76: Support starred variant name, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 288665587a 57/76: Use `symbol-value' instead of `eval', Tassilo Horn, 2023/01/13
- [elpa] externals/auctex d3ab64f893 60/76: Reduce redundancy in regexp, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex f9b378a45c 70/76: Support detached arguments,
Tassilo Horn <=
- [elpa] externals/auctex 7da1860c2a 26/76: Support starred section names, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex d937d4035c 16/76: Simplify implementation of style/changelog.el, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 906e57dfb8 68/76: ; * style/physics.el: Write proper date., Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 01f84ce9f5 73/76: Simplify implementation of style/minted.el, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 2d0fdebac0 69/76: Preserve braces after @TeX and similar macros., Tassilo Horn, 2023/01/13
- [elpa] externals/auctex c60ed913a0 12/76: ; Remove unnecessary `declare-function', Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 7c15b32d06 47/76: Simplify implementation of style/ltugboat.el, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 643d39a10c 75/76: Update Pygments style names, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 358b4d0785 76/76: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2023/01/13
- [elpa] externals/auctex 4700af5dd4 64/76: ; Delete ineffective string escapes reported by Relint, Tassilo Horn, 2023/01/13