Re: skeleton improvement

Zajcev Evgeny <[email protected]> Thu, 24 Feb 2005 16:38:16 +0300
Newsgroups gmane.emacs.xemacs.design
Message-ID <[email protected]>
Pierre Courtieu <[email protected]> writes:

> On 24 f=E9v 2005, Pierre Courtieu wrote:
>
>> > It will insert:
>> >=20
>> >         if ( [0] ) {
>> >                 [1]
>> >         } else {
>> >                 [2]
>> >         }
>> >=20
>> > And write to minibuffer - 'Marks set: 3, use C-u C-SPC to jump next.=
'
>> > Hope this is what you are looking for.
>>=20
>> 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 th=
is
> 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" a=
t
> 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!

--=20
lg