Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!husc6!bloom-beacon!bu-cs!dartvax!eleazar.dartmouth.edu!earleh From: earleh@eleazar.dartmouth.edu (Earle R. Horton) Newsgroups: comp.sys.mac.programmer Subject: Re: C topics. Message-ID: <10403@dartvax.Dartmouth.EDU> Date: 13 Oct 88 15:47:00 GMT Article-I.D.: dartvax.10403 References: <10389@dartvax.Dartmouth.EDU> Sender: news@dartvax.Dartmouth.EDU Reply-To: earleh@eleazar.dartmouth.edu (Earle R. Horton) Organization: Dartmouth College, Hanover, NH Lines: 58 In article <10389@dartvax.Dartmouth.EDU> I write: > > I just found out about ctags a while ago. I got the source, put it on >my Mac, made an MPW Tool out of it, created a tags file from the contents >of {CIncludes}, trained an editor to use it, and WOW! Question: Why isn't >this built into every source code editor which runs on the Mac? > Judging from my mail this morning, I should have included more information. This article was targeted towards people who write and distribute source code editors, but I suppose all sorts of people would want to know about it. It sort of helps if you have an editor with source code. Assuming you have source code to an editor which runs on the Mac, and which can open a file and do forward regular expression search, then adding the capability to use ctags takes about 1 page of code. Ctags is a simple program which can be obtained via anonymous ftp to j.cc.purdue.edu. It is in /news/comp/sources/unix/volume3/ctags.Z, a compressed shar file (smallish). If you have a C compiler, then compiling the program and creating a tags file with tags for all your development system header files and personal source files is straightforward. The only snag might be if you want to use it with LightSpeedC or something which doesn't give you the ability to specify wild cards on a program command line. A clever person can get around this. The tags file contains three fields, separated by tabs. The first field is an identifier found by ctags in one of your header or source files. The second field is the name of the file where this identifier is declared. (Identifiers consist of functions, macros, and optionally typedefs.) The third field, in the case of functions and macros, is a regular expression specification telling how to find the identifier in the file. In the case of typedefs, the third field is the line number. When the editor you are using is configured to use tags, you simply position the cursor over an identifier in your C source you want information on, and press some key which is bound to the function for looking up tags. The editor then looks in the tags file, finds the tag for the identifier, opens the file, and positions itself at the identifier definition. This provides a mechanism for looking up definitions in header files, and also for moving between source code of your own in an extremely efficient manner. Currently, MacJove supports tags, as does also a vi clone which I have been playing with. This is such a handy thing that I am amazed all Mac editors do not support it. The ctags program also can index Pascal, Fortran, Lisp, Lex, and Yacc tags, and perhaps more. One could conceivably write an MPW Shell script to use tag files, too. Earle R. Horton. 23 Fletcher Circle, Hanover, NH 03755 (603) 643-4109 Sorry, no fancy stuff, since this program limits my .signature to three