Question

I'm looking for a way to tell auto-insert-mode to use different templates regarding on the file path (not only on the file extension).

I want all .org files created under a directory */meetings to have a defined template.

The following setting does not work :

(auto-insert-mode)  
(setq auto-insert-directory "~/org/template/") ;;; *NOTE* Trailing slash important
(setq auto-insert-query nil) ;;; If you don't want to be prompted before insertion
(define-auto-insert "\/meetings/\.org" ".meetings_template.org")
(define-auto-insert "\.org" ".template.org")

Do you have an idea ?

Was it helpful?

Solution

The names are matched with a regular expression. The one you gave for meetings is not doing what you want. Try this one instead: "/meeting/.*\\.org"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top