How to evaluate the expressions or functions in a code-block before tangling a source code block?
- I generate my
init.elfile usingorg-babel-tangle
AND - I'm using chemacs2chemacs2 - which allows using multiple configurations parallely. Chemacs2 uses a special file called
.emacs-profiles.elwhere we store location and environment properties of each of the configurations as mentioned below.
But the .emacs-profiles.el file cannot have any functions since it doesn't understand how to process them as mentioned here & here.
So, I'm looking for a way to evaluate the functions and replace the code content with the result. According to the documentation, we can use org-babel-pre-tangle-hook for this, but I'm very new to elisp and I'm not sure how to write the hook.
Please note that I have a working configuration with chemacs that handles multiple configurations like
spacemacs,doom emacs... But the.emacs-profiles.elconfig is specific to my current windows PC - since it mentionsC:\\Users\\<username>in the file path. So I cannot directly use the same.emcas-profiles.elconfig in another system as is without updating the<username>. That's the reason I'm looking for this approach.
Below is the source code block that I want to be evaluated:
( ("default" . ((user-emacs-directory . "~/emacs-configs/my-config") (env . ( ("HOME" . (concat (getenv "APPDATA") "\\AG-Emacs"))) )))) ) I want this to be evaluated and tangled like this:
( ("default" . ((user-emacs-directory . "~/emacs-configs/my-config") (env . ( ("HOME" . "C:\\Users\\<username>\\AppData\\Roaming\\AG-Emacs") )))) ) Useful/Similar resources I found:
- ntangle - tangle org file using an external tool
- add custom header args for org tangle
- How do you run a shell command or execute a code block on tangle?