auctex-devel
[Top][All Lists]
Advanced

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

Re: Font lock is slow for large doctex document


From: Arash Esbati
Subject: Re: Font lock is slow for large doctex document
Date: Wed, 14 Jul 2021 10:09:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50

Hi Keita,

Ikumi Keita <ikumi@ikumi.que.jp> writes:

> Now font lock operation slows down significantly in a buffer of large
> doctex document, at least on machines with somewhat poor CPU power.
>
> [How to confirm]

Thanks for looking into this.  I can reproduce this with your recipe.

> My tentative proposal to fix this issue is attached below. With this
> patch, `texmathp' regards a line containing only whitespaces except "%"
> at its beginning as empty in doctex mode buffer. On my machine, this
> eliminates lags described above.
>
> This is equivalent to an assumption "math expressions in docTeX
> documents don't contain neither such pseudo-empty lines nor true empty
> lines". I'm not sure whether that's right or not, so comments and
> suggestion are greatly appreciated.

I'm not really familiar with writing .dtx files, so others can comment,
but looking at dtxtut.pdf ([1], page 21), it says:

    Although commentary really belongs only in the typeset documentation,
    it is also possible to write comments that are visible only in the
    .sty file, in both the typeset documentation and the .sty file, or
    only in the .dtx source.  Table 3 shows how to control comment
    visibility.

       Table 3: Comment visibility
    ===================================
    Appears   Appears   Mechanism
    in docs   in.sty
    -------- --------- ----------------
       N         N      % ^^A (comment)

       N         Y      % \iffalse
                        %% (comment)
                        % \fi

       Y         N      % (comment)
       Y         Y      %% (comment)
    ===================================

You can also have a situation where you have more than one % at line
beginning.  Maybe you can cater for it with:

> 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]"
> +                         "[\n\r][ \t]*[\n\r]")
>                                            nil 1 texmathp-search-n-paragraphs)
>                        (match-beginning 0)
>                      (point-min))))

WDYT, does it make sense?

Best, Arash

Footnotes:
[1]  https://www.ctan.org/pkg/dtxtut




reply via email to

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