>From 11f3af94b7283b9724cf36d0c37c658f1befb8ca Mon Sep 17 00:00:00 2001 From: Ikumi Keita Date: Thu, 8 Jul 2021 01:50:22 +0900 Subject: [PATCH] Fix slowdown of font lock in doctex mode `texmathp' limits search by looking for empty lines, which appear frequently in LaTeX documents. However, docTeX documents often lack such true empty lines. In such buffer, `texmathp' must search from (point-min) every time, which slowed down font lock operation siginificantly. * texmathp.el (texmathp): Adjust regular expression so that a line containing only whitespaces except "%" at its beginning is considered as empty in doctex mode buffer. --- texmathp.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/texmathp.el b/texmathp.el index ac2b75c7..42b3caf6 100644 --- a/texmathp.el +++ b/texmathp.el @@ -274,7 +274,10 @@ See the variable `texmathp-tex-commands' about which commands are checked." (interactive) (let* ((pos (point)) math-on sw-match (bound (save-excursion - (if (re-search-backward "[\n\r][ \t]*[\n\r]" + (if (re-search-backward + (if (eq major-mode 'doctex-mode) + "[\n\r]%?[ \t]*[\n\r]" + "[\n\r][ \t]*[\n\r]") nil 1 texmathp-search-n-paragraphs) (match-beginning 0) (point-min)))) -- 2.31.1