auto-mode-alist,指定〜的子目录

spe*_*ool 3 emacs elisp

我想在我的主目录的一个名为"notes"的特定子目录中调用org-mode.现在在我的.emacs文件中有一行以一种糟糕的方式解决了这个问题:

(add-to-list 'auto-mode-alist '(".*/notes/.*" . org-mode))
Run Code Online (Sandbox Code Playgroud)

这匹配任何/ notes /目录并调用org-mode.但我不希望在每个目录中的org-mode恰好被称为"notes",只是我的主目录中的那个.明显的答案不起作用:

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

更复杂的版本略高于我的elisp技能水平:

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

以上给出了我的错误信息:

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

hua*_*uan 6

尝试

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