io12 / org-fragtog

Automatically toggle Org mode LaTeX fragment previews as the cursor enters and exits them
MIT License
397 stars 14 forks source link

Possibility to toggle fragments on input #30

Closed FelixBrendel closed 3 years ago

FelixBrendel commented 3 years ago

Thank you for the package! I have been using it for many months now and overall I am really happy with it. I would however like to make a suggestion.

When scrolling through a document with a lot of multi-line equations, it can be a bit disorienting, if the fragments automatically toggle. Also sometimes I just want to move the cursor over a multiline fragment which makes it harder when the fragment expands to a lot of code.

I thought about the situation, and for me personally I would be happy if there was a way treat fragments as images until you start typing while they are under point. At that time they could be toggled to the latex text. Maybe this could be a customize setting?

The behaviour of re-toggeling them back to would not be affected.

This would allow a cleaner navigation through the document where the content wouldn't be changing simply because of scrolling or moving the cursor.

If you see a simpler way for me to archieve this on my side I would also be interested to hear it!

io12 commented 3 years ago

I think you can get something similar to what you want by customizing org-fragtog-preview-delay. That only changes the images to text when point is on the image for org-fragtog-preview-delay seconds.

FelixBrendel commented 3 years ago

Thank you for the suggestion! I guess that would work in some situations, only when scrolling through the document and then stopping to read, if the cursor is on a fragment it could change the page layout suddenly.

Another option would be to turn off org-fragtog-mode and manually toggle the fragment under point (for example by setting a keyboard shortcut). In that case, do you think I could still somehow leverage the re-toggling to the image preview when the cursor leaves the fragment?

FelixBrendel commented 3 years ago

After thinking about it more, it was actually tivial to implement (maybe this is what you meant actually), by setting the timeout to a very high number and binding a key to toggle the fragment. org-fragtog-mode will still retoggle to the preview when the cursor leves the fragment.

This is the config that makes it work, for those who are looking at this later

(use-package org-fragtog
  :custom (org-fragtog-preview-delay 99999999999999999)
  :bind   (:map org-mode-map ("<f2>" . org-toggle-latex-fragment))
  :hook   (org-mode . org-fragtog-mode))

Unless you want to add something, I would go ahead and close this issue, as I found a way to solve my need. Thank you for your help!