From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from postman.osf.org ([130.105.1.152]) by hawkwind.utcs.toronto.edu with SMTP id <2664>; Wed, 17 Mar 1993 13:28:40 -0500 Received: from earth.osf.org by postman.osf.org (5.64+/OSF 1.0) id AA06028; Wed, 17 Mar 93 13:28:25 -0500 Received: by earth.osf.org (5.65/4.7) id AA06894; Wed, 17 Mar 93 13:28:23 -0500 Date: Wed, 17 Mar 1993 13:28:23 -0500 From: rsalz@osf.org Message-Id: <9303171828.AA06894@earth.osf.org> To: ejk@ux2.cso.uiuc.edu, sam-fans@hawkwind.utcs.toronto.edu Subject: Re: scripts using 3/12 sam command pipe? I had a test copy of Boyd's stuff and have been using this for a while. Similar but written in rc (uses look and sed). You'll have to edit the "sp=" line ... It is probably just that I haven't been able to really wrap my mind around structural R.E.'s all that much, but find that I am not using them all that much. I use the multi-file aspect all the time; it is my primary reason for using sam. As a result, I am often writing little shell snippets like this: for (i in stderr stdout nolog console) { echo 'X/./ ,g/svc_c_' ^ $i ^ '/ {' echo ',x/svc_c_' ^ $i ^ '/ x/svc_c_/ a/route_/' echo '}' } >>$h/.sam.rsalz Actually, I often write those snippets in an "unnamed" window, select them, and then do ">rc >$sp" where sp is an envvar naming the sam pipe. /r$ #! /bin/rc ## Output a series of commands that will make same go to the tag named on ## the command line. If no argument, use the word in the current X ## selection. The best way to get the selection is to install xcb; available ## as contrib/xcb-2.1.tar.Z on export.lcs.mit.edu. ## Useful variables ~ $#tagspath 0 && tagspath = (. .. /usr/lib/tags) nl = ' ' tab=' ' cat=() ## Print usage message and exit. fn usage { echo Usage: $0 '[-o] [-i | tag]' >[1=2] exit 1 } ## Parse flags. while ( ! ~ $#* 0 ) { switch ( $1 ) { case -i ! ~ $#function 0 && usage function = `` ($nl) {sed 1q} case -o cat=cat case -* usage case * ! ~ $#function 0 && usage function = $1 } shift } ## Sending to sam? ~ $#cat 0 && { ~ $#sp 0 && { sp=$home/.sam.$USER ! ~ $#DISPLAY 0 && sp=$sp.$DISPLAY } test -r $sp || { echo 'No sam fifo' >[1=2] usage } cat='cat >$sp' } ## Get the current X selection. ~ $#function 0 && function = `{xcb -p 0} function = $function ^ $tab for (dir in $tagspath) test -f $dir ^ /tags && { line = `` ($nl) { look $function $dir ^ /tags ; echo $status } ~ $#line 2 && ~ $line(2) 0 && { { * = `` ($tab $nl) { echo $line(1) } if ( ~ $dir . || ~ $2 /* ) { echo B $2 ^ $nl ^ b $2 } else { echo B $dir ^ '/' ^ $2 ^ $nl ^ b $dir ^ '/' ^ $2 } shift ; shift { echo -n $1 while (shift && ! ~ $#* 0) echo -n $tab ^ $1 echo } | sed -e 's/\[/\\[/g' \ -e 's/[].+?|()*$^]/\\&/g' \ -e 's/\/\\\^/\/\^/' \ -e 's/\\\$\/$/\$\//' \ -e 's/ / +/g' } | eval $cat exit 0 } } exit 1