[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: About the usage of `with-eval-after-load'.
From: |
Omar Polo |
Subject: |
Re: About the usage of `with-eval-after-load'. |
Date: |
Sat, 18 Sep 2021 12:28:16 +0200 |
User-agent: |
mu4e 1.6.6; emacs 28.0.50 |
h
Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> `C-h o with-eval-after-load RET' gives the following description:
>
> with-eval-after-load is a Lisp macro in ‘subr.el’.
>
> (with-eval-after-load FILE &rest BODY)
>
> Execute BODY after FILE is loaded.
> FILE is normally a feature name, but it can also be a file name,
> in case that file does not provide any feature. See ‘eval-after-load’
> for more details about the different forms of FILE and their semantics.
> ;;;
>
> Based on the above explanation, it seems that only one FILE can be
> used, but according to my tries, the following code snippet also take
> effect:
>
> (add-hook 'python-mode-hook 'hs-minor-mode)
> (with-eval-after-load
> "python"
> (progn
> (define-key python-mode-map (kbd "C-c TAB") 'hs-toggle-hiding)
> (add-to-list
> 'python-shell-completion-native-disabled-interpreters "jupyter")
> )
>
> 'elpy (pyvenv-activate "~/.pyenv/versions/datasci")
> )
this is wrong. as the signature says, it accepts a first argument
"file" and then the body to execute. here, it seems that you want to
execute something when `python' is loaded and something else when `elpy'
is loaded, which warrants two `with-eval-after-load':
(with-eval-after-load 'python
(define-key ...)
(add-to-list ...))
(with-eval-after-load 'elpy
(pyvenv-activate ...))
Other than that, I don't usually write python so can't comment further
on the code
> Is there anything wrong with my understanding of this macro? Any hints
> will be helpful.
>
> Regards
Cheers,