From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Morgan Subject: Re: Adding source location information when tangling Date: Sat, 07 Jun 2014 13:23:44 +0900 Message-ID: <87wqcts5yn.fsf@azha.ziiuu.com> References: <87zji5bz6s.fsf@azha.ziiuu.com> <87r43d7ey0.fsf@azha.ziiuu.com> <87d2emezan.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wt8Af-00081q-3d for emacs-orgmode@gnu.org; Sat, 07 Jun 2014 00:24:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wt8AY-0008L0-09 for emacs-orgmode@gnu.org; Sat, 07 Jun 2014 00:23:57 -0400 Received: from mail-pb0-f42.google.com ([209.85.160.42]:43028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wt8AX-0008KH-Qf for emacs-orgmode@gnu.org; Sat, 07 Jun 2014 00:23:49 -0400 Received: by mail-pb0-f42.google.com with SMTP id md12so3291040pbc.1 for ; Fri, 06 Jun 2014 21:23:47 -0700 (PDT) In-Reply-To: <87d2emezan.fsf@gmail.com> (Eric Schulte's message of "Fri, 06 Jun 2014 12:24:07 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: "emacs-orgmode@gnu.org" , Rainer M Krug Eric Schulte writes: > Thomas Morgan writes: > >> Hi, Rainer,=20 >> >> Rainer M Krug writes: >> >>> Envoy=C3=A9 de mon iPhone >>> >>>> Le 25 mai 2014 =C3=A0 18:28, Thomas Morgan a =C3=A9cri= t : >>>>=20 >>>> Dear Org hackers, >>>>=20 >>>> I have a question about tangling LilyPond code blocks. >>>>=20 >>>> 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