org-babel-tangle.py
org-babel-tangle.py copied to clipboard
Understand ": tangle yes"
I understand I could use #+BEGIN_SRC emacs-lisp :tangle filename, but if OrgTangle could parse the :tangle yes attribute my setup would be simpler.
If this is not possible, an alternative would be to be able to get this information as a property of the file, like this:
#+PROPERTY: header-args:emacs-lisp :tangle filename
I really won't have time to do this anytime soon, but it should be really easy if you know some basic Python. If you're interested in implementing it, here's a quick starting point:
- Create a dict somewhere associating languages names to extensions: eg
{"python": "py", "c++": "cpp"}etc. - Somewhere around here, handle
yescase: usefileinput.filename()to get the name of the org file being read. Handle the case where the script is reading from stdin withfileinput.isstdin(); abort with an error message. (real org would prompt, but Emacs is interactive) [Question: would "t" be valid too?] - Somewhere around here, read language name from
line[1]. The language name will be all lowercase. - Find new extension in this dict, make new file name by replacing extension of input file name only if
.org, otherwise append. Nicely handleKeyError(nicely = crash, but explain why)
Otherwise I'll implement when I'll find the time.