* Customizing "Easy Templates"? @ 2011-07-07 2:28 Michael Hannon 2011-07-07 5:13 ` suvayu ali 0 siblings, 1 reply; 5+ messages in thread From: Michael Hannon @ 2011-07-07 2:28 UTC (permalink / raw) To: Org-Mode List Greetings. I just came across the "Easy Templates" feature of Org-mode: http://orgmode.org/manual/Easy-Templates.html In particular, using: <s<TAB> to generate: #+begin_src #+end_src is a real time-saver for me. One thing that would improve this feature for me: I like to keep source code in lower case and directives such as BEGIN_SRC in upper case. (This must stem from some ancient convention I used in C at one time.) I can't figure out how to customize the text of these templates. Can anybody point me in the right direction? Thanks, -- Mike ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Customizing "Easy Templates"? 2011-07-07 2:28 Customizing "Easy Templates"? Michael Hannon @ 2011-07-07 5:13 ` suvayu ali 2011-07-07 8:30 ` Eric S Fraga 2011-07-07 15:24 ` Michael Hannon 0 siblings, 2 replies; 5+ messages in thread From: suvayu ali @ 2011-07-07 5:13 UTC (permalink / raw) To: Michael Hannon; +Cc: Org-Mode List Hey Mike, On Thu, Jul 7, 2011 at 4:28 AM, Michael Hannon <jm_hannon@yahoo.com> wrote: > I can't figure out how to > customize the text of these templates. Can anybody point me in the right > direction? > This should work: (add-to-list 'org-structure-template-alist '("S" "#+BEGIN_SRC ?\n\n#+END_SRC" "<src lang=\"?\">\n\n</src>")) -- Suvayu Open source is the future. It sets us free. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Customizing "Easy Templates"? 2011-07-07 5:13 ` suvayu ali @ 2011-07-07 8:30 ` Eric S Fraga 2011-07-07 15:33 ` Michael Hannon 2011-07-07 15:24 ` Michael Hannon 1 sibling, 1 reply; 5+ messages in thread From: Eric S Fraga @ 2011-07-07 8:30 UTC (permalink / raw) To: suvayu ali; +Cc: Michael Hannon, Org-Mode List suvayu ali <fatkasuvayu+linux@gmail.com> writes: > Hey Mike, > > On Thu, Jul 7, 2011 at 4:28 AM, Michael Hannon <jm_hannon@yahoo.com> wrote: >> I can't figure out how to >> customize the text of these templates. Can anybody point me in the right >> direction? >> > > This should work: > > (add-to-list 'org-structure-template-alist > '("S" "#+BEGIN_SRC ?\n\n#+END_SRC" "<src lang=\"?\">\n\n</src>")) Mike, if you intend to customise further than this, you might wish to consider using yasnippets [1] instead of these templates, although these templates are indeed quite useful! I use both but, for instance, for source blocks, I have the following snippet defined: --8<---------------cut here---------------start------------->8--- #name : #+begin_src language options ...#+end_src # -- #+srcname: $1 #+begin_src $2 $3 $0 #+end_src --8<---------------cut here---------------end--------------->8--- so that typing "src TAB" starts defining a source block with subsequent TABs allowing me to fill in the name, the language, the arguments and finally puts me into the actual code section. The nice thing about yasnippets is that you can have defaults for any of the fields. For instance, here is one I use for Java files (not org): --8<---------------cut here---------------start------------->8--- #contributor: dobbymoodge <j...@transloc-inc.com> #name : public? class ... { ... } # -- // Copyright (c) 2011, Eric S Fraga, All rights reserved. package ${1:jacaranda.design}; import jacaranda.base.Settings; ${2:public} class ${3:foo} ${4:extends jacaranda.base.EGO} { public static boolean debug = false; private static final int dl = 5; private static String version = "2011.03.02 20:04:40"; static { Settings.output.printf (": <%s> $3\n", version); } ${5:public} $3 () { $0 } } // end of $3 class // Local Variables: // time-stamp-line-limit: 1000 // time-stamp-format: "%04y-%02m-%02d %02H:%02M:%02S" // time-stamp-active: t // time-stamp-start: "version = \"" // time-stamp-end: "\";" // End: --8<---------------cut here---------------end--------------->8--- for when I start a new class file. Footnotes: [1] http://www.emacswiki.org/emacs/Yasnippet -- : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 : using Org-mode version 7.5 (release_7.5.586.g382e6) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Customizing "Easy Templates"? 2011-07-07 8:30 ` Eric S Fraga @ 2011-07-07 15:33 ` Michael Hannon 0 siblings, 0 replies; 5+ messages in thread From: Michael Hannon @ 2011-07-07 15:33 UTC (permalink / raw) To: Eric S Fraga, suvayu ali; +Cc: Org-Mode List Thanks, Eric. You're not the first person to suggest that I look into yasnippets, and it's on my to-do list. (Using Emacs is a little like being in the Red Queen's race: http://en.wikipedia.org/wiki/Red_Queen%27s_race ;-) -- Mike ----- Original Message ---- > From: Eric S Fraga <e.fraga@ucl.ac.uk> > To: suvayu ali <fatkasuvayu+linux@gmail.com> > Cc: Michael Hannon <jm_hannon@yahoo.com>; Org-Mode List <emacs-orgmode@gnu.org> > Sent: Thu, July 7, 2011 1:30:37 AM > Subject: Re: [O] Customizing "Easy Templates"? > > suvayu ali <fatkasuvayu+linux@gmail.com> writes: > > > Hey Mike, > > > > On Thu, Jul 7, 2011 at 4:28 AM, Michael Hannon <jm_hannon@yahoo.com> wrote: > >> I can't figure out how to > >> customize the text of these templates. Can anybody point me in the right > >> direction? > >> > > > > This should work: > > > > (add-to-list 'org-structure-template-alist > > '("S" "#+BEGIN_SRC ?\n\n#+END_SRC" "<src lang=\"?\">\n\n</src>")) > > Mike, > > if you intend to customise further than this, you might wish to consider > using yasnippets [1] instead of these templates, although these > templates are indeed quite useful! I use both but, for instance, for > source blocks, I have the following snippet defined: > > --8<---------------cut here---------------start------------->8--- > #name : #+begin_src language options ...#+end_src > # -- > #+srcname: $1 > #+begin_src $2 $3 > $0 > #+end_src > --8<---------------cut here---------------end--------------->8--- > > so that typing "src TAB" starts defining a source block with subsequent > TABs allowing me to fill in the name, the language, the arguments and > finally puts me into the actual code section. > > The nice thing about yasnippets is that you can have defaults for any of > the fields. For instance, here is one I use for Java files (not org): > > --8<---------------cut here---------------start------------->8--- > #contributor: dobbymoodge <j...@transloc-inc.com> > #name : public? class ... { ... } > # -- > // Copyright (c) 2011, Eric S Fraga, All rights reserved. > package ${1:jacaranda.design}; > > import jacaranda.base.Settings; > > ${2:public} class ${3:foo} ${4:extends jacaranda.base.EGO} > { > public static boolean debug = false; > private static final int dl = 5; > private static String version = "2011.03.02 20:04:40"; > static { > Settings.output.printf (": <%s> $3\n", version); > } > ${5:public} $3 () { > $0 > } > } // end of $3 class > > // Local Variables: > // time-stamp-line-limit: 1000 > // time-stamp-format: "%04y-%02m-%02d %02H:%02M:%02S" > // time-stamp-active: t > // time-stamp-start: "version = \"" > // time-stamp-end: "\";" > // End: > --8<---------------cut here---------------end--------------->8--- > > for when I start a new class file. > > > Footnotes: > [1] http://www.emacswiki.org/emacs/Yasnippet > > -- > : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 > : using Org-mode version 7.5 (release_7.5.586.g382e6) > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Customizing "Easy Templates"? 2011-07-07 5:13 ` suvayu ali 2011-07-07 8:30 ` Eric S Fraga @ 2011-07-07 15:24 ` Michael Hannon 1 sibling, 0 replies; 5+ messages in thread From: Michael Hannon @ 2011-07-07 15:24 UTC (permalink / raw) To: suvayu ali; +Cc: Org-Mode List Thanks, Suvayu. This works like a charm. -- Mike ----- Original Message ---- > From: suvayu ali <fatkasuvayu+linux@gmail.com> > To: Michael Hannon <jm_hannon@yahoo.com> > Cc: Org-Mode List <emacs-orgmode@gnu.org> > Sent: Wed, July 6, 2011 10:13:55 PM > Subject: Re: [O] Customizing "Easy Templates"? > > Hey Mike, > > On Thu, Jul 7, 2011 at 4:28 AM, Michael Hannon <jm_hannon@yahoo.com> wrote: > > I can't figure out how to > > customize the text of these templates. Can anybody point me in the right > > direction? > > > > This should work: > > (add-to-list 'org-structure-template-alist > '("S" "#+BEGIN_SRC ?\n\n#+END_SRC" "<src lang=\"?\">\n\n</src>")) > > > -- > Suvayu > > Open source is the future. It sets us free. > > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-07-07 15:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-07-07 2:28 Customizing "Easy Templates"? Michael Hannon 2011-07-07 5:13 ` suvayu ali 2011-07-07 8:30 ` Eric S Fraga 2011-07-07 15:33 ` Michael Hannon 2011-07-07 15:24 ` Michael Hannon
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.