5

I'm basically a level 0 emacs/orgmode user, trying to get the hang of Emacs/Orgmode. Doing this like for the 5th time already, as most Emacs beginners obviously. I have this feeling I'll like and be happy with the Emacs world, but oh well it takes a lot of patience. So I'm trying to do things little by little.

So I'm trying to do something that seemingly should be quite doable but can't understand how to make it work. The idea is to reuse predefined text within a buffer.

I think that what I want is to define kind of "text variables" or "snippets" and reuse that in my text later on.

Let's say I'm writing some specification for my laptop. I'd like to something like define a term in buffer (don't pay attention to syntax, it's just my interpretation), let's say "Thinkpad T470p, black, with dedicated graphics card, XYZ".

So I'd define this term at the beginning of my buffer.

The term, presumably, would have a label/name (not sure if this is the correct term) and some value. Let's say, the value is as above and label is "MyThinkPad".

Then when writing text, I'd like to start writing "MyThinkPad" and that would auto-insert the previously predefined text "Thinkpad T470p, black, with dedicated graphics card, XYZ" at the cursor position.

AND what is most important - if I change value of this "variable" in the buffer , that should auto-update throughout the buffer.

I'm not sure what is the right direction to look. I have a feeling this has to do with some of these "#+NAME" or "#+LABEL", or citations, or local variables, or something of that sort.

After reading online resources and trying out various ideas, I'm stuck and turning to community help. Really looking forward to your suggestions. Thanks in advance!

  • 2
    If it wasn't for the auto-update requirement, that would sound a lot like the generic abbrev-mode facility, but the persistent auto-update part makes things more interesting. It sounds like the actual text of the file should remain as "MyThinkPad" everywhere that was typed, and for display purposes only the instances should be changed. There are some generic features which would handle this as well, but finally I am imagining that you want this translation to be performed automatically during org exports? Could you confirm that one way or the other? – phils May 9 '18 at 9:42
  • 2
    You may have a look at macro replacement. – Juancho May 9 '18 at 15:08
  • @phils - well, I have a feeling that we're digging deeper than necessary. Or maybe I just haven't yet grasped the Emacs/Orgmode way of doing things. – Lauris May 10 '18 at 10:37
  • Basically I'd like to define like a "constant" within a buffer and then reuse it. Not sure if those should be name/value pairs. Maybe it's sufficient to define the whole phrase in the buffer, and then have something like "references" or "links" in text to that defined phrase. And if there is such reference, the buffer would understand that the whole phrase has to be shown. And since that would be a reference, it would auto-update if the defined phrase is changed. – Lauris May 10 '18 at 10:46
  • Somehow I'd like to think that this should be a regular thing, especially in technical writing. But probably I'm just dreaming here. – Lauris May 10 '18 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.