emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Adding information to tangled code regarding org-source
@ 2016-05-03 21:33 Ethan Ligon
  2016-05-04  1:23 ` Ken Mankoff
  0 siblings, 1 reply; 2+ messages in thread
From: Ethan Ligon @ 2016-05-03 21:33 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Adding information to tangled code regarding org-source
  2016-05-03 21:33 Adding information to tangled code regarding org-source Ethan Ligon
@ 2016-05-04  1:23 ` Ken Mankoff
  0 siblings, 0 replies; 2+ messages in thread
From: Ken Mankoff @ 2016-05-04  1:23 UTC (permalink / raw)
  To: Ethan Ligon; +Cc: emacs-orgmode


How about ":comments link" header arg?

https://org-babel.readthedocs.io/en/latest/header-args/#comments

  -k.

On 2016-05-03 at 17:33, Ethan Ligon <ligon@berkeley.edu> wrote:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-04  1:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-03 21:33 Adding information to tangled code regarding org-source Ethan Ligon
2016-05-04  1:23 ` Ken Mankoff

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).