when I want to process a dot's contents in acme I can use the '>' syntax, e.g.
have
> awk '{print}'
in a window, select it, and then 2-1 click on Edit in the window with
my dot. That works.
But what shall I do when the awk script is more complicated, in the
simplest case like
> awk '
{print}
'
When I select it all and do the same as before, it doesn't work
(probably because of the new lines?)...
Thanks
Ruda
Put the awk code into a file and execute '> awk -f foo' in acme.
well, I hoped this would be the last way... It makes me create files I
don't actually need.
Is it the newlines that causes troubles?
Thanks
Ruda
remember, this is plan9 and everything is a file. chances are your
"script" is already available in some filesystem and you don't need to
write it out:: create a new window inside acme, type your awk script
and then issue ">awk -f /mnt/wsys/X/body" where X is the ID of your
window.
you'll need to figure out what the new window's ID is, but that's not
too difficult, simply middle-click something like this after you've
created the script window:
grep -l foo /mnt/wsys/[0-9]*/body
where 'foo' is some unique part of your script.
well, though an inspiring idea, it doesn't sound to be much practical:
1) I usually have a special window in which I have many commands. I
then select the one needed and chord it to the appropriate window
(i.e. I don't use the whole contents of a window).
2) sometimes I have more such windows.
The very question for me now is: why it behaves how it behaves, i.e
why newlines (if it's them) are problematic.
Ruda
and you want somebody do look through the code and figure it out for you?
They are the only way Edit has to separate commands. You will notice
that you cannot use something like i/A/a/W/ (or i/A/;a/W/, for
example). However, you can chord something like
i/A/
a/W/
When you chord your example, acme calls rc with: rc -c 'awk '', so it
does not work. rc is who interprets those multiple-line commands. You
could use rc functions if that makes you feel better than with plain
files, just remember to prepend the function name with a semi-colon,
to force rc to interpret the command. At least that is how I remember
it, please somebody correct me if I am wrong.
--
- yiyus || JGL .
not really. I wanted to know whether
1) somebody thought about it (knowing the system has been around for
some time I'd expect somebody must have had the same problem)
2) there is any good reason why it behaves so.
Ruda
This is an interesting usage model. I've never seen it before.
The power of acme is that you can extend it with external
programs. The script below implements this usage; I called it Run.
You can type and select your command in one window, with a name matching
pattern, and then in the other window's tag execute >Run pattern.
Run finds the window with a title matching pattern, pulls out the
selected text, and runs it through rc.
See http://swtch.com/~rsc/acme-Run.png for an illustration.
Russ
#!/bin/rc
if(! ~ $#* 1) {
echo 'usage: Run title' >[1=2]
exit usage
}
id=`{awk -v 'pat='$1 '$6 ~ pat {print $1}' /mnt/wsys/index}
if(~ $#id 0) {
echo 'no match for pattern' >[1=2]
exit none
}
if(! ~ $#id 1) {
echo 'ambiguous pattern' >[1=2]
exit ambiguous
}
if(~ `{wc -w /mnt/wsys/$id/rdsel} 0) {
echo 'no command selected' >[1=2]
exit missing
}
exec rc /mnt/wsys/$id/rdsel
Wow, cool. Could you copy this into /acme/bin on sources?
- Dan C.
Thank you much!
This is what I need and now I see how it can be achieved...
:)
Ruda