tecosaur / org-glossary

Mirror of https://git.tecosaur.net/tec/org-glossary
GNU General Public License v3.0
97 stars 4 forks source link

Question: text substitution only on export? #8

Closed japhir closed 2 years ago

japhir commented 2 years ago

Hi tecosaur, excellent package as always!

I'm trying to get the following behaviour in my document:

#+latex_header: \usepackage[version=4]{mhchem}
I want to write plain d18O in my main text, in stead of having to write the full definition every time.

with the following 
* Text Substitutions
- d18O :: \ensuremath{\delta}\ce{^18O}

Right now, with org-glossary-mode on this replaces d18O with the full definition whenever I type it, and when I copy the text it is also the full replacement text (it's like a yasnippet!) Is it possible to turn off the substitution preview, while leaving it a link to hover on with the appropriate styling? Obviously on export I would sitll like it to do its thing. The reason being that I'd like to look at the simplifications while writing.

Kind regards,

japhir

EDIT: even if I use the simpler \delta^{18}O as a definition, my org-entities preview kicks in and it looks kind of nice, but this preview appears turned off for the replacement text.

japhir commented 2 years ago

perhaps a separate issue, but I've also noticed the text replacements introduce a newline in the latex export, which means that if I type d18O? it will export to

\ensuremath{\delta}\ce{^18O}
?

in the PDF export this leads to an undesired space before the ?

tecosaur commented 2 years ago

Right now, with org-glossary-mode on this replaces d18O with the full definition whenever I type it, and when I copy the text it is also the full replacement text (it's like a yasnippet!)

It's just a display property, as can be verified with buffer-substring:

#("write plain d18O in my main text"
  12 16
  (fontified t help-echo org-glossary--help-echo-from-textprop face org-glossary-substituted-value mouse-face
   (:inverse-video t)
   display "\\ensuremath{\\delta}\\ce{^18O}" keymap
   (keymap
    (follow-link . mouse-face)
    (mouse-2 . org-glossary-goto-term-definition)
    ("RET" . org-glossary-goto-term-definition)
    (return . org-glossary-goto-term-definition)))))

Beyond that, you can turn off display substitutions by setting org-glossary-display-substitute-value to nil. I've added this to the docs in d87f8ad99a5e7489f3821f15c3e8528de34a93c4.

this preview appears turned off for the replacement text.

Right, at the moment only the text is copied, not the fortification of the text. This is something that could be improved, but is not a priority.

I've also noticed the text replacements introduce a newline in the latex export

Hmmm, I thought I'd used string-trim enough to stop this from happening. I may need to give this a second look. In any case, this should be a separate issue, so I'll close this one as the original concern should be resolved.

tecosaur commented 2 years ago

org-entities preview kicks in and it looks kind of nice, but this preview appears turned off for the replacement text.

Frankly, I'm not sure how I ended up doing this, but I've added fortification to the displayed snippets. Sub/super scripts don't work, but other than that it seems to work well.

image

See e598ef072d680a3f7c2fe5b262dea76dd831b13d.