Karthik Chikmagalur <karthikchikmaga...@gmail.com> writes:

>> Abstracting away previews is certainly welcome.
>> RMS explicitly asked Org mode team to work towards this goal:
>> https://list.orgmode.org/e1kikxv-0007iy...@fencepost.gnu.org/
>
> I recently spent some time on this feature (LaTeX previews in all
> major-modes) and produced a few prototypes.  You can see some demos in
>
> https://www.youtube.com/watch?v=u44X_th6_oY [1]

Thanks!
Also, talking about calc previews... there is 
https://github.com/johnbcoughlin/calctex

> The way support for other major modes works right now is based on the
> following observation: The `org-latex-preview' feature uses a tiny
> subset of the `org-element' API.  Specifically, it uses only the
> functions
>
> - `org-element-context'
> - `org-element-property', referring to the properties :value,
>   :begin and :end, and optionally :post-blank and :post-affiliated
> - `org-element-type', which returns either latex-fragment,
>   latex-environment or any other symbol

I think that it will be better to reuse thingatpt.el to retrieve object
boundaries: fragments and sections.

> In addition, it uses two functions to generate the preamble and find
> section bounds:
>
> - `org-latex-preview--get-preamble'
> - `org-latex-preview--section-bounds'

For preamble, we may simply use buffer-local variable.
Something like
(defvar-local latex-preview-make-preamble-function 
#'latex-preview-default-preamble ...)

Then, major modes may set it as needed.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to