emacs-devel
[Top][All Lists]
Advanced

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

Re: skeleton.el _ versus @


From: Joe Kelsey
Subject: Re: skeleton.el _ versus @
Date: 30 Mar 2003 10:51:56 -0800

Since noone has responded to my e-mail, do I assume that there is no
opposition to fixing the _ versus @ thing in skeleton?  mmm-mode needs
this fix.

/Joe

On Mon, 2003-03-24 at 17:00, Joe Kelsey wrote:
> On Mon, 2003-03-24 at 12:05, Stefan Monnier wrote:
> > > My contention is that the use of @ as a backup to _ in setting
> > > skeleton-point is incorrect.  When a skeleton contains both @ and _
> > > markers, obviously the _ should be used to set the skeleton-point and
> > > the @ should be used to set skeleton-positions when the skeleton is used
> > > in simple insertion mode.
> > 
> > The current code allows the following trick:
> > 
> >     "fun f (" @ ")" \n "{" \n _ \n "}"
> 
> The actual skeleton you wanted is
> 
> (nil "fun f (" @ ")" \n "{" \n _ \n "}")
> 
> You did not include the INTERACTOR.
> 
> > such that selecting a region and calling the skeleton will
> > put the region in the body of the function (because of the _)
> > and point will be put at the right place for you to enter the
> > arglist (because of the @).
> 
> This is using skeletons in "region" mode.  I am not changing region
> mode, or at least I can modify the @ behavior so that it works in region
> mode this way.
> 
> > Your suggestion would break such usage.
> > Could you describe concrete cases where your suggestion would
> > be helpful ?
> 
> mmm-mode uses skeletons to insert multi-mode regions.  A multi-mode
> region is, for example, a section of Javascript embedded in an .html
> page.  mmm-mode allows dynamic switching between html-mode and c++-mode
> depending on the position of the point.
> 
> A multi-mode region is defined by a front-tag, the body and a back-tag. 
> Therefore skeletons look like
> 
> (nil  "<script language=\"JavaScript\">" @ "\n" _ "\n" @ "</script>" @)
> 
> where the @'s mark the front-tag and back-tag begin and end points and
> the _ marks the position of the point after insertion so that you can
> begin editing there.
> 
> However, I can imagine using an mmm-mode skeleton in region mode where I
> want to wrap the front-tag and back-tag around some existing text.  In
> that case, *I* want the point to end up at the beginning of the region,
> i.e., at the _ and *not* at the @.  This is clearly a case of
> conflicting goals.
> 
> A better skeleton for your purposes would be one which prompted the user
> for each of the function arguments using the recursive prompting mode of
> skeleton input.  Consider this skeleton:
> 
> ("function name: " "fun " str " (" (read-string "first argument: ")
> ( "next argument: " ","  \n > str) resume: ")" \n "{" \n _ \n "}")
> 
> It prompts for the funstion name, then reads the first argument, then
> enters a subskeleton prompting for each successive argument.  When you
> type ^G to the subskeleton, it proceeds to resume:, finishing the
> argument list and the function wrapper.  Of course, some work is left to
> be done to get the indentation right...
> 
> My transformation of your skeleton removes the need for @ to substitute
> for _.
> 
> I think that maybe skeleton.el could do with some examples.  There are a
> lot of complex examples in progmodes/sh-script.el for people to look at.
> 
> /Joe
> 
> 





reply via email to

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