Skip to main content
63 votes
Accepted

Why do easy templates, .e.g, "< s TAB" in org 9.2 not work?

They changed the template system in orgmode 9.2. The new mechanism is called structured template. The command org-insert-structure-template bound to C-c C-, gives you a list of #+begin_-#+end_ pairs ...
Tobias's user avatar
  • 33.3k
9 votes
Accepted

Is it possible to organize the capture templates selection screen?

There are a couple of options for this, to me the easiest way is grouping templates using the built-in mechanism. My way to use capture templates is based in memory muscle rather than digging a long ...
Muihlinn's user avatar
  • 2,644
8 votes

Why do easy templates, .e.g, "< s TAB" in org 9.2 not work?

Others have stated that it's C-c C-, now to insert templates. One cool thing is that you can paste some code, then visual-select it and do C-c C-, s and it will wrap your selection inside #+begin_src ...
Philippe Carphin's user avatar
7 votes

Template for new file

At @Drew's suggestion, here's a short example of combining YASnippet and auto-insert to achieve dynamic or interactive boilerplate. From my ~/.emacs.d/init.el: ;;{{{ yasnippet & auto-insert (...
nega's user avatar
  • 3,276
7 votes

Template for new file

See standard library auto-insert.el, which is part of Emacs. To use it, customize options auto-insert and auto-insert-directory, then do this: (add-hook 'find-file-hook 'auto-insert) auto-insert ...
Drew's user avatar
  • 78k
6 votes
Accepted

How can I create custom org-mode templates?

You can use the templating system of org-mode. If you insert the following lines at the end of your init.el file: (add-to-list 'org-structure-template-alist '("P" "#+TITLE:\n#+OPTIONS: ...
Lgen's user avatar
  • 1,420
4 votes

Why do easy templates, .e.g, "< s TAB" in org 9.2 not work?

As described by Tobias, I had to (require 'org-tempo) in .emacs. Additionally, I had to remove any customization to org-structure-template-alist or revert it to standard. Then, C-c C-, triggers Org-...
leze's user avatar
  • 103
4 votes
Accepted

How to create a file from a template if it does not exist or open existing copy?

You could use this version of the function: (defun journal-entry () (interactive) (let* ((daily-name (format-time-string "%Y-%m-%d)")) (journal-path "~/Dropbox (Personal)/journal/") (...
Konstantin Morenko's user avatar
4 votes
Accepted

Creating templates in emacs

You'll want to take a look at Agenda Views, Org-Mode Capture Templates and / or YASnippet. With Org-Mode you can set up capture templates for various tasks and for different target locations, and ...
nyameko's user avatar
  • 555
3 votes
Accepted

How to run functions inside auto-insert template

You can specify a vector of actions for each entry in auto-insert-alist. This way you can insert the contents of the template file with the first action and then use a function that searches the new ...
Tobias's user avatar
  • 33.3k
3 votes
Accepted

How to use org-capture template expansion on finish?

AFAIK, template expansion happens at the very beginning of the capture, so you cannot use %U or similar escapes, since you can only add the end time at the end of the capture. But there are several ...
NickD's user avatar
  • 30.9k
2 votes
Accepted

Capture template without body

Try adding :empty-lines 0 to each template's set of properties. Zero is in fact the default value, so it would be strange if this was the solution, but maybe worth a try.
Phil Hudson's user avatar
  • 1,796
2 votes

How can I create custom org-mode templates?

You may want to check out this example wherein the author suggests this define-skeleton: (define-skeleton org-skeleton "In-buffer settings info for a emacs-org file." "Title: " "#+TITLE:" str " ...
147pm's user avatar
  • 2,979
2 votes

Use `%^{prop}p` `%^{prompt}` together in org-capture-templates

You can't do this with the t%^ template format strings. You can however call org-set-property when your template is constructed using the %(func) syntax. When called interactively org-set-property ...
erikstokes's user avatar
  • 12.9k
2 votes

Why do easy templates, .e.g, "< s TAB" in org 9.2 not work?

You can get completion back by adding org-tempo to org-modules like so (add-to-list 'org-modules 'org-tempo t) You will need to restart emacs so when orgmode is loaded it will load org-tempo as well. ...
Adam Oudad's user avatar
2 votes
Accepted

Evaluate a variable when inserting text into a buffer

Inside of GNU Emacs only your imagination is the limit :) I think you're looking for something along the following lines, though some adjustments might be needed. (defun header() "Insert header ...
aadcg's user avatar
  • 1,248
2 votes

Yasnippet conditional template depending on field value

On a more general note, here's an example that sets b to the value of a if a is not 0. # -*- mode: snippet -*- # name: test # key: test # -- a = ${1:0} b = ${1:$(unless (equal yas-text "0") ...
jagrg's user avatar
  • 3,954
2 votes

auto-insert-alist

It is unusually complicated for a customize interface, that's true. I'd go so far as to say the code that defines auto-insert-alist needs to be re-written to present a clearer interface making better ...
Phil Hudson's user avatar
  • 1,796
2 votes
Accepted

How to use a Template for creating YaSnippet snippets

Customize the variable yas-new-snippet-default (or let-bind the variable for temporary modification only), which is used when calling the function yas-new-snippet. https://github.com/joaotavora/...
lawlist's user avatar
  • 19.2k
1 vote
Accepted

auto-insert-alist

You can bypass both customize and use-package[1]. Add something like this to your init file, changing the definition of auto-insert-directory to whatever you want and adding dotted pairs of (mode . &...
NickD's user avatar
  • 30.9k
1 vote
Accepted

Org-capture template extension with project name

Thanks for the pointer @Fran Burstall. :-) I was able to get the desired behavior with a custom funtion: (defun gkh/project-current-name () "Get the name of the current project by returning the ...
grszkthfr's user avatar
1 vote

Yasnippet conditional template depending on field value

I managed to solve this by simply putting the following in my doom.d/config.el (with-eval-after-load 'yasnippet (defun maybe_notify_snip (snip_str) (if (string= snip_str "0&...
Reginald Marr's user avatar
1 vote
Accepted

Org mode HTML export presets

This solved my problem: http://bald.cat/slimhtml I hope this can also be of use to others. It allows one to define classes and ids etc while still in the org buffer.
Paulo Soares's user avatar
1 vote

How to set schedule and deadline for entires being inserted via org-capture template file?

I usually add %^{SCHEDULED}p to my org-capture template. But first it prompts for a SCHEDULED value which is useless and I leave it empty, and finally it prompts for a date and adds a SCHEDULED ...
Evgeny Mikhaylov's user avatar
1 vote

How to set schedule and deadline for entires being inserted via org-capture template file?

This seems to do the required trick. Found the jk-org-insert-time-stamp function here: https://emacs.stackexchange.com/a/27323/20123 . * PROJ %(progn (defun jk-org-insert-time-stamp (time-string) (...
Anuvrat Parashar's user avatar
1 vote

Why do easy templates, .e.g, "< s TAB" in org 9.2 not work?

you can use menu bar Org => Customize => Browse Org Group to add
kei's user avatar
  • 11
1 vote
Accepted

org-capture Template expansion leading whitespace: bug, feature, workaround

I found the solution although I must admit, I still don’t see, why this problem never occured in Org outlines I typed in directly: The custom-set-variable is called org-adapt-indentation and it has ...
Guebert's user avatar
  • 111
1 vote

How do I pre-process capture buffer before saving to target?

You are looking for org-capture-before-finalize-hook. (defcustom org-capture-before-finalize-hook nil "Hook that is run right before a capture process is finalized. The capture buffer is still ...
PuercoPop's user avatar
  • 396
1 vote

Putting emacs .org file options in .emacs file

Maybe not exactly what you are expecting as not in .emacs file, but in another Org file, the solution I use for a long time is to use #+SETUPFILE: In your .org files: #+SETUPFILE: path_to_your_setup/...
Picaud Vincent's user avatar
1 vote
Accepted

Yet another request for Emacs templates

I don't know how much elisp you know, so I'll post this for whoever can use it. I have not tested this code, but here's another defun (modelled after the one above) that will copy N of your favorite ...
Kevin's user avatar
  • 1,328

Only top scored, non community-wiki answers of a minimum length are eligible