🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.editors
Article #3359

Re: find-tags for uEMACS

#3359
From: David MacKenzie
Date: Tue, 08 Nov 1988 06:38
176 lines
5147 bytes
Here is a modification of Reimar's MicroEMACS tag-finding macro.  I have
split it up into two front ends; one of them takes the tag from the
buffer starting at point (the way his does) and the other prompts for it
on the message line.

I also renamed some variables to make the code clearer, and made some
other improvements like respecting the '^' and '$' characters in the
tags file's regular expressions for more accuracy.

David MacKenzie
edf@rocky2.rockefeller.edu

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  tags.cmd
# Wrapped by dave@edfdc  on Tue Nov  8 01:27:26 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'tags.cmd' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tags.cmd'\"
else
echo shar: Extracting \"'tags.cmd'\" \(2884 characters\)
sed "s/^X//" >'tags.cmd' <<'END_OF_FILE'
X; Find-Tags Macro for MicroEMACS 3.8i and higher
X; Author: Reimer Mellin
X; Modified by: David MacKenzie
X; Date: 4 November 1988
X;
X; Goes to the tag in a second, bottom window.
X; Only allowed in CMODE.
X
X; Searches for the tag of the identifier starting at point.
X15	store-macro
X	run setup-tags
X	!if &not %ok
X		!return
X	!endif
X	set %savecm $cmode
X	add-mode "magic"
X!force  search-forward "[^0-9A-Za-z_]"	; search for end of identifier
X	set $cmode %savecm
X	backward-character
X	copy-region		; get identifier
X	!if &sequal $kill ""
X		write-message "No tag specified"
X		set $discmd TRUE
X		!return
X	!endif
X	set %ident $kill
X	run find-tags
X!endm
Xbind-to-key execute-macro-15 M-T
X
X; Searches for tag of the identifier typed in the message line.
X16	store-macro
X	run setup-tags
X	!if &not %ok
X		!return
X	!endif
X	set %ident @"Search for tag: "
X	run find-tags
X!endm
Xbind-to-key execute-macro-16 ^XT
X
Xstore-procedure setup-tags
X	set $discmd FALSE
X	!if &not  &band $cmode 2
X		write-message "Must be in CMODE"
X		set $discmd TRUE
X		set %ok FALSE
X		!return
X	!endif
X
X	set %startcwl $cwline	; remember line
X	set-mark
X	set %ok TRUE
X!endm
X
Xstore-procedure find-tags
X	write-message  &cat  "Searching for tag "  &cat %ident " . . ."
X
X	delete-other-windows
X	set %lfrombot  &sub $wline $cwline
X	%lfrombot next-line	; go to last line of window
X	split-current-window	; so the new window will be the lower one
X	previous-window
X	; complicated calculation for restoring the old context
X	%lfrombot previous-line
X	exchange-point-and-mark	; return to original point
X	!if &less $wline %startcwl
X		set %startcwl $wline
X	!endif
X	!if &less $cwline %startcwl
X		&sub %startcwl $cwline  move-window-up
X	!endif
X
X	next-window
X	!if &exist "tags"
X		find-file "tags"
X	!else
X		set %errmesg "No tags file"
X		previous-window
X		!goto error1
X	!endif
X
X	; find identifier in tags file
X	add-mode "exact"
X	add-mode "magic"
X	beginning-of-file	; rewind tags file
X!force  search-forward  &cat "^"  &cat %ident &chr 9
X	!if &not $status
X		set %errmesg &cat %ident ": No such tag in tags file"
X*error1
X!force 		delete-window
X*error2
X		write-message %errmesg
X		set $discmd TRUE
X		!return
X	!endif
X
X	; extract filename
X	set-mark
X	search-forward &chr 9	; find tab after filename
X	backward-character
X	copy-region
X	set %tagfile $kill
X
X	; extract search string
X	2 forward-character	; skip past tab /
X	set-mark
X	end-of-line
X	backward-character	; back up past /
X	copy-region
X	set %pattern $kill
X
X!force  find-file %tagfile
X	!if &not $status
X		set %errmesg  &cat %tagfile " not found"
X		!goto error1
X	!endif
X
X	; search for pattern in tagfile
X	beginning-of-file
X	set %savecm $cmode
X	add-mode "exact"
X	add-mode "magic"
X!force  search-forward %pattern
X	!if &not $status
X		set %errmesg "Pattern for tag not found; rerun ctags"
X		!goto error1
X	!endif
X	set $cmode %savecm
X
X	beginning-of-line	; found the tag
X	set-mark
X
X	clear-message-line
X	set $discmd TRUE
X!endm
END_OF_FILE
if test 2884 -ne `wc -c <'tags.cmd'`; then
    echo shar: \"'tags.cmd'\" unpacked with wrong size!
fi
# end of 'tags.cmd'
fi
echo shar: End of shell archive.
exit 0
-----
David MacKenzie
Environmental Defense Fund
edf@rocky2.rockefeller.edu (...rutgers!cmcl2!rocky2!edf)
Technical Details
Message-ID: <224@rocky8.rockefeller.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!bellcore!rutgers!cmcl2!rocky8!rocky2.rockefeller.edu!edf
References: <1101@altger.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!bellcore!rutgers!cmcl2!rocky8!rocky2.rockefeller.edu!edf
From: edf@rocky2.rockefeller.edu (David MacKenzie)
Newsgroups: comp.editors
Subject: Re: find-tags for uEMACS
Keywords: ctags, uEMACS, macro
Message-ID: <224@rocky8.rockefeller.edu>
Date: 8 Nov 88 06:38:52 GMT
References: <1101@altger.UUCP>
Sender: notes@rocky8.rockefeller.edu
Reply-To: edf@rocky2.rockefeller.edu (David MacKenzie)
Organization: Environmental Defense Fund
Lines: 176