auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 199bc6e51c443c77853aa


From: Ikumi Keita
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 199bc6e51c443c77853aaeca2fcca0a9df544c99
Date: Wed, 17 Nov 2021 09:22:43 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  199bc6e51c443c77853aaeca2fcca0a9df544c99 (commit)
      from  8e0fb6559974d8bc1920b5abe1a142ad71d045de (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 199bc6e51c443c77853aaeca2fcca0a9df544c99
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Date:   Sun Nov 14 01:25:07 2021 +0900

    Use coherent logic to identify code comment (bug#51762)
    
    * latex.el (LaTeX-fill-region-as-paragraph): Use the same logic to
    identify code comment as the rest of latex.el.
    Use shy regexp groups when possible.
    Add some comments.
    * tests/latex/latex-test.el (LaTeX-filling):
    * tests/latex/latex-filling-in.tex:
    * tests/latex/latex-filling-out.tex:
    Add new tests (including ones for bug#48937).

diff --git a/latex.el b/latex.el
index 0523834..af44053 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 (save-excursion (goto-char to) (point-marker))))
+  (let ((end-marker (copy-marker to)) has-code-comment)
     (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
@@ -4016,29 +4016,47 @@ performed in that case."
                                                        "Local Variables:")))))
         ;; Filling disabled, only do indentation.
         (indent-region from to nil)
+      ;; XXX: This `save-restriction' is a leftover of older codes and
+      ;; can now be removed.
       (save-restriction
         (goto-char from)
         (while (< (point) end-marker)
-          (if (re-search-forward
-               (concat "\\("
-                       ;; Code comments.
-                       "\\([^ \r\n%\\]\\|\\\\%\\)\\([ \t]\\|\\\\\\\\\\)*"
-                       TeX-comment-start-regexp
-                       "\\|"
-                       ;; Lines ending with `\par'.
-                       "\\(\\=\\|[^" TeX-esc "\n]\\)\\("
-                       (regexp-quote (concat TeX-esc TeX-esc))
-                       "\\)*"
-                       (regexp-quote TeX-esc) "par[ \t]*"
-                       "\\({[ \t]*}\\)?[ \t]*$"
-                       "\\)\\|\\("
-                       ;; Lines ending with `\\'.
-                       (regexp-quote TeX-esc)
-                       (regexp-quote TeX-esc)
-                       "\\(\\s-*\\*\\)?"
-                       "\\(\\s-*\\[[^]]*\\]\\)?"
-                       "\\s-*$\\)")
-               end-marker t)
+          (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 "\\("
+                        ;; Lines ending with `\par'.
+                        ;; XXX: Why exclude \n?  vv
+                        "\\(?:\\=\\|[^" TeX-esc "\n]\\)\\(?:"
+                        (regexp-quote (concat TeX-esc TeX-esc))
+                        "\\)*"
+                        (regexp-quote TeX-esc) "par[ \t]*"
+                        ;; XXX: What's this "whitespaces in braces" ?
+                        ;;    vvvvvvvv
+                        "\\(?:{[ \t]*}\\)?[ \t]*$"
+                        "\\)\\|"
+                        ;; Lines ending with `\\'.
+                        (regexp-quote (concat TeX-esc TeX-esc))
+                        ;; XXX: Why not just "\\s-*\\*?" ?
+                        "\\(?:\\s-*\\*\\)?"
+                        ;; XXX: Why not "\\s-*\\(?:\\[[^]]*\\]\\)?" ?
+                        "\\(?:\\s-*\\[[^]]*\\]\\)?"
+                        "\\s-*$")
+                end-marker t))
               (progn
                 (goto-char (line-end-position))
                 (delete-horizontal-space)
@@ -4052,7 +4070,8 @@ performed in that case."
                   ;; Code comments and lines ending with `\par' are
                   ;; included in filling.  Lines ending with `\\' are
                   ;; skipped.
-                  (if (match-string 1)
+                  (if (or has-code-comment
+                          (match-beginning 1))
                       (LaTeX-fill-region-as-para-do from (point) justify-flag)
                     (LaTeX-fill-region-as-para-do
                      from (line-beginning-position 0) justify-flag)
diff --git a/tests/latex/latex-filling-in.tex b/tests/latex/latex-filling-in.tex
index 274d03c..f1de81b 100644
--- a/tests/latex/latex-filling-in.tex
+++ b/tests/latex/latex-filling-in.tex
@@ -26,3 +26,36 @@ Lorem ipsum dolor sit amet, consectetur adipisci,
 lorem ipsum dolor
 \par
 sit amet, consectetur adipisci
+
+% bug#48937-1 "\% %" should be considered as comment
+Donec vehicula augue eu neque.  Pellentesque habitant morbi tristique senectus
+et netus et malesuada fames ac turpis egestas. 35\% % FIXME check this number
+Mauris ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus vestibulum
+urna fringilla ultrices.
+
+% bug#48937-2 "\%%" should be considered as comment
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Ut purus
+elit, vestibulum ut, placerat ac, adipiscing vitae, felis.  Curabitur
+dictum gravida mauris.  Nam arcu libero, nonummy eget, consectetuer
+id, vulputate a, magna.  Donec vehicula augue eu neque.  Pellentesque
+habitant morbi tristique senectus et netus et malesuada fames ac
+turpis egestas. 35\%% FIXME check this number
+Mauris ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus
+vestibulum urna fringilla ultrices.
+
+% bug#51762-1 "\ %" should be considered as comment
+$$ \fundefline p{A \times B}{A}{(x,y)}{x}\ %%
+\et\ \fundefline q{A \times B}{B}{(x,y)}{y}\ %%
+\text{les projections canoniques}\ .$$
+
+% bug#51762-2 another form of code comment
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit
+tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et,
+ \\% This is a code comment.
+mattis eget, convallis nec, purus.
+
+% bug#51762-3 "%" in \verb should not introduce code comment
+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.
diff --git a/tests/latex/latex-filling-out.tex 
b/tests/latex/latex-filling-out.tex
index 764628c..232464b 100644
--- a/tests/latex/latex-filling-out.tex
+++ b/tests/latex/latex-filling-out.tex
@@ -24,3 +24,37 @@ Lorem ipsum dolor sit amet, consectetur adipisci, lorem 
ipsum dolor
 Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
 \par
 sit amet, consectetur adipisci
+
+% bug#48937-1 "\% %" should be considered as comment
+Donec vehicula augue eu neque.  Pellentesque habitant morbi tristique
+senectus et netus et malesuada fames ac turpis egestas.
+35\% % FIXME check this number
+Mauris ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus
+vestibulum urna fringilla ultrices.
+
+% bug#48937-2 "\%%" should be considered as comment
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Ut purus
+elit, vestibulum ut, placerat ac, adipiscing vitae, felis.  Curabitur
+dictum gravida mauris.  Nam arcu libero, nonummy eget, consectetuer
+id, vulputate a, magna.  Donec vehicula augue eu neque.  Pellentesque
+habitant morbi tristique senectus et netus et malesuada fames ac
+turpis egestas. 35\%% FIXME check this number
+Mauris ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus
+vestibulum urna fringilla ultrices.
+
+% bug#51762-1 "\ %" should be considered as comment
+$$ \fundefline p{A \times B}{A}{(x,y)}{x}\ %%
+\et\ \fundefline q{A \times B}{B}{(x,y)}{y}\ %%
+\text{les projections canoniques}\ .$$
+
+% bug#51762-2 another form of code comment
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
+hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam
+nisl, tincidunt et, \\% This is a code comment.
+mattis eget, convallis nec, purus.
+
+% bug#51762-3 "%" in \verb should not introduce code comment
+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.
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index b6135b2..9c1198d 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -140,13 +140,18 @@
              (LaTeX-mode)
              (let ((fill-column 70))
                (fill-paragraph)
+
                (let ((cmds '("captionsetup" "caption"
                              "parencite"    "par")))
                  (dolist (cmd cmds)
                    (search-forward (concat "\\" cmd))
                    (save-excursion
                      (end-of-line 0)
-                     (fill-paragraph)))))
+                     (fill-paragraph))))
+
+               (while (search-forward "% bug#" nil t)
+                 (forward-line 1)
+                 (fill-paragraph)))
              (buffer-string))
            (with-temp-buffer
              (insert-file-contents LaTeX-filling/out)

-----------------------------------------------------------------------

Summary of changes:
 latex.el                          | 63 +++++++++++++++++++++++++--------------
 tests/latex/latex-filling-in.tex  | 33 ++++++++++++++++++++
 tests/latex/latex-filling-out.tex | 34 +++++++++++++++++++++
 tests/latex/latex-test.el         |  7 ++++-
 4 files changed, 114 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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