sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
* Re: the obvious. =)
@ 2000-03-25 23:47 kim kubik
  2000-03-26  1:51 ` James A. Robinson
  0 siblings, 1 reply; 6+ messages in thread
From: kim kubik @ 2000-03-25 23:47 UTC (permalink / raw)
  To: jim.robinson, sam Fans


-----Original Message-----
From: James A. Robinson <jim.robinson@stanford.edu>
To: sam Fans <sam-fans@hawkwind.utcs.toronto.edu>
Date: Friday, March 24, 2000 10:26 PM
Subject: the obvious. =)


>I just have to shout to the world (well, to sam fans) that this editor
>is wonderful>I'm finally ready I can just write
>
>,x/^\/\*(.+\n)+ \*\/\n/ t /}\n/
>
>To copy the top comment down to the second method. e.g.
>

Jim (or anyone): 

this just ran up against my (mis)understanding of 
sam's regexp's. I'm sure when first using sam I did
something similar to your example above and the
'greedy' little bastard (.+\n)+ would (to my way
of thinking) eat the whole file, that is, never see
the closing */ of the commment because the .+ should
just keep on going.

But I tried what you have and it works, so obviously
all this time the way I've been getting around this,
using addresses, e.g.

,x/re/{
.,/re2/do stuff
}

isn't necessary.

So what am I missing?

- kim

PS: in your example there's a space after the 
    second + that shouldn't be there, right?
    At least by your example, but probably you
    do comments as:

/*
 * so there really is a space
 * before the last splat.
 *
 */

And the example left this out.





^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: the obvious. =)
@ 2000-03-27 14:37 rob pike
  0 siblings, 0 replies; 6+ messages in thread
From: rob pike @ 2000-03-27 14:37 UTC (permalink / raw)
  To: sam-fans

	,x/^\/\*(.+\n)+ \*\/\n/ t /}\n/

Regular expressions have their limitations, which is why Sam
also has addresses. These provide a simpler and safer way to
match multi-line things like comments:

	,x/^\/\*/ .,/\*\/\n/ t /}\n/

This one works even if there are no blank lines.
Here's a troff paragraph-at-a-time pattern:

	,x/^\.PP/ .,/^\.(PP|SH)/-     ...

Also if there's a slash in the pattern, you can use another character
as the delimiter and save a backslash, as in this example for C++ //
comments:

	x/\/\//  goes to x;//;

Have fun.

-rob



^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <chaotrope@jps.net>]
* the obvious. =)
@ 2000-03-24 21:25 James A. Robinson
  0 siblings, 0 replies; 6+ messages in thread
From: James A. Robinson @ 2000-03-24 21:25 UTC (permalink / raw)
  To: sam Fans

I just have to shout to the world (well, to sam fans) that this editor
is wonderful! Now that I'm actually working directly in sam instead of
just using it via a pipe (from wily), I'm amazed at how much easier it
is to do stuff.

One of the things I tend to do in Java is write a method with name X
that takes no args, X(), or takes N args, X(N). X() tends to just pass
some sort of defaults on to X(N).

When writing JavaDoc comments for each method, it's a major pain
a lot of it tends to be a straight copy and paste one to the
other

Now, with sam, I can just write the top java doc comment, and when
I'm finally ready I can just write

,x/^\/\*(.+\n)+ \*\/\n/ t /}\n/

To copy the top comment down to the second method. e.g.

	/**
	 * 1-5 lines describing Foo
	 */
	public void X()
	{
		...
	}
	public void X(N)
	{
		...
	}

turns into

	/**
	 * 1-5 lines describing Foo
	 */
	public void X()
	{
		...
	}
	/**
	 * 1-5 lines describing Foo
	 */
	public void X(N)
	{
		...
	}

sam's slogan ought to be 'Making your life easier through
structured regular expressions.' =)

Jim


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-03-27 20:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-25 23:47 the obvious. =) kim kubik
2000-03-26  1:51 ` James A. Robinson
  -- strict thread matches above, loose matches on Subject: below --
2000-03-27 14:37 rob pike
     [not found] <chaotrope@jps.net>
2000-03-26 20:54 ` kim kubik
2000-03-27  3:35   ` James A. Robinson
2000-03-24 21:25 James A. Robinson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).