Eric Schulte <schulte.e...@gmail.com> writes:

> Thomas Morgan <t...@ziiuu.com> writes:
>
>> Hi, Rainer, 
>>
>> Rainer M Krug <r.m.k...@gmail.com> writes:
>>
>>> Envoyé de mon iPhone
>>>
>>>> Le 25 mai 2014 à 18:28, Thomas Morgan <t...@ziiuu.com> a écrit :
>>>> 
>>>> Dear Org hackers,
>>>> 
>>>> I have a question about tangling LilyPond code blocks.
>>>> 
>>>> Is there a way to put the commands `\sourcefilename' and
>>>> `\sourcefileline' in the tangled file before each block,
>>>> perhaps in place of the comment that includes the same information?
>>>
>>> Yes - Check out the header option concerning tangling with comment. So
>>> links are inserted as comments which contain information about the
>>> filename And the header from which it was tangled.
>>
>> Thank you; that option is certainly useful.  What I was looking for,
>> though, is a way to replace or supplement the comments with commands
>> that indicate the same information directly to the compiler or
>> interpreter (`\sourcefilename' and `\sourcefileline' for LilyPond,
>> `#line' for C, etc.).
>>
>
> Hi Thomas,
>
> I believe the `org-babel-tangle-comment-format-beg' and
> `org-babel-tangle-comment-format-end' variable should provide the
> functionality you desire.

Hi, Eric,

Thank you, though I'm afraid I'm still having trouble getting
the right result.  The closest I've come is with this setting:

  (setq org-babel-tangle-comment-format-beg
        "\\sourcefilename \"%file\"\n\\sourcefileline %start-line")

But this adds comment characters before the commands.

It also adds a blank line after the comment, throwing line numbers
off by one.  (Actually they are off by two; maybe LilyPond needs
\sourcefileline to be on the same line as the beginning of the code.)

By the way, I tried binding the variable this way in the Org file:

  #+BIND: org-babel-tangle-comment-format-beg "\\sourcefilename 
\"%file\"\n\\sourcefileline %start-line"

But that had no effect.

A further question: can this approach accommodate code blocks in
multiple languages in the same file?

Best,

Thomas

Reply via email to