emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ethan Ligon <ligon@berkeley.edu>
To: emacs-orgmode@gnu.org
Subject: Adding information to tangled code regarding org-source
Date: Tue, 3 May 2016 21:33:37 +0000 (UTC)	[thread overview]
Message-ID: <loom.20160503T232411-815@post.gmane.org> (raw)

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	other threads:[~2016-05-03 21:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03 21:33 Ethan Ligon [this message]
2016-05-04  1:23 ` Adding information to tangled code regarding org-source Ken Mankoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20160503T232411-815@post.gmane.org \
    --to=ligon@berkeley.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).