TransWikia.com

org-mode document structure / templates

Emacs Asked by Mr. Hasquestions on January 22, 2021

Suppose you had a large org document of recipes, with hundreds of entries like this:

* Tasty Pudding
** Ingredients
- Milk
- Sugar
- Eggs
- Flavorings
** Process
1. Mix the eggs and sugar
2. Heat up the milk and flavorings
3. Temper the milk into the egg mixture
4. Cook the pudding
** Description
It's my favorite pudding

But then you realize the description subheading is pointless and your recipes should be structured more like

* Tasty Pudding
It's still my favorite pudding, but it makes more
sense to have the description up here!
** Ingredients
...
** Process
...
** Notes
Here's my new additional thoughts about this
pudding.

Is it possible to either edit all of these entries at once, or ideally have some kind of “node” structure that these recipes are bound to?

So for example, I could see having a Yas Snippet like:

* $1
$2
** Ingredients
- $3
** Process
1. $4
** Notes
$5

But of course that would only work for your new recipes, it can’t fix the old ones.

One Answer

I defined a macro.

  • At the beginning of the document and start the macro (F3),
  • Search (C+s) for the string * Description (I hope you don't have another structure with name starting with Description) and hit enter (RET),
  • Move the section up twice, (M+up x 2)
  • Go to the beginning of the line (C+a) and kill it (C+k),
  • End the macro (F4),
  • Select the buffer (C+h) and apply the macro (M+x apply-macro-to-region-lines RET)

Answered by Dox on January 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP