emacs-elpa-diffs
[Top][All Lists]
Advanced

[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.%



reply via email to

[Prev in Thread] Current Thread [Next in Thread]