Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oantolin/placeholder
Emacs package to treat any buffer as a template with placeholders to fill-in
https://github.com/oantolin/placeholder
Last synced: 12 days ago
JSON representation
Emacs package to treat any buffer as a template with placeholders to fill-in
- Host: GitHub
- URL: https://github.com/oantolin/placeholder
- Owner: oantolin
- License: gpl-3.0
- Created: 2020-04-06T21:31:31.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-26T23:49:29.000Z (over 2 years ago)
- Last Synced: 2024-08-07T18:31:15.388Z (5 months ago)
- Language: Emacs Lisp
- Size: 15.6 KB
- Stars: 27
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
* Placeholder
This package provides a simple way to treat text in a buffer
as a template with placeholders where text needs to be filled in. Any
occurrence of =<++>= in the buffer is a placeholder. You can navigate
among the placeholder with the =placeholder-forward= and
=placeholder-backward= commands. They move the point to the next
placeholder in the specified direction and delete the placeholder so
you can immediately start typing the text that should replace it.
However, if you call them again immediately after, they restore that
occurrence of the placeholder and move to the next.The placeholder in only =<++>= by default, it can be changed by
customizing the =placeholder-string= variable.A =placeholder-insert= command is also provided, to insert the
placeholder string.I suggest the following keybindings:
| Command | Keybinding |
|----------------------+----------------------------|
| =placeholder-forward= | =C-S-n= |
| =placeholder-backward= | =C-S-p= |
| =placeholder-insert= | =C-S-x= (X marks the spot!) |* When to use Placeholder over richer templating options?
Why not just use [[http://joaotavora.github.io/yasnippet/][YASnippet]] or the built-in [[https://www.gnu.org/software/emacs/manual/html_node/autotype/index.html][Skeletons]] or [[https://www.gnu.org/software/emacs/manual/html_node/autotype/Tempo.html][Tempo]]
libraries? All of these great packages are /much/ more featureful and
ambitious than Placeholder, but they require defining the template in
advance and arranging for some way to insert it in a buffer: naming
the template or binding it to a key. This makes perfect sense for
templates you plan to use many times, like for loops or CommonMark
code blocks, or other things people typically make snippets for. But
it can feel like too much work if you just want to leave some spots
marked in your buffer to fill in later, or to make bespoke templates
you only ever plan to use a few times. In those situations Placeholder
might be a better fit.For example, I often want to write several similar but not identical
emails to different people. I write the first one right in the message
buffer using placeholders and put the text in a register. Then I
repeatedly insert the template, fill it out and send the email.