Re: [O] Programmatically insert source-blocks

2013-03-25 Thread Bastien
Hi Thorsten and Eric,

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

 I don't see that Org-mode itself will ever want to programatically and
 non-interactively insert a code block in an Org-mode file (if fact that
 sounds rather dangerous to me), so I would vote against adding such a
 function to the core.

FWIW +1 here too.

-- 
 Bastien



Re: [O] Programmatically insert source-blocks

2013-03-23 Thread Eric Schulte
 So here is my FEATURE REQUEST:

 either modify `org-babel-demarcate-block' so that it can be used to
 insert a language-specific code-block (with args?) non-interactively, or
 add something like `org-insert-block' to Org-mode's core. I would prefer
 signature

 ,--
 | (defun org-insert-block (lang rest args)...)
 `--

 to be able to specify the src-block headline exactly in a program that
 uses this function.

This function may be easily written outside of Org-mode by anyone who
needs it.

I don't see that Org-mode itself will ever want to programatically and
non-interactively insert a code block in an Org-mode file (if fact that
sounds rather dangerous to me), so I would vote against adding such a
function to the core.

-- 
Eric Schulte
http://cs.unm.edu/~eschulte



[O] Programmatically insert source-blocks

2013-03-20 Thread Thorsten Jolitz

Hi List, 

it probably a command everybody knows, but I looked for it several times
and just missed it: 'insert a source-block'. 

I know about Chap. 15.2. of the manual (Easy Templates), thats not what
I mean. To reformulate my question:

Why doesn't (the most relevant function I have found) 

,--
| (org-babel-demarcate-block optional ARG)
`--

have a few more optional arguments, e.g. like this

,--
| (org-babel-demarcate-block optional LANG ARG rest args)
`--

so that it can be called (e.g.) like this

,--
| (org-babel-demarcate-block optional emacs-lisp nil :results output)
`--

without asking the user for input (inserting a new src-block around
point or region)? 

There are so many functions that deal with source-blocks, but the most
basic one - insert a new src-block for language xyz with args u v w - is
not there. At least not for non-interactive use. At least I did not find
it ;)

-- 
cheers,
Thorsten





Re: [O] Programmatically insert source-blocks

2013-03-20 Thread Christian Moe

Hi, Thorsten,

Here's one way, and pointers to more:
http://lists.gnu.org/archive/html/emacs-orgmode/2011-04/msg00406.html

Yours,
Christian

Thorsten Jolitz writes:

 Hi List, 

 it probably a command everybody knows, but I looked for it several times
 and just missed it: 'insert a source-block'. 

 I know about Chap. 15.2. of the manual (Easy Templates), thats not what
 I mean. To reformulate my question:

 Why doesn't (the most relevant function I have found) 

 ,--
 | (org-babel-demarcate-block optional ARG)
 `--

 have a few more optional arguments, e.g. like this

 ,--
 | (org-babel-demarcate-block optional LANG ARG rest args)
 `--

 so that it can be called (e.g.) like this

 ,--
 | (org-babel-demarcate-block optional emacs-lisp nil :results output)
 `--

 without asking the user for input (inserting a new src-block around
 point or region)? 

 There are so many functions that deal with source-blocks, but the most
 basic one - insert a new src-block for language xyz with args u v w - is
 not there. At least not for non-interactive use. At least I did not find
 it ;)




Re: [O] Programmatically insert source-blocks

2013-03-20 Thread Thorsten Jolitz
Christian Moe m...@christianmoe.com writes:

Hi Christian, 

 Here's one way, and pointers to more:
 http://lists.gnu.org/archive/html/emacs-orgmode/2011-04/msg00406.html

thanks for the links. 

I mean, it is not t difficult to write a function like 

,--
| (defun org-insert-block (lang)
|(interactive Mlanguage: )
|(insert (format #+begin_src %s\n  \n#+end_src lang))
|(goto-char (- (point) 10)))
`--

or to write insert statements like 

,---
| (insert (format #+begin_src %s\n  \n#+end_src lang))
`---

in a program - but I find it strange that this is not part of core
Org-mode functionality. There are dozens of functions that deal with
existing code-blocks, but none (non-interactive) that creates/inserts
a code-block.

So here is my FEATURE REQUEST:

either modify `org-babel-demarcate-block' so that it can be used to
insert a language-specific code-block (with args?) non-interactively, or
add something like `org-insert-block' to Org-mode's core. I would prefer
signature

,--
| (defun org-insert-block (lang rest args)...)
`--

to be able to specify the src-block headline exactly in a program that
uses this function.

-- 
cheers,
Thorsten