Closed SPFabGerman closed 3 years ago
Someone else in the System Crafters discord channel already asked me about toggling links so I played around with the idea of turning this into a collection of org-autotoggles
. From this perspective, your idea certainly seems interesting! I think we'll have to rework the code to make it support multiple "toggle-entities" in a sane way but, as a starter, please go ahead and submit what you have.
Have you looked into org-raise-scripts
? It should be helpful to see how Org itself handles edge cases for sub/superscripts.
Nice. I clean up my code and open a PR, when it's ready. Thank you for the suggestion with org-raise-scripts
, that could prove helpful.
Thank you for taking interest!
I closed the issue.
While waiting for @SPFabGerman 's PR, I sketched out the move to a multi-purpose org-togglers
package in a feature branch. Please see org-togglers--enable for a working example of how general-purpose enabler will dispatch the type-specific toggle.
Hey, just found this issue. Did you work out how to hop into org-entities as well? It would be great to show i.e. \to
and \Delta
org-entities with org-toggle-pretty-entities
but to 'hop in' so you can edit them if point is on any of them.
Cheers for the great package! :)
Here's my wishlist for the package :).
*format bold*
/cursive/
~program string~
=literal=
[[https://emacs.org][emacs]]
subscript_{subscript} hoi
super^{script} hoi
org-entities such as \to, \Delta, \appr
I don't have the org-togglers--enable function loadable, so maybe I'm doing something wrong with running the latest version…
Hey, @japhir!
This issue was discussed quite some time ago, during our prototyping phase. Since then, there have been some major changes to the codebase. Notably,
org-togglers
to org-appear
;org-appear--parse-elem
;org-appear-autosubmarkers
).I thought that org-entities
are handled by org-fragtog I avoided looking into it. Now I see that they're not. Thank you for the suggestion, I will explore this further -- feel free to post a PR too.
Hey. Yeah originally I also wanted to implement the org-entities, but I never really use them myself and then just forget about them, lol.
Awesome, thanks to both of you for the explanation and the quick work-in-progress branch! :)
I would like to bring attention to subscript/superscripts, where org-appear seems to be doing nothing inside a latex fragment while editing, it would very helpful if there are any workarounds or potential fixes for this.
Hi @Inc0ns1st3nt,
I already have a WIP branch for this exact issue. (https://github.com/SPFabGerman/org-appear/tree/cleanlatex)
Currently I only try to show everything in a Latex fragment. (So multiple Sub/Superscripts in the same fragment are all toggled at the same time.)
I have not created a pull request yet, since the behaviour is still somewhat buggy, but it works for now.
You have to set the org-appear-clearlatex
variable to non-nil to enable this feature.
There are some problems when supporting the Latex fragments. Most notably, the reliance on the org-element-context
function does not return individual Sub/Superscripts or Entities, but only the full Latex Fragment. This makes toggling individual parts in the same Latex Fragment really difficult without heavy rewrites of the code.
Secondly, Entity toggling does not work for some reason. Maybe there is something I'm missing, but it seems we can not simply remove the composition of Entities in a Latex Fragment. At least, again, not without heavy rewrites.
Lastly, Org Mode has some wierd behaviour where it Re-Fonitfies the Latex Fragment after editing, but only after a certain amount of time. This means when you edit the Latex Fragment, the Sub/Superscripts can disappear and reapper somewhat randomly. (Since simple movement commands trigger our code to show the Sub/Superscript markers again.)
So yeah, if you want to have somewhat working support for Latex Fragments you could use this branch and see how well it works for you.
The first question to ask, I think, is should org-appear
handle things inside LaTeX fragments?
If yes, then we will have to stop relying on org-element
and write our own parser -- or, at least, "borrow" it with modifications from org-element
. This is entirely possible. @SPFabGerman must remember that, at first, org-appear
used regular expressions instead of org-element
. But it's also a lot of work involving a complete rewrite of org-appear
.
For my personal use, the benefit of this does not outweigh the extra work. I don't want elements inside LaTeX fragments moving anyway. Although, to be fair, I have some grievances with my choice to use org-element
.
It might be valueable for me, as I often write inline LaTeX code such as \SI{45}{\metre}
(from siunitx) or \ce{CO2}
(from mhchem) but rendering all of that sounds like way too much of a hassle ;-).
inline LaTeX code such as \SI{45}{\metre}
You can use org-fragtog to automatically toggle inline LaTeX. It has to be enclosed in $...$
, however, as far as I can tell.
ah yeah, I do use org-fragtog but indeed it only works when putting things in \[...\]
or $...$
, which puts them in math mode in the export:
#+latex_header: \usepackage{siunitx}
- \SI{35}{\metre} # this one doesn't preview in org-fragtog
- $\SI{35}{\metre}$ # this one and the next three produce nice previews in org-fragtog
- \(\SI{35}{\metre}\)
- \[\SI{35}{\metre}\]
but this is the relevant section of the exported tex file:
\begin{itemize}
\item \SI{35}{\metre}
\item \(\SI{35}{\metre}\)
\item \(\SI{35}{\metre}\)
\item \[\SI{35}{\metre}\]
\end{itemize}
perhaps I could file an issue with them to see if they could search for particular \...
constructs somehow.
Hey again! One more link type that currently doesn't do anything is inline images that are previewed. Not sure if that would be desirable, as it's already lagging significantly when point is over those images (in evil normal-mode) and lags even more if I change the line (i.e. dd in evil normal-mode to delete the line)
Hey!
My personal opinion is that at-point image toggling would be too disruptive, both in terms of lag from processing and in general, with little benefit. That being said, I feel the same way about link toggling. If you think it is a useful addition to org-appear
, I will look into implementing it.
It's not really a feature that I would want, but I just thought of it as another link type that this approach could be applied to for the completionist's sake ;-).
Maybe later, once the new idle-delay feature is stable -- this makes more sense when you have to stop the cursor and wait to make the image appear. Thanks for the suggestion, @japhir.
Closing this issue for the time being.
I have a question: Would you like to add support for Subscript (
_
) and Superscript (^
) markers? (These are automatically hidden by org mode, whenorg-pretty-entites
ist
.) I have a working prototype, which implements toggling of Sub-/Superscripts, based on this package.But I'm not really sure, if this package would be the right place to add this, since handling Sub-/Superscripts can be a bit more complicated, because there are multiple edge cases that one would have to consider and not all of the code can be reused. But I think it would make sense to add this functionality to this package, since it is has a very simmilar idea.
So what do you think? If you are interested in my code, I could open a pull request, after I clean the code up a bit.