Article View: comp.editors
Article #3348find-tags for uEMACS
From: Reimer A. Mellin
Date: Mon, 31 Oct 1988 17:25
Date: Mon, 31 Oct 1988 17:25
126 lines
4277 bytes
4277 bytes
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 activate
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 window and displays
the start of the definition (Always in the lower window). In the upper
window you will still see your old context.
BUGS: the macro doesn't prompt for a name
the TAGS file is loaded after the first search (running out of
memory?)
if you 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 */
Technical Details
Message-ID:
<1101@altger.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!unido!altger!ramShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!unido!altger!ram From: ram@altger.UUCP (Reimer A. Mellin) Newsgroups: comp.editors Subject: find-tags for uEMACS Keywords: ctags, uEMACS, macro Message-ID: <1101@altger.UUCP> Date: 31 Oct 88 17:25:26 GMT Organization: Altos Computer Systems Munich Lines: 126