emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Adding information to tangled code regarding org-source


From: Ethan Ligon
Subject: [O] Adding information to tangled code regarding org-source
Date: Tue, 3 May 2016 21:33:37 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

When one exports from  org to, say, latex the resulting *.tex file includes 
a comment at the  top indicating the time of creation.  This is useful in 
part because it lets the user know that the *.tex file isn't the  original  
source.

The  same isn't true of tangled code from a source block, and I've been  
repeatedly bitten by editing a file of  python code that was tangled from a 
source org file.

I'd like to deal with  this by making tangle emit a comment with 
information about the org-source file.  The :prologue header argument is 
well suited to this; e.g.,

#+begin_src  python :tangle /tmp/test.py :prologue (format "# Tangled from 
%s on %s" (buffer-file-name) (current-time-string))
print "Hello, world!"
#+end_src

produces what one would want.

I'd like to make this header argument be applied automatically.  The 
variable org-babel-default-header-args looks like just the ticket, but  my 
lame efforts to write the necessary emacs-lisp aren't working:

#+BEGIN_SRC emacs-lisp
(add-to-list 'org-babel-default-header-args:python
                  '((:prologue . (format "# Tangled from %s on %s" (buffer-
file-name) (current-time-string)))))
#+END_SRC

What am I doing wrong?

Thanks for any help,
-Ethan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]