From: Pascal Bourguignon <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: emacs function for writing C++ iterator loop
Date: Fri, 29 Jun 2007 09:31:10 +0200 [thread overview]
Message-ID: <87ir97tdxd.fsf@informatimago.com> (raw)
In-Reply-To: 1183098937.627370.109140@u2g2000hsc.googlegroups.com
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.
next prev parent reply other threads:[~2007-06-29 7:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-29 0:56 emacs function for writing C++ iterator loop Mohitz
2007-06-29 3:22 ` weber
2007-06-29 6:35 ` Mohitz
2007-06-29 7:31 ` Pascal Bourguignon [this message]
2007-06-29 7:09 ` Pascal Bourguignon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ir97tdxd.fsf@informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.