How do you overwrite a defcustom
of type: string
with a function that generates a string? Below a specific set-up is detailed:
Current set-up
In a .dir-locals.el file two variables are created python-shell-virtualenv-root
and python-pytest-executable
.
((nil . ((eval . (let ((direnv-python ".direnv/python-3.7.2"))
(setq-local python-shell-virtualenv-root (expand-file-name direnv-python projectile-project-root)
python-pytest-executable (expand-file-name (concat direnv-python "/bin/pytest") projectile-project-root)))
))))
The snippet above builds the two variables using direnv-python
.
Preferred set-up
Globally define the functions that build the two variables python-shell-virtualenv-root
and python-pytest-executable
, preferably in an init.el
. Then, in the .dir-locals.el
define the direnv-python
variable.
Then python-shell-virtualenv-root
and python-pytest-executable
should be created dynamically, using the direnv-python
variable.
Motivation
The logic for creating python-shell-virtualenv-root
and python-pytest-executable
is the same for every project. The direnv-python
is project specific. I would like to only specify the later per project.
EDIT
[1] defvar
should be defcustom