reddit / emacs
How do you reload your init file when you put your config file in config.org which you then write to config.el?
LowCom · 2022-06-05 05:02
I switched my emacs config to org-mode babel and wheneve I make changes in config.org, I cannot immediately test it like I used to by sourcing the init file.
I now have to close the emacs daemon, reload it and only then I can see if my new config has any errors or doign what it;s intended to do?
How to fix this?
OutsideArmadillo791 · 2022-06-05 05:59
auto tangle config.org to ini.el with org-auto-tangle
LowCom · 2022-06-05 07:05
Please elaborate how to write this
tomratboy · 2022-06-05 07:38
I dont use the daemon so I just reload my client a lot if I need to. I often don't bother as I eval (C-x C-e) the expressions I'm writing as I write them, and then I reload emacs once I'm happy.
You could use `M-x load-file` and point it to your init.el, but consider that if you are frequently loading wouldnt be able to just comment lines out, you would have to do the opposite of what you wrote.
notperm · 2022-06-05 08:06
Just c-x c-f init.el and then m-x eval-buffer
X7and7 · 2022-06-05 09:26
Im not really sure what you mean, but this is my tutorial to org-babel:
​
If you want to org babel all your source blocks with a certain type (like elisp) to one file, you can just use:
`#+PROPERTY: header-args:elisp :tangle /home/haider/.emacs.d/init.el`
And yes, this is not limited to elisp
​
If you want to babel per source code block, you replace your "#+BEGIN\_SRC" with this:
`#+BEGIN_SRC fundamental :tangle "/home/haider/.bashrc"`
fundamental here being the major mode the file uses.
To test your code you can just run commands like "eval-last-sexp" or any "eval-foo" command in the org file (not sure eval-buffer would work though).
And to tangle the code blocks, just "M-x org-babel-tangle", and the codeblocks would immediatly be sent to the destination file (in your case init.el) and there you could just go to your init.el and eval-buffer if need be (I never do this, I mainly just use "M-x eval-last-sexp").
BettaGeorge · 2022-06-05 10:43
Depending on your setup, sourcing your init file might be a bad idea anyway.
I usually just mark the new stuff and do `eval-region`. A nifty shortcut for small changes is putting point after the closing parenthesis of your new code and calling `eval-last-sexp`, which is bound by default to `C-x C-e`.
BettaGeorge · 2022-06-05 10:46
FYI, `eval-last-sexp` is usually bound to `C-x C-e`, so you don't have to use `M-x`.
hkjels · 2022-06-05 11:00
Instead of using org-babel-load-file, I recommend that you tangle your init file instead, it will shave some seconds when launching emacs or the daemon.
Two more tips:
- Create templates for hooks and advices with the counterpart of removing them commented out.
- Evaluate the changed region instead of restarting. If you’ve broken something you can just evaluate the counterpart in the previous point.
When you’re happy with how stuff works, you just remove the comments
LowCom · 2022-06-05 13:07
How to tangle ? I am following this from a distro tube video and it's not working
Added this property at the beggining of document before title.
#+property: header-args :tangle filename
And then did M-x org-babel-tangle and it says that 0 code blocks were tangled. Don't know why.
hkjels · 2022-06-05 15:17
I don’t use that syntax myself. I typically create a property drawer or just add the tangle statement to each source block. The latter is the most flexible one
flexibeast · 2022-06-07 13:37
i assume what's being referred to is [this package](https://github.com/yilkalargaw/org-auto-tangle). (Haven't tried it myself, however.)