Auto-mode-alist, which sets the subdirectory ~

I would like to always call org-mode in a specific subdirectory called "notes" in my home directory. Right now, there is a line in my .emacs file that does not solve this problem like this:

(add-to-list 'auto-mode-alist '(".*/notes/.*" . org-mode))


This matches any / notes / directory and calls org-mode. But I don't want the org-mode in each directory to be called "notes" only in my home directory. The obvious answer doesn't work:

(add to the list "auto-mode-alist" ("~ / notes /.*". org-mode))

And more complex versions are slightly above my elisp skill level:

(add-to-list 'auto-mode-alist '('(concat (expand-file-name "~/notes/") ".*") . org-mode))


The above gives me the error message as well:

File mode specification error: (wrong-type-argument stringp (quote (concat (expand-file-name "~/notes/") ".*"))) 



source to share

1 answer


(add-to-list 'auto-mode-alist `(,(expand-file-name "~/notes/") . org-mode))




All Articles