ram@altger.UUCP (Reimer A. Mellin) (11/04/88)
Hello, After beginning of using the uEMACS, I missed one feature of VI very soon: the Find-tags command. At the end of this Article there is now my solution, consisting basicly of a short macro, which can be added to the uEMACS startup-file. Now you can simply move to the beginning of an identifier and ac- tivate the macro (I bound it on my system to M-TAB, please change this as you like). After finding the 'TAGS'-file (created by the program 'ctags') and the specified identifier, the macro splits your current win- dow and displays the start of the definition (Always in the lower window). In the upper window you will still see your old con- text. BUGS: the macro doesn't prompt for a name the TAGS file is loaded after the first search (running out of memory?) if your current window is 2 lines high, it can't be split the default search-pattern will be overwritten ... maybe unlimited .. :-) I hope it will be useful for some of you .... Greetings Reimer Mellin PS: This was my first uEMACS-Macro, I am sure it can be made better :-) ----------------------CUT HERE------------------------------------------- ; Find-Tags Macro for uEMACS 3.8i and higher .... ; simply add to your '.emacsrc'-file ; Author: Reimer Mellin ; Date: 13.apr.88 ; You can copy, modify, use, abuse this stuff as you wish ; ; If you use this Macro please send a small contribution to GreenPeace ; or to some organisation against famine in the third world !!!!!!!! 21 store-macro !if ¬ &band $cmode 2 !return !endif ; only allowed in CMODE set $discmd FALSE set %tmp01 $cwline ; remember line add-mode "magic" set-mark !force search-forward "[^0-9A-Za-z_]" ; search for end of identifier delete-mode "magic" backward-character copy-region ; get identifier !if &seq $kill "" set %var1 "no identifier specified" !goto error2 !endif set %var1 &sub $wline $cwline %var1 next-line ; go to last line of window split-current-window ; so the new window will be the lower one previous-window %var1 previous-line exchange-point-and-mark set %tmp02 %tmp01 !if &gre %tmp02 $wline set %tmp02 $wline !endif !if &les $cwline %tmp02 &sub %tmp02 $cwline move-window-up !endif ; complicate calculation for restoring the ; old context next-window !if &exist TAGS ; the TAGS-file ... find-file TAGS !else set %var1 "tags-file not found" previous-window !goto error1 !endif add-mode "exact" ; for speed .... beginning-of-file ; rewind tags-file !force search-forward $kill !if ¬ $status set %var1 &cat $kill " not in tags-file" *error1 !force delete-window *error2 write-message &cat "Fatal error: " %var1 set $discmd TRUE !return !endif forward-character ; we were at end of identifier ... set-mark ; extract filename .. search-forward &chr 9 backward-character copy-region set %var1 $kill 3 forward-character ; extract pattern without '^' and '$' !! set-mark end-of-line 2 backward-character copy-region set %pattern $kill !force find-file %var1 ; look for filename !if ¬ $status set %var1 &cat %var1 " not found" !goto error1 !endif beginning-of-file add-mode "exact" !force search-forward %pattern !if ¬ $status set %var1 &cat %var1 " is not as I remember (run ctags again)" !goto error1 !endif delete-mode "exact" beginning-of-line ; found it .... set-mark set $discmd TRUE !endm ;DONE bind-to-key execute-macro-21 M-^I ; whatever you like ... ----------------------CUT HERE------------------------------------------- /* E O F */ -- Reimer A. Mellin UUCP : unido!altger!ram Germany->Bavaria->Munich VOICE: 49-89-791 36 68 "Real programmers don't write in any language, they patch ......"
DMasterson@cup.portal.com (David Scott Masterson) (11/10/88)
Has anyone tried these find-tags macros? I've tried the original and the cleaned up version that someone else posted and have had trouble with them on Sun 3s running SunOS 3.5. As close as I can come to figuring it out, there might be a bug in expression processing within macros and the $kill buffer. The following code does some strange things: copy-region !if &sequal $kill "" write... !endif set %indent $kill After this code runs twice (like finding the tag of two different identifiers), the kill buffer ($kill) seems to have left over data from the last kill command attached to the end of the new kill string ("position" -> "ident" = "idention"). Has anyone else run into this type of problem? Find-tags seems great (from what I can see), if I can just get it to work consistently. David Masterson DMasterson@cup.portal.com