[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Test for fontification
From: |
Arash Esbati |
Subject: |
Re: Test for fontification |
Date: |
Wed, 31 Mar 2021 20:16:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 |
Hi Keita,
Ikumi Keita <ikumi@ikumi.que.jp> writes:
>>>>>> Arash Esbati <arash@gnu.org> writes:
>> What do others think, do we need such a general test?
>
> It would be good to have tests considering that syntax propertization
> affects syntax-aware functions.
Thanks for your response.
>> And if yes, which cases should be included?
>
> How about adding these?
> - verbatim environment
> - equation environment
> - \(\), \[\] pairs
> - \emph{...}
> - font specification such as \textbf{...} \mathrm{...} {\bfseries ...}
> {\ttfamily ...}
>
>> + (LaTeX-mode)
>> + (insert "\
>> +\\documentclass{article}
>> +\\begin{document}
>> +Inline verbatim test: \\verb|x|
>> +Inline math test: $x$
>> +Marginpar test: \\marginpar{x}
>> +\\end{document}
>> +
>> +%%% Local Variables:
>> +%%% mode: latex
>> +%%% TeX-master: t
>> +%%% End:\n")
>
> I think that `(LaTeX-mode)' should come after insertion of buffer
> contents because otherwise Local Variables section isn't analysed and
> would be confusing when debugging after other local variables are added.
OK, I moved that form after insert'ing the code.
>> + ;; Test for inline verb:
>> + (search-forward-regexp "\\\\verb|")
>
> It would be enough to use `search-forward' since we know the literal
> contents.
Yes, true. I also has something like this in my first attempt
(search-forward-regexp "\\\\document\\(?1:c\\)lass\\[")
and hence stayed with regexp.
>> + (should (memq 'font-lock-constant-face
>> + (get-text-property (match-end 0) 'face)))
>
> Maybe `font-latex-faces-present-p' makes the code a bit simpler.
Ah, many thanks for this one. I was literally about to re-invent the
wheel!
I pushed a change to our repo. Please feel free to have a look and tell
me if think more stuff is missing. I think the idea can be expanded
also for LaTeX packages and their corresponding AUCTeX styles.
Best, Arash