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

  1. Path: sparky!uunet!pipex!warwick!str-ccsun!strath-cs!memex!hq!stephen
  2. From: stephen@memex.co.uk (Stephen Marley)
  3. Newsgroups: comp.editors
  4. Subject: Bug in vi? CTAGS
  5. Summary: Problem with buffered command execution
  6. Keywords: ctags macros vi bug
  7. Message-ID: <stephen.714737742@hq>
  8. Date: 25 Aug 92 10:15:42 GMT
  9. Distribution: comp.editors
  10. Organization: Memex Information Systems Ltd., East Kilbride, Scotland
  11. Lines: 105
  12.  
  13.  
  14. I have a problem using named buffers in vi (SunOs 4.11), perhaps someone 
  15. can shed some light on this. First I'll tell you the circumstances which led 
  16. me to find this problem ...
  17.  
  18. A short while ago, Michael Samchee submitted the following news article...
  19.  
  20. > Hi,
  21. > Please, I need some help! using CTAGs in unix:
  22. > If I recursively invoke tags (by typing "CNTRL ]" on each
  23. > identifier I wish to search for), say 3 times, I am unable
  24. > to "pop back" to the file where I *first* invoked tags. 
  25. > When I was on campus, it used to work the way I wanted 
  26. > it to, but now on my job, when I create a tags file and
  27. > invoke it in a nested (recursive) fashion, I'm only able
  28. > to "pop back" to the *previous* file where tags was invoked.
  29. > Also, invoking tags seem to be case sensitive ie. identifier
  30. > "Ct" is not treated the same as "ct". Is there a way to make it
  31. > case insensitive?
  32. > Anybody ever had these experiences, or knows how to
  33. > overcome these problems ?
  34. > Your help will be very much appreciated !
  35. > Thanks,
  36. > Michael.
  37.  
  38.  
  39. I too had a the same problem and came up with the following simple solution.
  40. However I didn't post the article because vi did not always behave as I
  41. expected. Before I describe the problem led me show what was to be my original
  42. posting.
  43.  
  44. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  45. In your .exrc file or EXINIT parameter add the following 2 mappings
  46.  
  47. map ^A mzywo^[pI:!exec vi -t ^["zdd`z@z
  48. map ^K :q!^M^M            # if too risky, force yourself to type :q! 
  49. map ^W :!exec listtags
  50.  
  51. where listtags is a shell script to display vi's -t option argument from
  52. a ps listing. eg on a Sun, this works...
  53.     ps | grep 'vi -t' | grep -v grep | awk '{ print $NR }'
  54. ( This was an afterthought and is admittedly a bit ropey )
  55.  
  56. To use, type:
  57. <ctrl-A> on the identifier you want to tag to, like ^]. 
  58. <ctrl-K> takes you back. 
  59. <ctrl-W> gives you a listing of the tags stack. 
  60.  
  61. Obviously you could use your own preferrences to ^A,^K and ^W. 
  62.  
  63. Perhaps you would appreciate an explanation of the first macro.
  64.  
  65. mz        -  mark cursor position as point z
  66. eb             -  put cursor on first character of word (end, beginning) 
  67. yw        -  yank word into unnamed buffer
  68. o          -  open a line
  69. ^[        -  <esc> come out of edit mode
  70. p        -  put back yanked word
  71. I:!exec vi -t ^[-  insert before word :!exec vi -t
  72. "zdd        -  delete line into buffer z
  73.            ( buffer now contains `:!exec vi -t *identifier*' )
  74. `z              -  Put cursor back to original spot z
  75. @z        -  Run contents of buffer z as ex command. 
  76.  
  77. As for the case insensitivity you could change the macro so that the command
  78. line becomes
  79.  
  80.     :!exec vi -t `echo *identifier* | tr "[A-Z]" "[a-z]"`
  81.  
  82. but this would only work if you had previously de-capitalized the first word on each line of your tags file. A simple shell script could could be used to 
  83. create a new lower case tags file, say lctags, and the :se tags=lctags command 
  84. in vi could be used to change the file searched when tagging. 
  85. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  86.  
  87. Now when testing these macros I found they worked well most of the time
  88. but in certain circumstances the command in z buffer does not get executed, 
  89. nor can it be recalled from the buffer using the "zp command. In fact once the 
  90. problem has occurred, all buffers seem inaccessible - you don't even get the 
  91. "nothing in register x" message. The cursor repositioning does not work 
  92. correctly either.
  93.  
  94. This behaviour can be repeated quite easily  - edit a new file and place 
  95. two words on the first line. eg
  96.  
  97. foo bar
  98.  
  99. Put the cursor on the letter b and depress ctrl-A - nothing happens. Change now
  100. to the 'f' and try ctrl-A again. Still nothing, but on the third attempt on
  101. foo it begins working!! Most weird I think, or is it just a bug in my macro??
  102. Does anyone know what's going on or even how to fix it ?
  103. Help please!
  104.  
  105. PS How do you get the character '|' into a macro ?
  106. --
  107.  
  108. Stephen Marley 
  109. Memex Information Systems Ltd, East Kilbride, Scotland
  110.