[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 618bdf1 85/95: Append \b to regexp built from Te
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 618bdf1 85/95: Append \b to regexp built from TeX control words |
Date: |
Sun, 16 Apr 2017 01:27:02 -0400 (EDT) |
branch: externals/auctex
commit 618bdf1b89159dfe23375353002cf05e354d2342
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Append \b to regexp built from TeX control words
* latex.el (LaTeX-paragraph-commands-regexp-make): Append \b to
regexp built from TeX control words. Fix this report
http://lists.gnu.org/archive/html/auctex/2017-03/msg00009.html
* tests/latex/latex-filling-in.tex:
* tests/latex/latex-filling-out.tex:
* tests/latex/latex-test.el (LaTeX-filling): Extend test for addition
in `LaTeX-paragraph-commands-regexp-make' in latex.el.
---
latex.el | 19 +++++++++++++++----
tests/latex/latex-filling-in.tex | 23 +++++++++++++++++++++++
tests/latex/latex-filling-out.tex | 17 +++++++++++++++++
tests/latex/latex-test.el | 15 ++++++++++++---
4 files changed, 67 insertions(+), 7 deletions(-)
diff --git a/latex.el b/latex.el
index a82a136..5e75d31 100644
--- a/latex.el
+++ b/latex.el
@@ -4547,10 +4547,21 @@ value of NO-SUBSECTIONS."
"Internal list of LaTeX macros that should have their own line.")
(defun LaTeX-paragraph-commands-regexp-make ()
- "Return a regular expression matching defined paragraph commands."
- (concat (regexp-quote TeX-esc) "\\("
- (regexp-opt (append LaTeX-paragraph-commands
- LaTeX-paragraph-commands-internal)) "\\)"))
+ "Return a regular expression matching defined paragraph commands.
+Regexp part containing TeX control words is postfixed with `\\b'
+to avoid ambiguities (e.g. \\par vs. \\parencite)."
+ (let (cmds symbs)
+ (dolist (mac (append LaTeX-paragraph-commands
+ LaTeX-paragraph-commands-internal))
+ (if (string-match "[^a-zA-Z]" mac)
+ (push mac symbs)
+ (push mac cmds)))
+ (concat (regexp-quote TeX-esc) "\\(?:"
+ (regexp-opt cmds "\\(?:")
+ "\\b"
+ "\\|"
+ (regexp-opt symbs)
+ "\\)")))
(defcustom LaTeX-paragraph-commands nil
"List of LaTeX macros that should have their own line.
diff --git a/tests/latex/latex-filling-in.tex b/tests/latex/latex-filling-in.tex
index 6e7294a..274d03c 100644
--- a/tests/latex/latex-filling-in.tex
+++ b/tests/latex/latex-filling-in.tex
@@ -3,3 +3,26 @@ Lorem ipsum dolor sit amet, consectetur adipisci elit, sed
eiusmod \(0 = 1\) tem
\begin{tabular}{| l | l | l | l |}
Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit
amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci &
Lorem ipsum dolor sit amet, consectetur adipisci
\end{tabular}
+
+% Test for unambiguousness of macros starting a paragraph. E.g.
+% caption vs. captionsetup
+Lorem ipsum dolor sit amet, consectetur adipisci,
+lorem ipsum dolor
+\captionsetup{key=val}
+sit amet, consectetur adipisci
+
+Lorem ipsum dolor sit amet, consectetur adipisci,
+lorem ipsum dolor
+\caption{key=val}
+sit amet, consectetur adipisci
+
+% par vs. parencite
+Lorem ipsum dolor sit amet, consectetur adipisci,
+lorem ipsum dolor
+\parencite{key}
+sit amet, consectetur adipisci
+
+Lorem ipsum dolor sit amet, consectetur adipisci,
+lorem ipsum dolor
+\par
+sit amet, consectetur adipisci
diff --git a/tests/latex/latex-filling-out.tex
b/tests/latex/latex-filling-out.tex
index b0596f3..764628c 100644
--- a/tests/latex/latex-filling-out.tex
+++ b/tests/latex/latex-filling-out.tex
@@ -7,3 +7,20 @@ consequatur.
\begin{tabular}{| l | l | l | l |}
Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit
amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci &
Lorem ipsum dolor sit amet, consectetur adipisci
\end{tabular}
+
+% Test for unambiguousness of macros starting a paragraph. E.g.
+% caption vs. captionsetup
+Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
+\captionsetup{key=val} sit amet, consectetur adipisci
+
+Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
+\caption{key=val}
+sit amet, consectetur adipisci
+
+% par vs. parencite
+Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
+\parencite{key} sit amet, consectetur adipisci
+
+Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
+\par
+sit amet, consectetur adipisci
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index 02b1894..05ca2c8 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -93,15 +93,24 @@ line and from another directory."
;; Test LaTeX code with math modes is indented as expected. This has mostly to
;; do with the value of `LaTeX-fill-break-at-separators' and how
;; `LaTeX-fill-move-to-break-point' handles it. If the test fails, try to look
-;; there.
+;; there. The second part of the test looks for unambiguousness of
+;; macros starting a paragraph
+;; (http://lists.gnu.org/archive/html/auctex/2017-03/msg00009.html)
(ert-deftest LaTeX-filling ()
(should (string=
(with-temp-buffer
(insert-file-contents LaTeX-filling/in)
(LaTeX-mode)
(let ((fill-column 70))
- (fill-paragraph))
- (buffer-string))
+ (fill-paragraph)
+ (let ((cmds '("captionsetup" "caption"
+ "parencite" "par")))
+ (dolist (cmd cmds)
+ (search-forward (concat "\\" cmd))
+ (save-excursion
+ (end-of-line 0)
+ (fill-paragraph)))))
+ (buffer-string))
(with-temp-buffer
(insert-file-contents LaTeX-filling/out)
(buffer-string)))))
- [elpa] externals/auctex 88a7563 81/95: Fix last improvement for skipping of inline verbatim macros, (continued)
- [elpa] externals/auctex 88a7563 81/95: Fix last improvement for skipping of inline verbatim macros, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 16f24dd 90/95: ; * style/minted.el (LaTeX-minted-add-syntactic-keywords-extra): Fix doc string., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a46c307 77/95: Improve fontification of verbatim macros in style/minted.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 83890d6 86/95: Update package options in style/amsmath.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 94b227d 89/95: * doc/auctex.texi (Selecting a Command): Document `TeX-ispell-verb-delimiters'., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 4225941 59/95: Modify `TeX-expand-list-builtin' instead of `TeX-expand-list', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 79361b5 58/95: Add new style/fvextra.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex d0908cb 51/95: Fix auto selection of japanese TeX engine, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex aac8694 67/95: Use compat function `TeX-replace-regexp-in-string' in core files, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 5a84d95 88/95: Fix `paragraph-start' and `paragraph-separate', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 618bdf1 85/95: Append \b to regexp built from TeX control words,
Tassilo Horn <=
- [elpa] externals/auctex 0cde29b 87/95: ; * tex-ispell.el (TeX-ispell-verb-delimiters): Remove `*'., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 07a2903 82/95: Don't alter standard value or saved value themselves of customize option, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 194a8f8 62/95: Add LaTeX inline math delimiters to Ispell skip list, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 7390999 61/95: ; Simplify insertion of a newline after label, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 6a298a8 47/95: Fix documents and add trivial improvements., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a286e8b 57/95: Improve parsing capabilities of style/fancyvrb.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 11e234b 55/95: Remove spurious entries of view settings., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 83a875b 83/95: ; * tex.el (TeX-ispell-tex-arg-verb-end): Drop unnecessary `format'., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 2116248 94/95: * doc/changes.texi: Update with recent changes., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 65e56e1 93/95: ; Make sure that `regex-opt' builds a shy group., Tassilo Horn, 2017/04/16