* Programmatically insert source-blocks
@ 2013-03-20 19:36 Thorsten Jolitz
2013-03-20 20:43 ` Christian Moe
0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Jolitz @ 2013-03-20 19:36 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Programmatically insert source-blocks
2013-03-20 19:36 Programmatically insert source-blocks Thorsten Jolitz
@ 2013-03-20 20:43 ` Christian Moe
2013-03-20 22:03 ` Thorsten Jolitz
0 siblings, 1 reply; 5+ messages in thread
From: Christian Moe @ 2013-03-20 20:43 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: emacs-orgmode
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 ;)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Programmatically insert source-blocks
2013-03-20 20:43 ` Christian Moe
@ 2013-03-20 22:03 ` Thorsten Jolitz
2013-03-23 22:35 ` Eric Schulte
0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Jolitz @ 2013-03-20 22:03 UTC (permalink / raw)
To: emacs-orgmode
Christian Moe <mail@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 toooo 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Programmatically insert source-blocks
2013-03-20 22:03 ` Thorsten Jolitz
@ 2013-03-23 22:35 ` Eric Schulte
2013-03-25 5:54 ` Bastien
0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2013-03-23 22:35 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: emacs-orgmode
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Programmatically insert source-blocks
2013-03-23 22:35 ` Eric Schulte
@ 2013-03-25 5:54 ` Bastien
0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2013-03-25 5:54 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode, Thorsten Jolitz
Hi Thorsten and Eric,
Eric Schulte <schulte.eric@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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-25 6:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-20 19:36 Programmatically insert source-blocks Thorsten Jolitz
2013-03-20 20:43 ` Christian Moe
2013-03-20 22:03 ` Thorsten Jolitz
2013-03-23 22:35 ` Eric Schulte
2013-03-25 5:54 ` Bastien
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).