org-babel-tangle.py icon indicating copy to clipboard operation
org-babel-tangle.py copied to clipboard

Understand ": tangle yes"

Open alienbogart opened this issue 7 years ago • 1 comments

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

alienbogart avatar Nov 21 '18 16:11 alienbogart

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 yes case: use fileinput.filename() to get the name of the org file being read. Handle the case where the script is reading from stdin with fileinput.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 handle KeyError (nicely = crash, but explain why)

Otherwise I'll implement when I'll find the time.

thblt avatar Nov 21 '18 17:11 thblt