I am using Chemacs2 and I want to set an environment variable in the .emacs-profiles.el, eg
To clarify the problem .emacs-profiles.el is not executed it is read and I have updated the post with a proper sample, ie a list of lists.
It does not provide and is not required
(
("vanilla" .((user-emacs-directory . "~/emacsen/vanilla/.emacs.d")))
("doom01" . ((user-emacs-directory . "~/emacsen/doom01/.emacs.d")
(env . (("DOOMDIR" . "~/emacsen/doom01/doomdir")
("PATH" . (concat "~/emacsen/doom01/.emacs.d/bin/doom" ":" (getenv "PATH")))
))))
)
The file that processes it is https://github.com/plexus/chemacs2/blob/master/chemacs.el.
The profile eg vanilla or doom01 is passed on the command line and its values such as user-emacs-directory and env used for that Emacs session.
The function which sets the environment variables is
(mapcar (lambda (env)
(setenv (car env) (cdr env)))
(chemacs-profile-get 'env))
and it fails on the pair ("PATH" . (concat "~/emacsen/doom01/.emacs.d/bin/doom" ":" (getenv "PATH"))) because (cdr env) which is (concat "~/emacsen/doom01/.emacs.d/bin/doom" ":" (getenv "PATH")) gets passed to the setenv call as it is without being evaluated first.
I have tried some of the splicing techniques listed at Backquote to no avail.
If the expression in the .emacs-profiles.el can't be written in a better way then is there a way to rewrite (cdr env) in (setenv (car env) (cdr env)) in such a way that it gets evaluated to a string before setenv tries to apply it?
backquote- see e.g. this question and answers – NickD Nov 05 '21 at 15:39envis a list of environment variables for that Chemacs configuration and the setenv function requires the second parameter ie(cdr env)to be a string so(concat "~/emacsen/doom01/.emacs.d/bin/doom" ":" (getenv "PATH"))must be evaluated before it gets passed tosetenv. I think the problem comes from the fact that.emacs-profile.elis not executed, it isreadand that is probably why it is not evaluated.setenvprobably reads the raw expression then evaluates it. I will update the question. – vfclists Nov 05 '21 at 16:37backquoteis the solution, so more details will help. – NickD Nov 05 '21 at 17:12--debug-initthe error the debugger displays isDebugger entered--Lisp error: (wrong-type-argument characterp concat). My conclusion is that the Chemacs codereadsthe expression and does not evaluate it, so the(cdr env)value passed tosetenvis the raw symbol from thereadand thus fails because it is not a string expression. – vfclists Nov 06 '21 at 12:23