我想在.dir-locals.el中定义一些变量,然后我在钩子中添加钩子到python-mode-hook,我想读取.dir-locals中定义的变量。问题是在加载.dir-locals.el
之前调用了模式钩子交换加载顺序的任何想法?
答案 0 :(得分:4)
您无法更换序列。它在normal-mode
中被硬编码。
但是,您可以在hack-local-variables-hook
处挂钩,在设置所有局部变量后运行。假设您目前有以下内容:
(defun my-python-hook-function ()
(message "Hello world"))
(add-hook 'python-mode-hook #'my-python-hook-function)
您只需将其更改为:
(defun my-local-variables-hook ()
(when (derived-mode-p 'python-mode) (my-python-hook-function)))
(add-hook 'hack-local-variables-hook #'my-local-variables-hook)