[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 9e97edc 49/71: Fix wrong logic of the previous c
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 9e97edc 49/71: Fix wrong logic of the previous commit |
Date: |
Fri, 17 Dec 2021 15:00:35 -0500 (EST) |
branch: externals/auctex
commit 9e97edc3f288a40b5bdff6803c903b4f0d86712d
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>
Fix wrong logic of the previous commit
* latex.el (LaTeX-fill-region-as-paragraph): Take into account lines
ending with "\par" or "\\" before code comments. We must always
perform both code comment detection and regexp match.
* tests/latex/latex-filling-in.tex:
* tests/latex/latex-filling-out.tex:
Add additional tests.
---
latex.el | 50 +++++++++++++++++++++++----------------
tests/latex/latex-filling-in.tex | 9 +++++++
tests/latex/latex-filling-out.tex | 18 ++++++++++++++
3 files changed, 57 insertions(+), 20 deletions(-)
diff --git a/latex.el b/latex.el
index af44053..132e6a5 100644
--- a/latex.el
+++ b/latex.el
@@ -4004,7 +4004,7 @@ You can disable filling inside a specific environment by
adding
it to `LaTeX-indent-environment-list', only indentation is
performed in that case."
(interactive "*r\nP")
- (let ((end-marker (copy-marker to)) has-code-comment)
+ (let ((end-marker (copy-marker to)) has-code-comment has-regexp-match)
(if (or (assoc (LaTeX-current-environment) LaTeX-indent-environment-list)
(member (TeX-current-macro) LaTeX-fill-excluded-macros)
;; This could be generalized, if there are more cases where
@@ -4021,24 +4021,24 @@ performed in that case."
(save-restriction
(goto-char from)
(while (< (point) end-marker)
- (if (or
- ;; Code comments.
- (when (setq has-code-comment
- (TeX-search-forward-comment-start end-marker))
- (goto-char has-code-comment)
- (when
- ;; See if there is at least one non-whitespace
- ;; character before the comment starts.
- (save-excursion
- (skip-chars-backward " \t" (line-beginning-position))
- (bolp))
- ;; Not a code comment. Go back to the former
- ;; point.
- (setq has-code-comment nil)
- (goto-char from))
- has-code-comment)
- (re-search-forward
- (concat "\\("
+ ;; Code comments.
+ (when (setq has-code-comment
+ (TeX-search-forward-comment-start end-marker))
+ ;; See if there is at least one non-whitespace
+ ;; character before the comment starts.
+ (goto-char has-code-comment)
+ (skip-chars-backward " \t" (line-beginning-position))
+ (if (bolp)
+ ;; Not a code comment.
+ (setq has-code-comment nil)))
+
+ ;; Go back to the former point for the next regexp search.
+ (goto-char from)
+
+ (when (setq has-regexp-match
+ (re-search-forward
+ (concat
+ "\\("
;; Lines ending with `\par'.
;; XXX: Why exclude \n? vv
"\\(?:\\=\\|[^" TeX-esc "\n]\\)\\(?:"
@@ -4056,8 +4056,18 @@ performed in that case."
;; XXX: Why not "\\s-*\\(?:\\[[^]]*\\]\\)?" ?
"\\(?:\\s-*\\[[^]]*\\]\\)?"
"\\s-*$")
- end-marker t))
+ (or has-code-comment end-marker) t))
+ ;; The regexp matched before the code comment (if any).
+ (setq has-code-comment nil))
+
+ ;; Here no need to go back to the former position because
+ ;; "ELSE" part of the following `if' doesn't rely on the
+ ;; current point.
+ ;; (goto-char from)
+
+ (if (or has-code-comment has-regexp-match)
(progn
+ (goto-char (or has-code-comment has-regexp-match))
(goto-char (line-end-position))
(delete-horizontal-space)
;; I doubt very much if we want justify -
diff --git a/tests/latex/latex-filling-in.tex b/tests/latex/latex-filling-in.tex
index f1de81b..0d97fcf 100644
--- a/tests/latex/latex-filling-in.tex
+++ b/tests/latex/latex-filling-in.tex
@@ -59,3 +59,12 @@ Cum sociis natoque penatibus et magnis \verb|a%b|
dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
dolor. Nullam tristique diam non turpis.
Cras placerat accumsan nulla. Nullam rutrum. Nam vestibulum accumsan nisl.
+
+% bug#51762-4 "\par" before code comment shouldn't be skipped.
+Mauris ac felis vel velit tristique imperdiet. Vestibulum convallis, lorem a
tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae
lacus.\par
+ Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at
vulputate neque nulla lacinia eros. Aliquam posuere. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.%
+
+% bug#51762-5 "\\" before code comment shouldn't be skipped.
+Mauris ac felis vel velit tristique imperdiet. Vestibulum convallis, lorem a
+tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus.\\
+ Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at
vulputate neque nulla lacinia eros. Aliquam posuere. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.%
diff --git a/tests/latex/latex-filling-out.tex
b/tests/latex/latex-filling-out.tex
index 232464b..bf326d1 100644
--- a/tests/latex/latex-filling-out.tex
+++ b/tests/latex/latex-filling-out.tex
@@ -58,3 +58,21 @@ Cum sociis natoque penatibus et magnis \verb|a%b| dis
parturient
montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
dolor. Nullam tristique diam non turpis. Cras placerat accumsan
nulla. Nullam rutrum. Nam vestibulum accumsan nisl.
+
+% bug#51762-4 "\par" before code comment shouldn't be skipped.
+Mauris ac felis vel velit tristique imperdiet. Vestibulum convallis,
+lorem a tempus semper, dui dui euismod elit, vitae placerat urna
+tortor vitae lacus.\par
+Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor,
+at vulputate neque nulla lacinia eros. Aliquam posuere. Cum sociis
+natoque penatibus et magnis dis parturient montes, nascetur ridiculus
+mus.%
+
+% bug#51762-5 "\\" before code comment shouldn't be skipped.
+Mauris ac felis vel velit tristique imperdiet. Vestibulum convallis,
+lorem a
+tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus.\\
+Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor,
+at vulputate neque nulla lacinia eros. Aliquam posuere. Cum sociis
+natoque penatibus et magnis dis parturient montes, nascetur ridiculus
+mus.%
- [elpa] externals/auctex b379da7 18/71: Don't indent begin/end of comment env, (continued)
- [elpa] externals/auctex b379da7 18/71: Don't indent begin/end of comment env, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 483f6e9 05/71: ; * style/hyperref.el ("hyperref"): Fix other link to testform.tex., Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 380bc4a 06/71: Handle optional embellishment arguments correctly, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex bd723c7 24/71: Cater for corner case when dealing with TeX error, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 6433dc3 30/71: Extend `TeX-read-key-val' to accept a function call, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex df69443 26/71: ; Silence the compiler, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in style/listings.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 0419539 37/71: Improve style/babel.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex d62d8f3 34/71: Update style/fontspec.el to package version 2.7i, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex b9545c8 45/71: Improve handling of key=vals in style/fancyvrb.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 9e97edc 49/71: Fix wrong logic of the previous commit,
Tassilo Horn <=
- [elpa] externals/auctex 8c50665 62/71: Add new style/unicodefonttable.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 8e13306 66/71: Update style/url.el to package version 3.4, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 25c8d0f 12/71: Add NEWS for two commands available in Texinfo mode, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 2e26d49 61/71: Update style/siunitx.el to package version 3, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex ee37db3 33/71: Supplement doc string, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex d77f49e 54/71: Fontify \tabularnewline macro, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 7c4147b 57/71: Improve handling of key=vals in style/tcolorbox.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex c6350aa 07/71: Track standardized generic hook names in LaTeX kernel, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 2db5e3c 40/71: Improve handling of key=vals style/newfloat.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 2e968b6 36/71: ; Fix escapings, Tassilo Horn, 2021/12/17