1

I have a couple org files I use for meeting notes. The meeting note structure follows the same general pattern (slightly different for the different types of meetings). I can always manually copy a template from a template file, or copy from the previous meeting and delete/replace text as necessary. But, I'm being lazy about this and would rather insert a template by creating a shortcut. That said, I cannot figure out how to get emacs to insert the text. I know nothing of lisp, so I'm having difficulty starting. How would I insert the lines below at the current cursor position in my org file (this is not the actual template, just example lines; if I can get these lines to work then I can do the rest of the template)?

* Attendants
* Updates
* Notes

2 Answers 2

2

There are so many options. You can define a function to insert a string, or use the built-in skeleton library like this:

(define-skeleton meeting-skeleton
  "A meeting skeleton" nil
  "* Attendants
* Updates
* Notes")

then to insert your template, type M-x meeting-skeleton at the place you want to insert the string.

Another option is yas-snippets.

1
  • That's perfect, simple is fine and I'm sure I'll get a lot of mileage out of this example.
    – tnknepp
    Mar 3, 2021 at 18:21
0

My recommendation would be to use the yasnippet package, which allows you to define snippets of text/code for specific modes (so org snippets won't be invoked when you're editing a Python file for example).

yasnippet-snippets will install useful basic snippets for a bunch of different modes, which can be edited at your convenience ; they are text files located in ~/.emacs.d/elpa/yasnippets-snippets-xxxxxxxx/snippets/<your_mode>/<your_snippet> ; or deleted and replaced with personalized versions inside .emacs.d/snippets/ (the package automatically loads any snippet located in that folder with the appropriate arborescence)

An example that would answer this specific question would be a file named ~/.emacs.d/snippets/org-mode/meeting-note and containing

# -*- mode: snippet -*-
# name: meeting-note
# key: /mee
# --
* Attendants
- ${1: Default value}
- ${2: Default value}
- ${3: an absentee}
* Updates
$2
* Notes
$0

The "key" line defines what should be typed for the snippet of text to be invoked and it can be any convenient unique shortcut. When one types /mee then presses TAB, he will see the snippet appear and the cursor will take him through the different $ anchors going from 1 upwards by pressing TAB, then ending with $0.

yasnippet snipper illustration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.