Como posso acessar variáveis locais do diretório nos meus ganchos principais?

Eu defini um arquivo .dir-locals.el com o seguinte conteúdo:

((python-mode . ((cr/virtualenv-name . "saas"))))

No meu .emacs, tenho a seguinte função para recuperar esse valor e fornecer um caminho virtualenv:

(defun cr/virtualenv ()
  (cond (cr/virtualenv-name (format "%s/%s" virtualenv-base cr/virtualenv-name))
        ((getenv "EMACS_VIRTUAL_ENV") (getenv "EMACS_VIRTUAL_ENV"))
        (t "~/.emacs.d/python")))

Finalmente, na minha lista python-mode-hook, tenho esta função de hook:

(add-hook 'python-mode-hook 'cr/python-mode-shell-setup)

(defun cr/python-mode-shell-setup ()
  (message "virtualenv-name is %s" cr/virtualenv-name)
  (let ((python-base (cr/virtualenv)))
    (cond ((and (fboundp 'ipython-shell-hook) (file-executable-p (concat python-base "/bin/ipython")))
           (setq python-python-command (concat python-base "/bin/ipython"))
           (setq py-python-command (concat python-base "/bin/ipython"))
           (setq py-python-command-args '( "-colors" "NoColor")))
          (t
           (setq python-python-command (concat python-base "/bin/python"))
           (setq py-python-command (concat python-base "/bin/python"))
           (setq py-python-command-args nil)))))

Quando abro um novo arquivo python, a mensagem registrada porcr/python-mode-shell-setup indica quecr/virtualenv-name énil. No entanto, quando clico no nome, recebo "saas".

Obviamente, há um problema de ordem de carga aqui; existe uma maneira de fazer com que minhas instruções de gancho de modo respondam a variáveis locais do diretório?

questionAnswers(1)

yourAnswerToTheQuestion