Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Understand ": tangle yes" #4

Open
alienbogart opened this issue Nov 21, 2018 · 1 comment
Open

Understand ": tangle yes" #4

alienbogart opened this issue Nov 21, 2018 · 1 comment
Assignees

Comments

@alienbogart
Copy link

alienbogart commented Nov 21, 2018

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

@thblt
Copy link
Collaborator

thblt commented Nov 21, 2018

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 thblt self-assigned this Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants