reddit / emacs

Some questions about org-babel

Foo-jin · 2022-09-15 17:51
I've recently decided to give org-mode and org-babel a shot as a notebook (think jupyter). I have a cli program that takes two text files as input. Currently, I've put those text files in a `#+begin_src text` block, with a tangle. I then have a `#+begin_src sh` block taking two filenames as input variables that invoke the cli program with the filenames. The current workflow thus ends up being: 1. don't forget to tangle the input files 2. invoke the shell block Ideally I'd like to somehow configure it such that invoking the shell block will auto-tangle the input blocks, or something to that effect (if there's an option to put them in a temp file and present the filename to the `sh` block, that's also fine). Is this something that can be done somewhat straightforwardly? Secondly, currently I have the following tangle instructions on each input file: `:tangle (org-in-tangle-dir "file.txt")`. The filename to tangle to is identical to the `#+name: file.txt` preceding the block. The `org-in-tangle-dir` function is defined as follows: (defun org-in-tangle-dir (sub-path) "Expand the SUB-PATH into the directory given by the tangle-dir property if that property exists, else use the `default-directory'." (expand-file-name sub-path (or (org-entry-get (point) "tangle-dir" 'inherit) (default-directory)))) Is there any way to tell the tangle to use the `#+name` attribute as filename to tangle to? Thanks for any help
Sound4Sound · 2022-09-15 18:34
I had a cheap way to tangle with filename: :tangle (concat "../src/" (org-element-property :name (org-element-context))) Here is a setup file with that header arg: https://raw.githubusercontent.com/AlbertoV5/dotfiles/main/org-examples/pow/org/header.setup I switched to defining getters for the paths at the top of the file as it got too funky for me using the name property, but I'm sure you can do better than me.
uita23 · 2022-09-15 20:07
It's a tangent, but this looks really cool: https://github.com/rougier/notebook-mode