home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / editors / 2035 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  3.9 KB

  1. Path: sparky!uunet!sun-barr!sh.wide!wnoc-tyo-news!nec-tyo!nec-gw!mips!swrinde!cs.utexas.edu!torn!cunews!nrcnet0!bnrgate!bcars267!bcarh600!mschee
  2. From: mschee@bcarh600.bnr.ca (Michael SamChee)
  3. Newsgroups: comp.editors
  4. Subject: Solutions to using CTAGS in VI..
  5. Keywords: recursive call, pop, stack
  6. Message-ID: <1992Aug19.223146.12348@bnr.ca>
  7. Date: 19 Aug 92 22:31:46 GMT
  8. Sender: news@bnr.ca (usenet)
  9. Organization: Bell-Northern Research, Ottawa, Canada
  10. Lines: 137
  11. Nntp-Posting-Host: bcarh600
  12.  
  13. Hi there,
  14.  
  15. A few days ago I sent the following news item asking for help on
  16. using CTAGS in VI:
  17.  
  18. > Hi,
  19. > Please, I need some help! using CTAGs in unix:
  20. > If I recursively invoke tags (by typing "CNTRL ]" on each
  21. > identifier I wish to search for), say 3 times, I am unable
  22. > to "pop back" to the file where I *first* invoked tags. 
  23. > When I was on campus, it used to work the way I wanted 
  24. > it to, but now on my job, when I create a tags file and
  25. > invoke it in a nested (recursive) fashion, I'm only able
  26. > to "pop back" to the *previous* file where tags was invoked.
  27. > Also, invoking tags seem to be case sensitive ie. identifier
  28. > "Ct" is not treated the same as "ct". Is there a way to make it
  29. > case insensitive?
  30. > Anybody ever had these experiences, or knows how to
  31. > overcome these problems ?
  32. > Your help will be very much appreciated !
  33. > Thanks,
  34. > Michael.
  35.  
  36.  
  37. Based on email and newsgroup replies, I would like to share
  38. the following solution with you:
  39.  
  40. First of all, it seem to be general concensus that tag stacking 
  41. is only available on newer versions of vi. 
  42.  
  43. Since we don't have access to the source for vi, the following
  44. solution, given by
  45.  
  46.            "s-fujii@sramha.sra.co.jp (Seigo Fujii)"
  47.  
  48. can be used to solve the problem:
  49.  
  50. First,
  51.  
  52. Map a key (say ^Y) to push the file on the stack and invoke tags:
  53.     map ^Y  :1,.w !exec vifs push %^M^M^]
  54.  
  55. Map a key (say ^P) to pop the previous file from the stack:
  56.     map ^P  :!exec vifs pop^M:so ~/tmp/vifs_pop.ex^M^M
  57.  
  58. Create a directory called "tmp" in your home directory,
  59. and put the following perl script program (given at the end
  60. of this news item) in a file and name it "vifs".
  61.  
  62. You can now use ^Y to invoke tags and ^P to pop back
  63. to the *previous* file where tags was invoked.
  64.  
  65. As for the last problem in the original posting, no one was
  66. able to give a solution to making tags case insensitive..
  67.  
  68. Cheers,
  69. Michael.
  70.  
  71.  
  72. --------------start of vifs file--------------------
  73. #!/usr/local/bin/perl
  74. #
  75. # vifs : vi edit-file stack
  76. #usage: vifs [show|push file|pop|clear|clean]
  77. #
  78. $PPID = getppid;
  79. $HOME = $ENV{'HOME'};
  80. $STACKFILEBASE = $HOME . '/tmp/#vifs_stack';
  81. $STACKFILE = $STACKFILEBASE . ".$PPID";
  82. $POPEXFILE = $HOME . '/tmp/vifs_pop.ex';
  83.  
  84. if ($ARGV[0] eq 'push' && $#ARGV == 1) {
  85.     &countline;
  86.     &getstack;
  87.     push(@stack, "$ARGV[1] $line\n");
  88.     &putstack;
  89. } elsif ($ARGV[0] eq 'show' || $#ARGV == -1) {
  90.     &getstack;
  91.     print @stack;
  92. } elsif ($ARGV[0] eq 'pop') {
  93.     &getstack;
  94.     $_ = pop(@stack);
  95.     chop;
  96.     ($file, $line) = split(' ');
  97.     &makepopex;
  98.     &putstack;
  99. } elsif ($ARGV[0] eq 'clear') {
  100.     truncate($STACKFILE, 0);
  101. } elsif ($ARGV[0] eq 'clean') {
  102.     unlink <$STACKFILEBASE.*>, $POPEXFILE;
  103. } else {
  104.     &usage;
  105. }
  106. exit 0;
  107.  
  108. sub usage {
  109.     print STDERR "usage: vifs [show|push file|pop|clear|clean]\n";
  110.     exit 1;
  111. }
  112.  
  113. sub countline {
  114.     while (<STDIN>) {}
  115.     $line = $.;
  116. }
  117.  
  118. sub getstack {
  119.     if (open(STACK, "<$STACKFILE")) {
  120.        @stack = <STACK>;
  121.        close(STACK);
  122.     }
  123. }
  124.  
  125. sub putstack {
  126.     open(STACK, ">$STACKFILE") || die "can not open $STACKFILE\n";
  127.     print STACK @stack;
  128.     close(STACK);
  129. }
  130.  
  131. sub makepopex {
  132.     open(POPEX, ">$POPEXFILE") || die "can not open $POPEXFILE\n";
  133.     if ($file && $line) {
  134.          print POPEX "e +$line $file\n$line\n";
  135.     } else {
  136.          print STDERR "edit-file stack empty\n";
  137.          print POPEX qq/" edit-file stack empty\n/;
  138.     }
  139.     close(POPEX);
  140. }
  141. -----------end of vifs file--------------------
  142.