>> Another problem: this top level chunk no longer works
>>
>> [...]
>>
>> since the previews are place asynchronously.  It always reports "no
>> images to display inline".  Should I remove this messaging, or find a
>> way to run this from the final async chunk?  The code gets a little
>> convoluted when I do the latter.
>
> I am a bit confused. Isn't `org-link-preview--get-overlays' counting
> overlays? And the overlays should be created before async preview is
> complete, right? Or do I miss something?

Currently I only add the overlay to `org-link-preview-overlays' if/when
the preview is successful.  `org-link-preview--get-overlays' counts
overlays in this buffer-local list.

If I add overlays to `org-link-preview-overlays' when they are created,

1. All previews that (eventually, asynchronously) fail will be reported
as successful by the message.

2. `org-link-preview-overlays' will be populated with overlays for
failed previews, leading to inconsistent behavior when doing other
things, like toggling a link preview at point.

These inconsistencies might still be worth it since the code will be
much more confusing and harder to maintain if everything (including user
messaging) is done via callbacks.

Karthik

Reply via email to