sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
From: rsalz@osf.org
To: ejk@ux2.cso.uiuc.edu, sam-fans@hawkwind.utcs.toronto.edu
Subject: Re:  scripts using 3/12 sam command pipe?
Date: Wed, 17 Mar 1993 13:28:23 -0500	[thread overview]
Message-ID: <9303171828.AA06894@earth.osf.org> (raw)

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


             reply	other threads:[~1993-03-17 18:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-03-17 18:28 rsalz [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-03-17 17:59 Ed Kubaitis - CCSO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9303171828.AA06894@earth.osf.org \
    --to=rsalz@osf.org \
    --cc=ejk@ux2.cso.uiuc.edu \
    --cc=sam-fans@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).