digestif icon indicating copy to clipboard operation
digestif copied to clipboard

No completions for commands defined in another file

Open Glitzy3033 opened this issue 2 years ago • 1 comments
trafficstars

Greetings. Suppose I have two LaTeX files called main.tex and macro.tex in the same directory. Suppose macro.tex reads:

% !TeX root = main.tex
\newcommand{\hellohello}{\mathrm{hello}}

and it is included in main.tex:

\documentclass{article}
\input{macro.tex}
\begin{document}

...

\end{document}

An expected behavior is that when one starts to type \helloh... in main.tex, a completion should pop up. But the actual behavior is that no such completion is suggested by digestif. It seems that digestif does not find the commands defined in the included files.

Glitzy3033 avatar Nov 24 '22 06:11 Glitzy3033

It would be nice to fix this limitation, but this behavior stems from an important optimization tradeoff.

Currently, if main.tex includes, say, chapter1.tex and chapter2.tex, we pretend that any new commands or packages or further \inputs in chapter1.tex don't affect the way main.tex or chapter2.tex are parsed. This is not how TeX actually works, but it allows us not to reparse chapter2.tex if chapter1.tex changes. In this way, we can deal with documents of essentially arbitrary length as long as they are in the usual one-file-per-chapter model.

There are some even worse consequences of this optimization: If you move all your preamble to a sty file like this:

\documentclass{article}
\usepackage{mystyle}
\begin{document}
\include{chapter1}
\include{chapter2}
\end{document}

then Digesitf will not "see" any packages loaded in mystyle.sty.

astoff avatar Nov 28 '22 23:11 astoff