9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] finding acme window id from shell script?
@ 2002-04-03 13:45 rog
  2002-04-03 14:16 ` Axel Belinfante
  0 siblings, 1 reply; 5+ messages in thread
From: rog @ 2002-04-03 13:45 UTC (permalink / raw)
  To: 9fans

> Can a shell script (or other program) find out from which acme window
> it was invoked (other than looking for a 'known' filename
> in/mnt/acme/index)?

in the alef version of acme i made a change so that the window id was
set in $acmewin so that shell scripts that wished to could operate on
the window they were executed from.

i did that largely so that i could implement aget and aput commands
which got or put some text into the selection of the current window so
you could do

	aget|fmt|aput

however since the '|' functionality has been implemented that's not so
useful.

one feature i would find useful: an environment variable giving the
filename of the current window (from the tag).  to save valuable space
in tags, it should probably be a single letter, maybe $% ?

cp $% $%.old
Edit ,>diff $% /fd/0



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

* Re: [9fans] finding acme window id from shell script?
  2002-04-03 13:45 [9fans] finding acme window id from shell script? rog
@ 2002-04-03 14:16 ` Axel Belinfante
  0 siblings, 0 replies; 5+ messages in thread
From: Axel Belinfante @ 2002-04-03 14:16 UTC (permalink / raw)
  To: 9fans

That would be nice.
id=`{grep $% /mnt/acme/index | awk '{print $1}'} ,  or so

Axel.


> one feature i would find useful: an environment variable giving the
> filename of the current window (from the tag).  to save valuable space
> in tags, it should probably be a single letter, maybe $% ?
>
> cp $% $%.old
> Edit ,>diff $% /fd/0




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

* Re: [9fans] finding acme window id from shell script?
  2002-04-03 14:58 rog
@ 2002-04-03 15:47 ` Axel Belinfante
  0 siblings, 0 replies; 5+ messages in thread
From: Axel Belinfante @ 2002-04-03 15:47 UTC (permalink / raw)
  To: 9fans

> > id=`{grep $% /mnt/acme/index | awk '{print $1}'} ,  or so
>
> that's not entirely accurate as it's quite possible to have have
> different acme windows with the same tag file, either deliberately
> (via Zerox) or accidentally (by typing).

Agreed. Your $acmewin is better in that respect.
Or e.g. a file /mnt/acme/id , or...

> while we're on the subject of shell scripts for acme, here's a little
> shell script i wrote years ago to show me what changes i'd made to a
> file within acme.
> it's a testament to the resilience of the file-style interface that it
> has remained unchanged (and working) throughout all the changes to
> acme (e.g. alef->C) that have taken place in the meantime. the
> modification date on the script is March 1999.


Nice! (both the script, and the resilience of the file-style interface)

Axel.




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

* Re: [9fans] finding acme window id from shell script?
@ 2002-04-03 14:58 rog
  2002-04-03 15:47 ` Axel Belinfante
  0 siblings, 1 reply; 5+ messages in thread
From: rog @ 2002-04-03 14:58 UTC (permalink / raw)
  To: 9fans

> id=`{grep $% /mnt/acme/index | awk '{print $1}'} ,  or so

that's not entirely accurate as it's quite possible to have have
different acme windows with the same tag file, either deliberately
(via Zerox) or accidentally (by typing).

while we're on the subject of shell scripts for acme, here's a little
shell script i wrote years ago to show me what changes i'd made to a
file within acme.

use like:

	afdiff somefile.c

it's a testament to the resilience of the file-style interface that it
has remained unchanged (and working) throughout all the changes to
acme (e.g. alef->C) that have taken place in the meantime.
the modification date on the script is March 1999.


#!/bin/rc
# afdiff: show differences between the file contents as held in
# acme's internal buffers and the file as actually held in the filesystem.

if (! test -f /mnt/acme/index) {
	echo 'not inside acme' >[1=2];
	exit fail
}
if (! ~ $#* 1 2) {
	echo 'usage: afdiff acmefile [file]' >[1=2]
	exit usage
}
pat=`{echo $1 | sed 's/[.*()[|+]/\\&/g'}
poss=`{awk '{print $1, $6}' < /mnt/acme/index | grep ' .*'^$pat^'$'}
if (! ~ $#poss 2) {
	{
		if (~ $#poss 0) {
			echo no matching acme files
			exit nomatch
		}
		echo 'afdiff: ambiguous name; possible matches are:'
		*=$poss
		while (! ~ $#* 0 1) {echo $2; shift 2}
	} >[1=2]
}
f2=/mnt/acme/^$poss(1)^/body
if (~ $#* 2) f1=$*(2)
if not f1=$poss(2)

exec diff $f1 $f2



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

* [9fans] finding acme window id from shell script?
  2002-03-29  5:23 [9fans] 'euro symbol' special in acme interface? Russ Cox
@ 2002-04-03 13:01 ` Axel Belinfante
  0 siblings, 0 replies; 5+ messages in thread
From: Axel Belinfante @ 2002-04-03 13:01 UTC (permalink / raw)
  To: 9fans

Another question about programming acme from rc:
Can a shell script (or other program) find
out from which acme window it was invoked
(other than looking for a 'known' filename
 in/mnt/acme/index)?

In the manual I only found acme's ID command,
which I cannot use from within the shell script
(or is there a way?), and reading the ctl file,
but I assume that refers to e.g. /mnt/acme/<nr>/ctl
and to read that I already need to know <nr>.
Currently I just look for a 'fixed' filename in
/mnt/acme/index, which works ok; I'm just wondering
whether there is a more 'direct' way.

Thanks,
Axel.



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

end of thread, other threads:[~2002-04-03 15:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-03 13:45 [9fans] finding acme window id from shell script? rog
2002-04-03 14:16 ` Axel Belinfante
  -- strict thread matches above, loose matches on Subject: below --
2002-04-03 14:58 rog
2002-04-03 15:47 ` Axel Belinfante
2002-03-29  5:23 [9fans] 'euro symbol' special in acme interface? Russ Cox
2002-04-03 13:01 ` [9fans] finding acme window id from shell script? Axel Belinfante

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).