From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <14ec7b180906080958l71642089k6fbe672fd18c9771@mail.gmail.com> Date: Mon, 8 Jun 2009 11:15:44 -0700 Message-ID: Subject: Re: [9fans] acme: send dot to the stdin of a more complicated command From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 06afd4f6-ead5-11e9-9d60-3106f5b1d025 > 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. 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