Re: [O] How to set a default language for source blocks?
Rasmus: Thanks Jorge: Yes probably On Tue, Feb 17, 2015 at 2:09 PM, Jorge A. Alfaro-Murillo wrote: > Hi, Grant. > > Grant Rettke writes: > >> It would be simpler to say "this whole document will be R source blocks, >> unless I specify other wise". I looked at [the spec]. I wanted to obtain >> this behavior. I couldn't figure out how. Is it possible? > > > The problem is that if there is nothing after #+BEGIN_SRC, then > org-babel-get-src-block-info returns nil. Probably you would have to modify > org-babel-get-src-block-info so that it returns a default when there is > nothing after #+BEGIN_SRC. But isn't it easier to set > org-structure-template-alist as a local buffer variable, say in the first > line of your file something like: > > #+BEGIN_EXAMPLE > # -*- org-structure-template-alist: '(("s" "#+BEGIN_SRC > python\n?\n#+END_SRC")) -*- > #+END_EXAMPLE > > Then example. > > Best, > > -- > Jorge. > > -- Grant Rettke g...@wisdomandwonder.com | http://www.wisdomandwonder.com/ “Wisdom begins in wonder.” --Socrates ((λ (x) (x x)) (λ (x) (x x))) “Life has become immeasurably better since I have been forced to stop taking it seriously.” --Thompson
Re: [O] How to set a default language for source blocks?
Hi, Grant. Grant Rettke writes: It would be simpler to say "this whole document will be R source blocks, unless I specify other wise". I looked at [the spec]. I wanted to obtain this behavior. I couldn't figure out how. Is it possible? The problem is that if there is nothing after #+BEGIN_SRC, then org-babel-get-src-block-info returns nil. Probably you would have to modify org-babel-get-src-block-info so that it returns a default when there is nothing after #+BEGIN_SRC. But isn't it easier to set org-structure-template-alist as a local buffer variable, say in the first line of your file something like: #+BEGIN_EXAMPLE # -*- org-structure-template-alist: '(("s" "#+BEGIN_SRC python\n?\n#+END_SRC")) -*- #+END_EXAMPLE Then file, for example. Best, -- Jorge.
Re: [O] How to set a default language for source blocks?
Grant Rettke writes: > Just read [this] question. It is interesting. We always want to optimize > our documents. Re-use reduces errors. Defining `:header-args:foo: > :session *bar*' is a great example. Rather than having to type it 100 > times all over, just do it once. It never occurred to be that we might > want to default the language for a source block. It should have. It > would be simpler to say "this whole document will be R source blocks, > unless I specify other wise". I looked at [the spec]. I wanted to obtain > this behavior. I couldn't figure out how. Is it possible? I didn't look > at the parser, is that the right place to look to answer questions like > this? You don't have to check the implementation, you can simply check the Org syntax¹. Blocks Like greater blocks, pattern for blocks is: #+BEGIN_NAME DATA CONTENTS #+END_NAME NAME cannot contain any whitespace character. [...] If it is “SRC”, it will be a “source block” [...] DATA can contain any character but a new line. It can be ommitted, unless the block is a “source block”. In this case, it must follow the pattern “LANGUAGE SWITCHES ARGUMENTS”, where SWITCHES and ARGUMENTS are optional. —Rasmus Footnotes: ¹ http://orgmode.org/worg/dev/org-syntax.html -- The right to be left alone is a human right
[O] How to set a default language for source blocks?
Good afternoon, Just read [this] question. It is interesting. We always want to optimize our documents. Re-use reduces errors. Defining `:header-args:foo: :session *bar*' is a great example. Rather than having to type it 100 times all over, just do it once. It never occurred to be that we might want to default the language for a source block. It should have. It would be simpler to say "this whole document will be R source blocks, unless I specify other wise". I looked at [the spec]. I wanted to obtain this behavior. I couldn't figure out how. Is it possible? I didn't look at the parser, is that the right place to look to answer questions like this? [this] https://emacs.stackexchange.com/questions/8314/set-default-language-for-code-blocks-in-orgmode/9316#9316 [the spec] http://orgmode.org/manual/Structure-of-code-blocks.html#Structure-of-code-blocks -- Grant Rettke g...@wisdomandwonder.com | http://www.wisdomandwonder.com/ “Wisdom begins in wonder.” --Socrates ((λ (x) (x x)) (λ (x) (x x))) “Life has become immeasurably better since I have been forced to stop taking it seriously.” --Thompson