15

I would like to manage the tangling my org files with a Makefile. Though I can not find any information of how to tangle files from the command line.

12

You can use something like:

emacs --batch --eval "(require 'org)" --eval '(org-babel-tangle "file-to-tangle.org")'

(That shell quoting is meant for Bash, adjust if you use a different shell.)

  • I tried it and received a Wrong type argument: stringp, nil error message, any suggestion of what I am possibly doing wrong? – lookyhooky Sep 17 '16 at 1:06
  • 1
    I also need the -L flag to add the current directory to the load path, and -l file-to-tangle.org to load the file before attempting to tangle it. – lookyhooky Sep 17 '16 at 1:14
  • 8
    emacs --batch -l org foo.org -f org-babel-tangle or emacs --batch -l org --eval '(org-babel-tangle-file "foo.org")' works for me. – xuchunyang Sep 17 '16 at 7:28
  • Thanks @xuchunyang, I am using your suggestion and it is working perfect. – lookyhooky Sep 17 '16 at 13:06
  • 1
    For a Bash script, this is useful: emacs --batch -l org --eval "(org-babel-tangle-file \"$1\")" – pentavalentcarbon Jul 21 '17 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.