>>>> (defconst org-latex-preview-live--cache-dir
>>>>   (expand-file-name "org-latex-preview-mode-display-live" 
>>>> temporary-file-directory)
>>>>   "Folder used to cache live previews.")
>>>
>>> Is it ever used? From the code, this would correspond to
>>> org-latex-preview-cache = 'live (undocumented).

> There is still a concern though - 'live looks like a valid user
> option. Maybe you should use something else, more obviously internal?

It is not documented and not listed as one of the valid options for
org-latex-preview-cache.  I don't know why users would assume that it is
an option.

>> 4. So we cache intermediate states of live previews in
>> org-latex-preview-live--cache-dir, with a counter that resets when
>> org-latex-preview-live--max-cache-count (default 1024) live preview
>> images have been generated.  The live cache is wiped when the
>> max-cache-count is reached.  My org-persist disk usage and
>> org-persist-gc time went down by a large factor after this, and cached
>> images for the "finished" fragments were still available in org-persist.
>
> Hmm. What if a single document contains more than 1024 fragments?
> Will preview still work?

Yes, it will still work.  I think there's some confusion here.  There is
no connection between the number of fragments being previewed and
org-latex-preview-live--max-cache-count.  Imagine you want to type

\( x + 3 \)

with live updates. "|" is the cursor position below:

You first insert the environment:

\( | \)

(Without the closing \) to make it a valid LaTeX fragment no live
previews can be generated.)

Next:

\( x| \)

When you pause here, a live preview image is generated.  This is stored
in the 'live cache, and not in org-persist.

\( x +| \)

Another live preview image, also stored in the 'live cache.

\( x + 3| \)

Another live preview image, stored in the 'live cache.

\( x + 3 \)|

We have now exited the fragment.  The final image is copied from the
'live cache to org-persist and the overlay is updated one final time.

We now have one image for the fragment in org-persist, and 3 images for
the fragment in the 'live cache, two of which are "incomplete".

This live cache can hold up to org-latex-preview-live--max-cache-count
== 1024 imgaes and rolls over after that.  We don't care about those
incomplete preview images anyway after we exit the fragment.  But they
are useful to cache while we are editing the fragment since the same
intermediate state might be reached several times in the editing process.

There is no limit to the number of preview images per file that are
stored in org-persist.

>>>>   "The document header used for processing LaTeX fragments.
>>>> It is imperative that this header make sure that no page number
>>>> appears on the page.  The package defined in the variables
>>>> `org-latex-default-packages-alist' and `org-latex-packages-alist'
>>>> will either replace the placeholder \"[PACKAGES]\" in this
>>>> header, or they will be appended."
>>>
>>> This is not "or they will be appended", but more subtle. See the
>>> docstring of org-latex-classes.
>>
>> The docstring is an exact copy of that of org-format-latex-header on
>> main.  I don't understand the "appended" part here or the docstring of
>> org-latex-classes, so please suggest a replacement.
>
> Oops. That's not the right docstring. What I meant is
> org-splice-latex-header that says
>
>     For backward compatibility, if both the positive and the negative place
>     holder is missing, the positive one (without the \"NO-\") will be
>     assumed to be present at the end of the template.
>
> That's where "appended" is coming from.

I've reworded it and mentioned org-splice-latex-header in the docstring.

Karthik

Reply via email to