[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[h-e-w] Template creation
From: |
Wojciech Komornicki |
Subject: |
[h-e-w] Template creation |
Date: |
Fri, 15 Feb 2002 08:37:25 -0600 |
Take a look at the tempo package. It allows you to create templates
with prompts for variable inputs. As an example, load tempo.elc and
then evaluate the code
(tempo-define-template "cif"
'(> "if (" (P "if-clause: " clause) ") {" n>
> r n
"}" > n>
)
"if"
"Insert a C if statement"
'c-tempo-tags)
Finally run the function
tempo-template-cif
I use templates like this bound to various keys to insert code template,
especially in teaching beginning level programming classes.
--
Wojciech Komornicki Dept of Mathematics
address@hidden Hamline University
http://www.hamline.edu/~wnk/ St Paul, MN 55104
USA
The skill of writing is to create a context in which other people can think.
Edwin Schlossberg
>>>>> "Rajesh" == Rajesh J Advani <address@hidden> writes:
Rajesh> Hi,
Rajesh> I'm using Emacs 21.1 (precompiled version), on Win2k, and I know no
Rajesh> Lisp/Elisp.
Rajesh> I regularly have this need to insert certain code (say comments)
Rajesh> following a given template, repeatedly in to my sourcecode, where
only a
Rajesh> couple of words in that template change.
Rajesh> eg -
Rajesh> Template -
Rajesh> -----------------------------------------------------------------
Rajesh> <SETVALUE BEAN="B2RResourceLoader.Property" VALUE="<The variable text
Rajesh> goes here>">
Rajesh> <VALUEOF BEAN="B2RResourceLoader.PropertyValue"/>
Rajesh> -----------------------------------------------------------------
Rajesh> So this would be repeated as
Rajesh> <SETVALUE BEAN="B2RResourceLoader.Property" VALUE="Value1">
Rajesh> <VALUEOF BEAN="B2RResourceLoader.PropertyValue"/>
Rajesh> <SETVALUE BEAN="B2RResourceLoader.Property" VALUE="Value2">
Rajesh> <VALUEOF BEAN="B2RResourceLoader.PropertyValue"/>
Rajesh> <SETVALUE BEAN="B2RResourceLoader.Property" VALUE="Value3">
Rajesh> <VALUEOF BEAN="B2RResourceLoader.PropertyValue"/>
Rajesh> etc, in my code.
Rajesh> Is there some lisp available to automate this? I want it so that all I
Rajesh> need is a key-stroke or two to insert the template into my buffer, and
Rajesh> then it prompts me for the text for the different variable fields.
Rajesh> I've seen functionality like this in JDE, and XAE modes.
Rajesh> I'm not averse to writing a bit of lisp if required. But I'd prefer
Rajesh> simple code reuse ;)
Rajesh> --
Rajesh> Rajesh J Advani
Rajesh> -----------------------------------
Rajesh> The fact that no one understands
Rajesh> you doesn't mean you're an artist.
Rajesh>
**************************Disclaimer************************************
Rajesh> Information contained in this E-MAIL being proprietary to Wipro
Limited
Rajesh> is 'privileged' and 'confidential' and intended for use only by the
Rajesh> individual or entity to which it is addressed. You are notified that
any
Rajesh> use, copying or dissemination of the information contained in the
E-MAIL
Rajesh> in any manner whatsoever is strictly prohibited.
Rajesh> ********************************************************************