* how to quote "#+end_src" string in a Babel block?
@ 2013-07-24 5:39 asenal
2013-07-24 6:11 ` Thorsten Jolitz
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: asenal @ 2013-07-24 5:39 UTC (permalink / raw)
To: emacs-orgmode
Hi Guys I'm trying to do literature programming with org mode.
My problem is How can I safely quote "#+XXX" inside a Babel-block?
I found org-mode mismatch the outter "#+begin_src" with the first "#+end_src" inside the block hence gives me a wrong parse.
Here's an example:
#+headers: :var varlist=top_iv
#+begin_src python :return iv_template(varlist)
def iv_template(varlist,db,table):
for var in varlist:
babel_template='''
#+name: var
#+begin_src sqlite :db mydb
SELECT colName,cnt,suc,fal,iv FROM mytable WHERE colName == %s';
#+end_src # org mode stop here!
''' % (var,var)
print babel_template
#+end_src
I know it looks twisted,but what I really care is wheather org-mode holds the capability to do so.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to quote "#+end_src" string in a Babel block?
2013-07-24 5:39 how to quote "#+end_src" string in a Babel block? asenal
@ 2013-07-24 6:11 ` Thorsten Jolitz
2013-07-24 7:24 ` Nicolas Goaziou
2013-07-24 22:32 ` Eric Schulte
2 siblings, 0 replies; 5+ messages in thread
From: Thorsten Jolitz @ 2013-07-24 6:11 UTC (permalink / raw)
To: emacs-orgmode
asenal <asenalhere@gmail.com> writes:
> Hi Guys I'm trying to do literature programming with org mode.
> My problem is How can I safely quote "#+XXX" inside a Babel-block?
> I found org-mode mismatch the outter "#+begin_src" with the first "#+end_src"
> inside the block hence gives me a wrong parse.
>
> Here's an example:
> #+headers: :var varlist=top_iv
> #+begin_src python :return iv_template(varlist)
> def iv_template(varlist,db,table):
> for var in varlist:
> babel_template='''
> #+name: var
> #+begin_src sqlite :db mydb
> SELECT colName,cnt,suc,fal,iv FROM mytable WHERE colName == %s';
> #+end_src # org mode stop here!
> ''' % (var,var)
>
> print babel_template
> #+end_src
>
> I know it looks twisted,but what I really care is wheather org-mode
> holds the capability to do so.
I don't know Python, but maybe you could do something like this
#+begin_src emacs-lisp :results value
(concat
(format "%s%s %s\n\n" "\#+" "begin_src" "python")
(format "%s%s" "\#+" "end_src"))
#+end_src
#+results:
: #+begin_src python
:
: #+end_src
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to quote "#+end_src" string in a Babel block?
2013-07-24 5:39 how to quote "#+end_src" string in a Babel block? asenal
2013-07-24 6:11 ` Thorsten Jolitz
@ 2013-07-24 7:24 ` Nicolas Goaziou
2013-07-24 22:32 ` Eric Schulte
2 siblings, 0 replies; 5+ messages in thread
From: Nicolas Goaziou @ 2013-07-24 7:24 UTC (permalink / raw)
To: asenal; +Cc: emacs-orgmode
Hello,
asenal <asenalhere@gmail.com> writes:
> My problem is How can I safely quote "#+XXX" inside a Babel-block?
> I found org-mode mismatch the outter "#+begin_src" with the first "#+end_src" inside the block hence gives me a wrong parse.
>
> Here's an example:
> #+headers: :var varlist=top_iv
> #+begin_src python :return iv_template(varlist)
> def iv_template(varlist,db,table):
> for var in varlist:
> babel_template='''
> #+name: var
> #+begin_src sqlite :db mydb
> SELECT colName,cnt,suc,fal,iv FROM mytable WHERE colName == %s';
> #+end_src # org mode stop here!
> ''' % (var,var)
>
> print babel_template
> #+end_src
Within a source block, you must prepend a comma to every line starting
with "*" or "#+". C-c ' will do that for you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to quote "#+end_src" string in a Babel block?
2013-07-24 5:39 how to quote "#+end_src" string in a Babel block? asenal
2013-07-24 6:11 ` Thorsten Jolitz
2013-07-24 7:24 ` Nicolas Goaziou
@ 2013-07-24 22:32 ` Eric Schulte
2013-08-15 11:38 ` asenal
2 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2013-07-24 22:32 UTC (permalink / raw)
To: asenal; +Cc: emacs-orgmode
asenal <asenalhere@gmail.com> writes:
> Hi Guys I'm trying to do literature programming with org mode.
> My problem is How can I safely quote "#+XXX" inside a Babel-block?
> I found org-mode mismatch the outter "#+begin_src" with the first "#+end_src" inside the block hence gives me a wrong parse.
>
> Here's an example:
> #+headers: :var varlist=top_iv
> #+begin_src python :return iv_template(varlist)
> def iv_template(varlist,db,table):
> for var in varlist:
> babel_template='''
> #+name: var
> #+begin_src sqlite :db mydb
> SELECT colName,cnt,suc,fal,iv FROM mytable WHERE colName == %s';
> #+end_src # org mode stop here!
> ''' % (var,var)
>
> print babel_template
> #+end_src
>
> I know it looks twisted,but what I really care is wheather org-mode
> holds the capability to do so.
>
The following syntax should work. If you edit code blocks with C-' the
leading ' characters will be added and stripped automatically.
#+begin_src python :return iv_template(varlist)
def iv_template(varlist,db,table):
for var in varlist:
babel_template='''
,#+name: var
,#+begin_src sqlite :db mydb
SELECT colName,cnt,suc,fal,iv FROM mytable WHERE colName == %s';
,#+end_src # org mode stop here!
''' % (var,var)
print babel_template
#+end_src
--
Eric Schulte
http://cs.unm.edu/~eschulte
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to quote "#+end_src" string in a Babel block?
2013-07-24 22:32 ` Eric Schulte
@ 2013-08-15 11:38 ` asenal
0 siblings, 0 replies; 5+ messages in thread
From: asenal @ 2013-08-15 11:38 UTC (permalink / raw)
To: Eric Schulte, Nicolas Goaziou; +Cc: emacs-orgmode
Thank for the answers .
I'm glad to know ', ' is the right escaping character to quote '#+babel_statement'.
I apologize for answering so late.
On Jul 25, 2013, at 6:32 AM, Eric Schulte <schulte.eric@gmail.com> wrote:
> asenal <asenalhere@gmail.com> writes:
>
>> Hi Guys I'm trying to do literature programming with org mode.
>> My problem is How can I safely quote "#+XXX" inside a Babel-block?
>> I found org-mode mismatch the outter "#+begin_src" with the first "#+end_src" inside the block hence gives me a wrong parse.
>>
>> Here's an example:
>> #+headers: :var varlist=top_iv
>> #+begin_src python :return iv_template(varlist)
>> def iv_template(varlist,db,table):
>> for var in varlist:
>> babel_template='''
>> #+name: var
>> #+begin_src sqlite :db mydb
>> SELECT colName,cnt,suc,fal,iv FROM mytable WHERE colName == %s';
>> #+end_src # org mode stop here!
>> ''' % (var,var)
>>
>> print babel_template
>> #+end_src
>>
>> I know it looks twisted,but what I really care is wheather org-mode
>> holds the capability to do so.
>>
>
> The following syntax should work. If you edit code blocks with C-' the
> leading ' characters will be added and stripped automatically.
>
> #+begin_src python :return iv_template(varlist)
> def iv_template(varlist,db,table):
> for var in varlist:
> babel_template='''
> ,#+name: var
> ,#+begin_src sqlite :db mydb
> SELECT colName,cnt,suc,fal,iv FROM mytable WHERE colName == %s';
> ,#+end_src # org mode stop here!
> ''' % (var,var)
>
> print babel_template
> #+end_src
>
>
> --
> Eric Schulte
> http://cs.unm.edu/~eschulte
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-15 11:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-24 5:39 how to quote "#+end_src" string in a Babel block? asenal
2013-07-24 6:11 ` Thorsten Jolitz
2013-07-24 7:24 ` Nicolas Goaziou
2013-07-24 22:32 ` Eric Schulte
2013-08-15 11:38 ` asenal
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).