sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
From: Ed Kubaitis - CCSO <ejk@ux2.cso.uiuc.edu>
To: sam-fans@hawkwind.utcs.toronto.edu
Subject: scripts using 3/12 sam command pipe?
Date: Wed, 17 Mar 1993 12:59:12 -0500	[thread overview]
Message-ID: <199303171759.AA13269@ux2.cso.uiuc.edu> (raw)

Here's a pretty obvious one. Anyone else have one to share?

Ed
===============================================================================
#! /usr/local/bin/perl
#
#   samtag - generate Sam commands from ctags(1) tags file
#
#   usage: !samtag tag     -OR-    (select-tag-with-mouse)
#                                  >samtag

$user = $ENV{'USER'};
$user = $ENV{'LOGNAME'} unless $user;
$user || die "samtag: no USER or LOGNAME environment variable.\n";

$pipe = ".sam.$user";
$pipe .= ".$ENV{'DISPLAY'}" if $ENV{'DISPLAY'};

$Pipe = "/tmp/$pipe";
$Pipe = "/usr/tmp/$pipe" unless -p $Pipe;
-p $Pipe || die "samtag: no sam pipe($pipe) in /tmp or /usr/tmp\n";

$Tag = shift;
$Tag = <STDIN> unless $Tag;
die "samtag: no tag specified." unless $Tag;

open(Tags, "tags") || die "samtag: tags: $!\n";
while(<Tags>) {
   /^([^\t]+)\t([^\t]+)\t(.+)$/;
   $tag = $1; $file =$2; $re =$3;
   last if $tag eq $Tag
   }
die "samtag: tag <$Tag> not found.\n" unless $tag eq $Tag;
$re =~ s/([()*[\]])/\\$1/g; # escape metacharacters in re

open(Pipe, ">$Pipe") || die "samtag: $Pipe: $!\n";
print Pipe "B $file\n$re\n";
close(Pipe);


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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-03-17 17:59 Ed Kubaitis - CCSO [this message]
1993-03-17 18:28 rsalz

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=199303171759.AA13269@ux2.cso.uiuc.edu \
    --to=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).