help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs function for writing C++ iterator loop


From: Pascal Bourguignon
Subject: Re: emacs function for writing C++ iterator loop
Date: Fri, 29 Jun 2007 09:31:10 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.1.50 (gnu/linux)

Mohitz <coolmohitz@gmail.com> writes:

>> Hi
>> This is probably a good starting 
>> point:http://www.emacswiki.org/cgi-bin/wiki/SkeletonMode
>> Cheers,
>
> Thank you so much... Got it working :)
>
> I would post the solution in case it benefits someone else..
>
> (define-skeleton generate-iterator-loop
>       "Generate Iterator Loop"
>       ""
>       > (setq v1 (skeleton-read "Iterate on? ")) "<"
>       > (setq v4 (skeleton-read "Class Name? ")) "> "
>       > (setq v2 (skeleton-read "Var Name? ")) " = "
>       > (setq v3 (skeleton-read "Points to? ")) ";" \n
>       > v1 "<" v4 ">::iterator " v2 "Iterate;" \n
>       > v2 "Iterate = " v2 ".begin();" \n
>       > "while (" v2 "Iterate != " v2  ".end())" \n
>       > "{" \n
>       > v4 " temp" v4 ";" \n
>       > "temp" v4 " = *" v2 "Iterate;" \n
>       > "//Do something with temp" v4 \n
>       > v2 "Iterate++;" \n
>       > "}" \n)

The problem with skeletons is that it inserts the results, and you or
your coworkers will edit it, so when the skeleton changes, the
generated parts cannot be updated automatically.

That's why macros (or preprocessors) are better: you edit only the
true source, the macro call or the macro definition, and the code
generated is updated everywhere.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]