* [9fans] Input/output
@ 2009-12-03 17:45 Maurício CA
2009-12-03 18:27 ` Russ Cox
0 siblings, 1 reply; 9+ messages in thread
From: Maurício CA @ 2009-12-03 17:45 UTC (permalink / raw)
To: 9fans
Hi,
I would like to write a script that takes text from standard
input, lets the user edit it with 'sam -d' and then prints it to
standard output.
Do you think that makes sense? After all, 'sam -d' needs standard
input and output in order to edit anything.
Thanks,
Maur�cio
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] Input/output
2009-12-03 17:45 [9fans] Input/output Maurício CA
@ 2009-12-03 18:27 ` Russ Cox
0 siblings, 0 replies; 9+ messages in thread
From: Russ Cox @ 2009-12-03 18:27 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
2009/12/3 Maurício CA <mauricio.antunes@gmail.com>:
> I would like to write a script that takes text from standard
> input, lets the user edit it with 'sam -d' and then prints it to
> standard output.
http://bitbucket.org/rsc/plan9port/src/tip/bin/ssam
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] Input/output
2009-12-05 1:53 ` erik quanstrom
@ 2009-12-05 4:16 ` Jorden Mauro
0 siblings, 0 replies; 9+ messages in thread
From: Jorden Mauro @ 2009-12-05 4:16 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
On Fri, Dec 4, 2009 at 8:53 PM, erik quanstrom <quanstro@quanstro.net> wrote:
> i general that's true, but double clicking at the start of a c block (or any
> other set of matching delimiters) is a notable exception.
Righto, forgot that escape hatch.
>
> which brings us around to acme. i was a devoted sam user for
> many years until the day i switched back to sam after a few days'
> trying acme. the mouseing in sam just felt clunky after that.
>
The chording patch helps.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] Input/output
[not found] <<3aaafc130912041745ub300dc6w498ddedfea62d837@mail.gmail.com>
@ 2009-12-05 1:53 ` erik quanstrom
2009-12-05 4:16 ` Jorden Mauro
0 siblings, 1 reply; 9+ messages in thread
From: erik quanstrom @ 2009-12-05 1:53 UTC (permalink / raw)
To: 9fans
On Fri Dec 4 20:46:19 EST 2009, jrm8005@gmail.com wrote:
> On Fri, Dec 4, 2009 at 1:51 PM, Russ Cox <rsc@swtch.com> wrote:
> > Why not just highlight the section you want to edit
> > and then type commands into the ~~sam~~ window?
> >
>
> You can't select more than a screenful with the mouse, and sometimes
> it easier to use the mouse for large selections than it is to write an
> x/.../ expression.
i general that's true, but double clicking at the start of a c block (or any
other set of matching delimiters) is a notable exception.
which brings us around to acme. i was a devoted sam user for
many years until the day i switched back to sam after a few days'
trying acme. the mouseing in sam just felt clunky after that.
- erik
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] Input/output
2009-12-04 18:51 ` Russ Cox
2009-12-04 22:44 ` Maurício CA
@ 2009-12-05 1:45 ` Jorden Mauro
1 sibling, 0 replies; 9+ messages in thread
From: Jorden Mauro @ 2009-12-05 1:45 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
On Fri, Dec 4, 2009 at 1:51 PM, Russ Cox <rsc@swtch.com> wrote:
> Why not just highlight the section you want to edit
> and then type commands into the ~~sam~~ window?
>
You can't select more than a screenful with the mouse, and sometimes
it easier to use the mouse for large selections than it is to write an
x/.../ expression.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] Input/output
2009-12-04 18:51 ` Russ Cox
@ 2009-12-04 22:44 ` Maurício CA
2009-12-05 1:45 ` Jorden Mauro
1 sibling, 0 replies; 9+ messages in thread
From: Maurício CA @ 2009-12-04 22:44 UTC (permalink / raw)
To: 9fans
>> Thanks, that's exactly what I need. My idea is to use this
>> inside sam itself with '|', so that I can easily edit small
>> parts of big files.
> Why not just highlight the section you want to edit and then
> type commands into the ~~sam~~ window?
Major probable real reason is that I have not yet master the
proper way to do everything.
Second major reason is that I'm happy with 'rc' scripts. I've been
writing them for anything I think of, just to learn it :)
Others:
* Sometimes I want to do a long, complex edit in a section, but
keep all changes in a single undo/redo step for the main document.
* I like the 'x' command, but it changes the selection. If you use
it many times it may be tiresome to select the same section of
text many times. I can't use 'k' to help here, as I think it is
not supposed to keep track of changes in selection size.
* When reviewing many similar, but not small, pieces of text, the
command below is pretty nice ('eec' is my "sub-sam"):
x/cool_regexp/| eec
* If I'm working on a section of a file, big enough not to fit in
the screen, I like to isolate it.
* When you say 'window', you mean that GUI thing? At this time I
use 'sam -d', but some day I may attach a mouse to my computer and
try that :)
Thanks for your comments, or others you may have. Best,
Maur�cio
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] Input/output
2009-12-04 13:13 ` Maurício CA
@ 2009-12-04 18:51 ` Russ Cox
2009-12-04 22:44 ` Maurício CA
2009-12-05 1:45 ` Jorden Mauro
0 siblings, 2 replies; 9+ messages in thread
From: Russ Cox @ 2009-12-04 18:51 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> Thanks, that's exactly what I need. My idea is to use this inside
> sam itself with '|', so that I can easily edit small parts of big
> files.
Why not just highlight the section you want to edit
and then type commands into the ~~sam~~ window?
Russ
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] Input/output
2009-12-03 19:34 ` erik quanstrom
@ 2009-12-04 13:13 ` Maurício CA
2009-12-04 18:51 ` Russ Cox
0 siblings, 1 reply; 9+ messages in thread
From: Maurício CA @ 2009-12-04 13:13 UTC (permalink / raw)
To: 9fans
> i think what you want is a modified ssam that reopens
> the console. the reason for this is to seperate the editing from
> the command stream. something like (for plan 9, run once)
>
> (...)
>
> or for linux (untested)
>
> (...)
Thanks, that's exactly what I need. My idea is to use this inside
sam itself with '|', so that I can easily edit small parts of big
files.
Here is my working version for linux. The only important change is
that I had to replace your use of $tty to a loop that uses 'fuser'
to find the terminal owned by $pid.
Best,
Maur�cio
#!/home/mauricio/plan9/bin/9 rc
file = $HOME ^ '/tmp/eec-' ^ $pid
cat > $file
pts = `{for (i in /dev/pts/*)
achou = `{fuser $i >[2]/dev/null | grep $pid} {
if (test -n $"achou) echo $i}}
#Note: 's' is a script that translates to sam.
s $file <[0]$pts >[1]$pts
cat $file
rm $file
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] Input/output
[not found] <<hf8tg7$hed$1@ger.gmane.org>
@ 2009-12-03 19:34 ` erik quanstrom
2009-12-04 13:13 ` Maurício CA
0 siblings, 1 reply; 9+ messages in thread
From: erik quanstrom @ 2009-12-03 19:34 UTC (permalink / raw)
To: 9fans
On Thu Dec 3 12:49:01 EST 2009, mauricio.antunes@gmail.com wrote:
> I would like to write a script that takes text from standard
> input, lets the user edit it with 'sam -d' and then prints it to
> standard output.
>
> Do you think that makes sense? After all, 'sam -d' needs standard
> input and output in order to edit anything.
i don't think ssam is what you want, since you want interactive
editing. i think what you want is a modified ssam that reopens
the console. the reason for this is to seperate the editing from
the command stream. something like (for plan 9, run once)
#!/bin/rc
tmp=()
fn sighup sigint sigexit{
rm -f $tmp
}
tmp = /tmp/esam.$pid
cat $* > $tmp
tty = /dev/cons
sam -d $tmp <>[0]$tty >[1=0]
cat $tmp
exit ''
or for linux (untested)
#!/bin/rc
tmp=()
fn sighup sigint sigexit{
rm -f $tmp
}
if(~ $#TMPDIR 0)
TMPDIR=/tmp
tmp=$TMPDIR/ssam.tmp.$USER.$pid
cat $* >$tmp
tty = `{tty}
sam -d $tmp <>[0]$tty >[1=0]
cat $tmp
- erik
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-12-05 4:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-03 17:45 [9fans] Input/output Maurício CA
2009-12-03 18:27 ` Russ Cox
[not found] <<hf8tg7$hed$1@ger.gmane.org>
2009-12-03 19:34 ` erik quanstrom
2009-12-04 13:13 ` Maurício CA
2009-12-04 18:51 ` Russ Cox
2009-12-04 22:44 ` Maurício CA
2009-12-05 1:45 ` Jorden Mauro
[not found] <<3aaafc130912041745ub300dc6w498ddedfea62d837@mail.gmail.com>
2009-12-05 1:53 ` erik quanstrom
2009-12-05 4:16 ` Jorden Mauro
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).