Pierre Courtieu <Pierre.Courtieu(a)univ-orleans.fr> writes:
On 24 fИv 2005, Pierre Courtieu wrote:
> > It will insert:
> >
> > if ( [0] ) {
> > [1]
> > } else {
> > [2]
> > }
> >
> > And write to minibuffer - 'Marks set: 3, use C-u C-SPC to jump next.'
> > Hope this is what you are looking for.
>
> This is exactly what I was looking for. Thanks a lot!
Well, after looking at it, specially to this kind of definition:
(defvar mc-if-skel
'(nil
> "if (" _ ") {" \n
> '(progn (mc-push-mark) nil) \n
> "}" '(progn (indent-according-to-mode) nil) \n
> '(progn (mc-push-mark) nil)
nil)
"*Skeleton for if statement")
I still think that adding the '@' as a special marker telling "store this
position into skeleton-position" is a good idea. For example the above
statement becomes.:
(defvar mc-if-skel
'(nil
> "if (" _ ") {" \n > @ \n > "}" '(progn
(indent-according-to-mode) nil) \n > @
nil)
"*Skeleton for if statement")
Then you can use add a hook skeleton-end-hook to store those positions in
mark-stack if you want (I plan to make another hook building a "hole" at
each position).
Definitely! Tottally agree that skeleton must have builtin support
for saving interesting points. However mcskels just shows how to
workarond when skeleton have no such support.
Moreover why do you need indent-according-to-mode? replacing it by >
wouldn't be the same?
For some reason > won't work for indenting empty lines, it might be a
xemacs specific issue - or might be skeleton bug/feature. So
inserting skeleton like this:
'(nil
"if (" _ ") {" \n > @ \n > "}" \n
> @
nil)
I'm having something like:
if ( [0] ) {
[1]
}
[2]
i.e. [1] is placed incorectly. I have not actually looked deeply why
this happening. If you will find something regarding this issue -
please let me know.
Thanks!
--
lg