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 9e97edc3f288a40b5bdff6803c903b4f0d86712d (commit) from 199bc6e51c443c77853aaeca2fcca0a9df544c99 (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 9e97edc3f288a40b5bdff6803c903b4f0d86712d Author: Ikumi Keita <ik...@ikumi.que.jp> Date: Fri Nov 19 00:21:37 2021 +0900 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. 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.% ----------------------------------------------------------------------- Summary of changes: latex.el | 50 +++++++++++++++++++++++---------------- tests/latex/latex-filling-in.tex | 9 +++++++ tests/latex/latex-filling-out.tex | 18 ++++++++++++++ 3 files changed, 57 insertions(+), 20 deletions(-) hooks/post-receive -- GNU AUCTeX _______________________________________________ auctex-diffs mailing list auctex-di...@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-diffs