diff --git a/README.org b/README.org index c08e480..8120d12 100644 --- a/README.org +++ b/README.org @@ -1774,10 +1774,11 @@ compatible with [[info:org#Editing Source Code][source code block editing]] whil '(python-shell-interpreter-args "-i -E"))) #+end_src -Listing [[lst:configure-eglot-for-python]] configures [[https://github.com/joaotavora/eglot][eglot]] for [[https://www.python.org][Python]]. It may be a -good idea to launch [[https://github.com/joaotavora/eglot][eglot]] by means of [[info:emacs#Directory Variables][directory variables]] in the root directory -of any [[https://www.python.org][Python]] project. Listing [[lst:eglot-directory-variables-for-python]] does a -proposal. +Listing [[lst:configure-eglot-for-python]] configures [[https://github.com/joaotavora/eglot][eglot]] for [[https://www.python.org][Python]]. It defines +a hook function to launch [[https://github.com/joaotavora/eglot][eglot]] by means of a proper [[info:emacs#Directory Variables][directory variables]] file in +the root directory of any [[https://www.python.org][Python]] project. Listing +[[lst:eglot-directory-variables-for-python]] does shows such a proper [[info:emacs#Directory Variables][directory +variables]] file. #+caption[Configure =eglot= for Python]: #+caption: Configure =eglot= for Python. @@ -1792,6 +1793,16 @@ proposal. "numpy" "scipy")))))) (:pylsp . (:plugins (:jedi_completion (:eager nil))))))) + + (when (fboundp 'eglot-ensure) + ;; The two hooks `after-change-major-mode-hook' and + ;; `hack-local-variables-hook' are OK, but `-mode-hook' is not. + (add-hook 'hack-local-variables-hook + (defun on-hack-local-variables-hook-eglot-maybe () + (when (and (derived-mode-p 'python-mode) + (assoc 'eglot-workspace-configuration + dir-local-variables-alist)) + (eglot-ensure))))) #+end_src #+caption[Propose =directory-variables= to launch =eglot=]: @@ -1802,11 +1813,9 @@ proposal. ;; Proposal for a .dir-locals.el file in the root of any Python project. ((python-mode . ((eglot-workspace-configuration - . `((:pylsp . (:plugins (:jedi_completion - (:cache_for ,(vconcat '("astropy" - "numpy" - "scipy")))))) - (:pylsp . (:plugins (:jedi_completion (:eager nil))))))))) + . ((:pylsp . (:plugins (:jedi_completion + (:cache_for ["astropy" "numpy" "scipy"])))) + (:pylsp . (:plugins (:jedi_completion (:eager nil))))))))) #+end_src Listing [[lst:configure-anaconda-for-python]] configures [[https://github.com/pythonic-emacs/anaconda-mode][anaconda]]. See