reddit / emacs

Org mode execute all related blocks, after tangling all of them together

nog_u · 2022-02-14 06:14
Hello, I've been playing with emacs for about 2 weeks or so, really liking it so far (I've been using vim/neovim for about 6 years now). I'm trying to figure out how to make it so that when I `C-c` in a src block in org-mode, it first checks all related src blocks in the file, tangle them together in a temporary buffer and only then execute the buffer, providing the results needed. Is there a native way to do that? Am I supposed to use the post-tangle hook org-babel provides? For now what I'm doing is: \- create all src blocks setting the tangle to a file location I can access, like `#+begin_src typescript :tangle ~/tmp/this-is-a-test.ts` \- run `org-babel-tangle` \- running the compiler on that file manually to find out the results However, that is tedious and I want to figure out a way to make it feel "native". My next hunch would be to try making a custom function that runs `org-babel-tangle-file` on the current buffer, somehow figuring out the language (based on the src block opening statement, maybe?), pasting the tangle on the temporary buffer and then running whatever is the equivalent `org-babel-execute:*` and only then bringing that (not sure how) to the `#+RESULTS` tag content. Am I on the right track or am I missing something? I've tried googling for this problem and I couldn't find out anyone actually trying to get the result of executing the final tangled file back to the original org file. Also would like to mention that this is mainly for (somewhat of) a literate programming habit I'm trying to create. I get many ideas and it is pretty useful to sketch out an org document outlining the main ideas and how the blocks might fit together later, in an actual production file. If you have any tips for a newbie getting into emacs/org, it would be greatly appreciated! Thanks in advance! Edit: fixing typos and I also forgot to mention that it is pretty disturbing how much fun I'm having customizing a bloody editor. Whenever I find something that annoys me, I spend so much time figuring out how to make it better and tidying the code up that I often forget what I was meant to be doing in the first place (lol). Also, ELisp is great and having all the help built into the editor is an amazing idea. I think I'll be using this editor for a long time!!
xenodium · 2022-02-14 07:16
There’s noweb which may work for your needs https://orgmode.org/manual/Noweb-Reference-Syntax.html I did something custom https://xenodium.com/emacs-chaining-org-babel-blocks ps. Nice to hear you’re enjoying the journey. It is indeed fun.
Danrobi1 · 2022-02-14 12:07
> I've been playing with emacs for about 2 weeks or so Nice. Welcome! > it is pretty disturbing how much fun I'm having customizing a bloody editor. Haha same here. > having all the help built into the editor is an amazing idea Indeed! Emacs is awesome. > I think I'll be using this editor for a long time!! Great! Wish you lots of fun with Emacs.
nog_u · 2022-02-14 12:13
Ah cool, that sounds more like what I want to do. Although you still need to type the `<<thingy>>` it is cool to have that without having to build anything separately. Thanks for the tip! Your blog looks good! I'll for sure read that post carefully to maybe learn a thing or two.
nog_u · 2022-02-14 12:13
Thanks!!