emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* how to insert a source template
@ 2011-04-12  1:16 Piter_
  2011-04-12  6:00 ` Jambunathan K
  2011-04-12  7:04 ` Eric Schulte
  0 siblings, 2 replies; 5+ messages in thread
From: Piter_ @ 2011-04-12  1:16 UTC (permalink / raw)
  To: emacs-orgmode

Hi all.
I have no big knowlege of elisp. But I hope some one already done this.
I want to make a key binding which would insert a source code template
like this (I've got tired to type it every time):

#+source:
#+begin_src

#+end_src

Thanks.
Petro.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to insert a source template
  2011-04-12  1:16 how to insert a source template Piter_
@ 2011-04-12  6:00 ` Jambunathan K
  2011-04-12  7:04 ` Eric Schulte
  1 sibling, 0 replies; 5+ messages in thread
From: Jambunathan K @ 2011-04-12  6:00 UTC (permalink / raw)
  To: Piter_; +Cc: emacs-orgmode

Piter_ <x.piter@gmail.com> writes:

> Hi all.
> I have no big knowlege of elisp. But I hope some one already done this.
> I want to make a key binding which would insert a source code template
> like this (I've got tired to type it every time):
>
> #+source:
> #+begin_src
>
> #+end_src

http://orgmode.org/manual/Easy-Templates.html#Easy-Templates
Also look at org-structure-template-alist.

>
> Thanks.
> Petro.
>
>

-- 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to insert a source template
  2011-04-12  1:16 how to insert a source template Piter_
  2011-04-12  6:00 ` Jambunathan K
@ 2011-04-12  7:04 ` Eric Schulte
  2011-04-12  9:45   ` Piter_
  2011-04-12 19:31   ` Matt Lundin
  1 sibling, 2 replies; 5+ messages in thread
From: Eric Schulte @ 2011-04-12  7:04 UTC (permalink / raw)
  To: Piter_; +Cc: emacs-orgmode

Hi Petro,

You can use yasnippet to expand keywords into templates (like code
blocks) with TAB, see the following for instructions on using yasnippet
with Org-mode [1].

Alternately you could add the following elisp code to your config, and
bind the `org-insert-block' function to a comfortable key combination.

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

Cheers -- Eric

Piter_ <x.piter@gmail.com> writes:

> Hi all.
> I have no big knowlege of elisp. But I hope some one already done this.
> I want to make a key binding which would insert a source code template
> like this (I've got tired to type it every time):
>
> #+source:
> #+begin_src
>
> #+end_src
>
> Thanks.
> Petro.
>


Footnotes: 
[1]  http://orgmode.org/worg/org-faq.html#YASnippet

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to insert a source template
  2011-04-12  7:04 ` Eric Schulte
@ 2011-04-12  9:45   ` Piter_
  2011-04-12 19:31   ` Matt Lundin
  1 sibling, 0 replies; 5+ messages in thread
From: Piter_ @ 2011-04-12  9:45 UTC (permalink / raw)
  To: emacs-orgmode

Thanks guys. Exactly what I wanted.
The word template had not came into my mind, thats why my googling was
not sucesseful :(



On Tue, Apr 12, 2011 at 9:04 AM, Eric Schulte <schulte.eric@gmail.com> wrote:
> Hi Petro,
>
> You can use yasnippet to expand keywords into templates (like code
> blocks) with TAB, see the following for instructions on using yasnippet
> with Org-mode [1].
>
> Alternately you could add the following elisp code to your config, and
> bind the `org-insert-block' function to a comfortable key combination.
>
> #+begin_src emacs-lisp
>  (defun org-insert-block (lang)
>    (interactive "Mlanguage: ")
>    (insert (format "#+begin_src %s\n  \n#+end_src" lang))
>    (goto-char (- (point) 10)))
> #+end_src
>
> Cheers -- Eric
>
> Piter_ <x.piter@gmail.com> writes:
>
>> Hi all.
>> I have no big knowlege of elisp. But I hope some one already done this.
>> I want to make a key binding which would insert a source code template
>> like this (I've got tired to type it every time):
>>
>> #+source:
>> #+begin_src
>>
>> #+end_src
>>
>> Thanks.
>> Petro.
>>
>
>
> Footnotes:
> [1]  http://orgmode.org/worg/org-faq.html#YASnippet
>
> --
> Eric Schulte
> http://cs.unm.edu/~eschulte/
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to insert a source template
  2011-04-12  7:04 ` Eric Schulte
  2011-04-12  9:45   ` Piter_
@ 2011-04-12 19:31   ` Matt Lundin
  1 sibling, 0 replies; 5+ messages in thread
From: Matt Lundin @ 2011-04-12 19:31 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Hi Petro,
>
> You can use yasnippet to expand keywords into templates (like code
> blocks) with TAB, see the following for instructions on using yasnippet
> with Org-mode [1].
>
> Alternately you could add the following elisp code to your config, and
> bind the `org-insert-block' function to a comfortable key combination.
>
> #+begin_src emacs-lisp
>   (defun org-insert-block (lang)
>     (interactive "Mlanguage: ")
>     (insert (format "#+begin_src %s\n  \n#+end_src" lang))
>     (goto-char (- (point) 10)))
> #+end_src

There is also a nice FAQ that outlines the various options:

http://orgmode.org/worg/org-faq.html#shortcuts-for-entering-source-blocks

Best,
Matt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-04-12 19:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-12  1:16 how to insert a source template Piter_
2011-04-12  6:00 ` Jambunathan K
2011-04-12  7:04 ` Eric Schulte
2011-04-12  9:45   ` Piter_
2011-04-12 19:31   ` Matt Lundin

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).