home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume38 / cie / part02 < prev    next >
Encoding:
Text File  |  1993-06-20  |  60.4 KB  |  1,714 lines

  1. Newsgroups: comp.sources.misc
  2. From: kennedy@art.intellection.com (Brian M Kennedy)
  3. Subject: v38i016:  cie - C++ In Emacs v1.0, Part02/02
  4. Message-ID: <1993Jun20.232350.15755@sparky.imd.sterling.com>
  5. X-Md4-Signature: 99dca9d7801abc1e2e53d0aab7299308
  6. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Sun, 20 Jun 1993 23:23:50 GMT
  9. Approved: kent@sparky.imd.sterling.com
  10.  
  11. Submitted-by: kennedy@art.intellection.com (Brian M Kennedy)
  12. Posting-number: Volume 38, Issue 16
  13. Archive-name: cie/part02
  14. Environment: Emacs, C++
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  cie/COPYING cie/README cie/cie-mouse.el cie/cie.el
  21. #   cie/class-manual.el cie/do-etags++ cie/etags++/Makefile
  22. #   cie/etags++/hier++.c cie/goto-file.el
  23. # Wrapped by kent@sparky on Sun Jun 20 18:21:18 1993
  24. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 2 (of 2)."'
  27. if test -f 'cie/COPYING' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'cie/COPYING'\"
  29. else
  30.   echo shar: Extracting \"'cie/COPYING'\" \(9934 characters\)
  31.   sed "s/^X//" >'cie/COPYING' <<'END_OF_FILE'
  32. X            GNU GENERAL PUBLIC LICENSE
  33. X             Version 1, February 1989
  34. X
  35. X Copyright (C) 1989 Free Software Foundation, Inc.
  36. X                    675 Mass Ave, Cambridge, MA 02139, USA
  37. X Everyone is permitted to copy and distribute verbatim copies
  38. X of this license document, but changing it is not allowed.
  39. X
  40. X                Preamble
  41. X
  42. X  The license agreements of most software companies try to keep users
  43. Xat the mercy of those companies.  By contrast, our General Public
  44. XLicense is intended to guarantee your freedom to share and change free
  45. Xsoftware--to make sure the software is free for all its users.  The
  46. XGeneral Public License applies to the Free Software Foundation's
  47. Xsoftware and to any other program whose authors commit to using it.
  48. XYou can use it for your programs, too.
  49. X
  50. X  When we speak of free software, we are referring to freedom, not
  51. Xprice.  Specifically, the General Public License is designed to make
  52. Xsure that you have the freedom to give away or sell copies of free
  53. Xsoftware, that you receive source code or can get it if you want it,
  54. Xthat you can change the software or use pieces of it in new free
  55. Xprograms; and that you know you can do these things.
  56. X
  57. X  To protect your rights, we need to make restrictions that forbid
  58. Xanyone to deny you these rights or to ask you to surrender the rights.
  59. XThese restrictions translate to certain responsibilities for you if you
  60. Xdistribute copies of the software, or if you modify it.
  61. X
  62. X  For example, if you distribute copies of a such a program, whether
  63. Xgratis or for a fee, you must give the recipients all the rights that
  64. Xyou have.  You must make sure that they, too, receive or can get the
  65. Xsource code.  And you must tell them their rights.
  66. X
  67. X  We protect your rights with two steps: (1) copyright the software, and
  68. X(2) offer you this license which gives you legal permission to copy,
  69. Xdistribute and/or modify the software.
  70. X
  71. X  Also, for each author's protection and ours, we want to make certain
  72. Xthat everyone understands that there is no warranty for this free
  73. Xsoftware.  If the software is modified by someone else and passed on, we
  74. Xwant its recipients to know that what they have is not the original, so
  75. Xthat any problems introduced by others will not reflect on the original
  76. Xauthors' reputations.
  77. X
  78. X  The precise terms and conditions for copying, distribution and
  79. Xmodification follow.
  80. X
  81. X            GNU GENERAL PUBLIC LICENSE
  82. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  83. X
  84. X  0. This License Agreement applies to any program or other work which
  85. Xcontains a notice placed by the copyright holder saying it may be
  86. Xdistributed under the terms of this General Public License.  The
  87. X"Program", below, refers to any such program or work, and a "work based
  88. Xon the Program" means either the Program or any work containing the
  89. XProgram or a portion of it, either verbatim or with modifications.  Each
  90. Xlicensee is addressed as "you".
  91. X
  92. X  1. You may copy and distribute verbatim copies of the Program's source
  93. Xcode as you receive it, in any medium, provided that you conspicuously and
  94. Xappropriately publish on each copy an appropriate copyright notice and
  95. Xdisclaimer of warranty; keep intact all the notices that refer to this
  96. XGeneral Public License and to the absence of any warranty; and give any
  97. Xother recipients of the Program a copy of this General Public License
  98. Xalong with the Program.  You may charge a fee for the physical act of
  99. Xtransferring a copy.
  100. X
  101. X  2. You may modify your copy or copies of the Program or any portion of
  102. Xit, and copy and distribute such modifications under the terms of Paragraph
  103. X1 above, provided that you also do the following:
  104. X
  105. X    a) cause the modified files to carry prominent notices stating that
  106. X    you changed the files and the date of any change; and
  107. X
  108. X    b) cause the whole of any work that you distribute or publish, that
  109. X    in whole or in part contains the Program or any part thereof, either
  110. X    with or without modifications, to be licensed at no charge to all
  111. X    third parties under the terms of this General Public License (except
  112. X    that you may choose to grant warranty protection to some or all
  113. X    third parties, at your option).
  114. X
  115. X    c) If the modified program normally reads commands interactively when
  116. X    run, you must cause it, when started running for such interactive use
  117. X    in the simplest and most usual way, to print or display an
  118. X    announcement including an appropriate copyright notice and a notice
  119. X    that there is no warranty (or else, saying that you provide a
  120. X    warranty) and that users may redistribute the program under these
  121. X    conditions, and telling the user how to view a copy of this General
  122. X    Public License.
  123. X
  124. X    d) You may charge a fee for the physical act of transferring a
  125. X    copy, and you may at your option offer warranty protection in
  126. X    exchange for a fee.
  127. X
  128. XMere aggregation of another independent work with the Program (or its
  129. Xderivative) on a volume of a storage or distribution medium does not bring
  130. Xthe other work under the scope of these terms.
  131. X
  132. X  3. You may copy and distribute the Program (or a portion or derivative of
  133. Xit, under Paragraph 2) in object code or executable form under the terms of
  134. XParagraphs 1 and 2 above provided that you also do one of the following:
  135. X
  136. X    a) accompany it with the complete corresponding machine-readable
  137. X    source code, which must be distributed under the terms of
  138. X    Paragraphs 1 and 2 above; or,
  139. X
  140. X    b) accompany it with a written offer, valid for at least three
  141. X    years, to give any third party free (except for a nominal charge
  142. X    for the cost of distribution) a complete machine-readable copy of the
  143. X    corresponding source code, to be distributed under the terms of
  144. X    Paragraphs 1 and 2 above; or,
  145. X
  146. X    c) accompany it with the information you received as to where the
  147. X    corresponding source code may be obtained.  (This alternative is
  148. X    allowed only for noncommercial distribution and only if you
  149. X    received the program in object code or executable form alone.)
  150. X
  151. XSource code for a work means the preferred form of the work for making
  152. Xmodifications to it.  For an executable file, complete source code means
  153. Xall the source code for all modules it contains; but, as a special
  154. Xexception, it need not include source code for modules which are standard
  155. Xlibraries that accompany the operating system on which the executable
  156. Xfile runs, or for standard header files or definitions files that
  157. Xaccompany that operating system.
  158. X
  159. X  4. You may not copy, modify, sublicense, distribute or transfer the
  160. XProgram except as expressly provided under this General Public License.
  161. XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
  162. Xthe Program is void, and will automatically terminate your rights to use
  163. Xthe Program under this License.  However, parties who have received
  164. Xcopies, or rights to use copies, from you under this General Public
  165. XLicense will not have their licenses terminated so long as such parties
  166. Xremain in full compliance.
  167. X
  168. X  5. By copying, distributing or modifying the Program (or any work based
  169. Xon the Program) you indicate your acceptance of this license to do so,
  170. Xand all its terms and conditions.
  171. X
  172. X  6. Each time you redistribute the Program (or any work based on the
  173. XProgram), the recipient automatically receives a license from the original
  174. Xlicensor to copy, distribute or modify the Program subject to these
  175. Xterms and conditions.  You may not impose any further restrictions on the
  176. Xrecipients' exercise of the rights granted herein.
  177. X
  178. X  7. The Free Software Foundation may publish revised and/or new versions
  179. Xof the General Public License from time to time.  Such new versions will
  180. Xbe similar in spirit to the present version, but may differ in detail to
  181. Xaddress new problems or concerns.
  182. X
  183. XEach version is given a distinguishing version number.  If the Program
  184. Xspecifies a version number of the license which applies to it and "any
  185. Xlater version", you have the option of following the terms and conditions
  186. Xeither of that version or of any later version published by the Free
  187. XSoftware Foundation.  If the Program does not specify a version number of
  188. Xthe license, you may choose any version ever published by the Free Software
  189. XFoundation.
  190. X
  191. X  8. If you wish to incorporate parts of the Program into other free
  192. Xprograms whose distribution conditions are different, write to the author
  193. Xto ask for permission.  For software which is copyrighted by the Free
  194. XSoftware Foundation, write to the Free Software Foundation; we sometimes
  195. Xmake exceptions for this.  Our decision will be guided by the two goals
  196. Xof preserving the free status of all derivatives of our free software and
  197. Xof promoting the sharing and reuse of software generally.
  198. X
  199. X                NO WARRANTY
  200. X
  201. X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  202. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  203. XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  204. XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  205. XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  206. XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  207. XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  208. XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  209. XREPAIR OR CORRECTION.
  210. X
  211. X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  212. XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  213. XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  214. XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  215. XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  216. XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  217. XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  218. XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  219. XPOSSIBILITY OF SUCH DAMAGES.
  220. X
  221. X             END OF TERMS AND CONDITIONS
  222. END_OF_FILE
  223.   if test 9934 -ne `wc -c <'cie/COPYING'`; then
  224.     echo shar: \"'cie/COPYING'\" unpacked with wrong size!
  225.   fi
  226.   # end of 'cie/COPYING'
  227. fi
  228. if test -f 'cie/README' -a "${1}" != "-c" ; then 
  229.   echo shar: Will not clobber existing file \"'cie/README'\"
  230. else
  231.   echo shar: Extracting \"'cie/README'\" \(9444 characters\)
  232.   sed "s/^X//" >'cie/README' <<'END_OF_FILE'
  233. XC++ In Emacs (CIE) v 1.0
  234. X
  235. XArchive-name: cie
  236. XEnvironment: Emacs, C++
  237. X
  238. XAuthor:  Brian M Kennedy (kennedy@intellection.com)
  239. X         with contributions from:
  240. X           Walt Buehring (tags.el and minibuffer-yank.el)
  241. X           Sam Kendall (tags.el) 
  242. X       (and, of course, the original tags.el author(s)).
  243. X
  244. X
  245. XThis package is a collection of some of the tools/enhancements we use for C++
  246. Xdevelopment work within GNU Emacs.  Briefly, it consists of an enhanced etags
  247. Xfor C++, a related class hierarchy generator, a mode and M-x commands for
  248. Xbrowsing the hierarchy and getting lists of class members, a command goto-file
  249. Xthat takes you to the proper line in a file, functions to make both tag names
  250. Xand file names mouseable, and a class manual generator that uses the hierarchy
  251. Xand tag information, coupled with the comments in the code, to build a class
  252. Xmanual in texinfo format.
  253. X
  254. XI've been stalling on releasing this, hoping to find time to implement some of
  255. Xthe outstanding features and do some significant cleanup.  I have decided that
  256. XI will never get to it (and I feel more and more guilty every time I see one
  257. Xof the many requests for these features on the newsgroups), so I am just going
  258. Xto release it basically as is.  My apologies.
  259. X
  260. XNote the implication here -- in the past many, many months I have never found
  261. Xtime to do any of the to-do queue.  You are welcome to send bug reports and
  262. Xsuggestions, but it is highly improbable that I will ever manage to get to
  263. Xacting on them.  If you like this package, and want it to grow, consider 
  264. Xvolunteering to adopt it and become its maintainer.  Any and all are welcome 
  265. Xto do so.
  266. X
  267. XThis has run with GNU Emacs 18.51, 18.55, 18.57 and 18.58.  I have not yet 
  268. Xswitched to Emacs 19, so neither has this code.  If you want to use it with 
  269. XEmacs 19, I encourage you to volunteer to "port" it for the rest of us ;-)
  270. X
  271. XThe etags++ and hier++ C++ programs have been compiled with Sun C++, 
  272. XCenterline C++, Lucid C++, and Comeau C++ on Sun OS, Ultrix, and AIX 
  273. Xplatforms.
  274. X
  275. X=====
  276. X
  277. XThe directory etags++ contains source for two programs, etags++ and hier++.
  278. XThey are written in C++.  Assuming you have some reasonable C++ compiler
  279. Xaccessible via command "CC", a simple make should build the two programs.
  280. X
  281. XThe file do-etags++ is simply an example of how to invoke etags++, hier++, 
  282. Xand emacs in batch mode to save out the tags-alist.  This is done for me
  283. Xautomatically each night (but just takes a few minutes on 100K LOC).
  284. X
  285. XThe files cie.el and cie-mouse.el set up keystrokes and mousestrokes and
  286. Xautoloads for the other files.  You may want to load these (or variations)
  287. Xin your default.el or .emacs.
  288. X
  289. XThe other files (the meat) need to be dropped in your load-path somewhere.  
  290. XNote that the tags.el should be loaded instead of (or after) the standard 
  291. Xtags.el.
  292. X
  293. XThe TAGS file generated by etags++ is standard format.  So, it is possible
  294. Xto use just that with the standard tags.el.  And this tags.el should work
  295. Xessentially the same as the standard tags.el on TAGS files generated by the
  296. Xstandard etags program (that is important since etags++ only supports C/C++
  297. Xcode; you must use the standard etags for Lisp, TeX, FORTRAN, etc.).
  298. X
  299. X
  300. XHere are excerpts from the important files:
  301. X
  302. X======================
  303. X;;; tags.el
  304. X
  305. X;; INTELLECTION MODS:
  306. X;; 
  307. X;; 1) Prefers the tags named explicitly after C-A's at the end of each line.
  308. X;;    This is true both for find-tag and for the completion-alist.
  309. X;; 2) Support for C++ scoping -- class::name is considered a tag and both
  310. X;;    class::name and name are matches (class::name preferred though).
  311. X;; 3) Support for completion of scoped names as well as unscoped names.
  312. X;;    That is, the alist contains both the fully-scoped name, and each
  313. X;;    subname (c1::c2::mem => c1::c2::mem, c2::mem, and mem in the alist).
  314. X;; 4) Added mechanism to save out the completion alist into TAGS.alist
  315. X;;    which is checked for when loading TAGS to prevent the need to rebuild
  316. X;;    the alist (which can take a while with large systems).  As an added
  317. X;;    advantage, this mechanism removes duplicates from the alist before
  318. X;;    saving it out (making it faster and much smaller).
  319. X
  320. X======================
  321. X;;; hier-mode.el
  322. X;;; Hierarchy mode (for hierarchies output by hier++)
  323. X
  324. X"Major mode for viewing class hierarchy files output by hier++.
  325. XThe file is formatted like this:
  326. X
  327. X* class_a 
  328. X  * child_b  :class_a
  329. X  * child_c  :class_a :class_f
  330. X    * grandchild_d  :child_c
  331. X    * grandchild_e  :child_c
  332. X* class_f
  333. X  * child_c  :class_a :class_f
  334. X    * grandchild_d  :child_c
  335. X    * grandchild_e  :child_c
  336. X  * child_g  :class_f
  337. X
  338. XClasses child_b and child_c are derived from class_a; classes child_c and
  339. Xchild_g are derived from class_f; classes grandchild_d and grandchild_e are
  340. Xboth derived from child_c.  Note that each class (and all of its children) 
  341. Xwill appear in the file once under each parent.
  342. X
  343. XDefined keys:
  344. XM-p moves to the previous sibling
  345. XM-n moves to the next sibling
  346. XM-u moves up to the parent
  347. XM-h finds the first occurrence of the hierarchy element for a class 
  348. X    (similar to M-. in behavior)
  349. XM-g finds the next occurrence (like M-,) in the case of multiple-inheritance.
  350. XM-m brings up a new window with a listing of all the members (both direct and 
  351. X    inherited) of that hierarchy entry.  It does this via tags, so you must 
  352. X    have tags set up in Emacs.  It will also only work properly if the tags 
  353. X    file was generated by etags++ (companion to hier++)."
  354. X
  355. X======================
  356. X;;; class-manual.el
  357. X;;; Class Manual Generation
  358. X;;;   Code to use hier-mode (for hierarchies output by hier++) and etags++
  359. X;;;   functionality to build a class manual using the header comments in 
  360. X;;;   the code itself.  The formatting is in standard texinfo.
  361. X;;;   This is a hack that has been helpful for us, given our coding 
  362. X;;;   guidelines.  It will likely need modification to produce good
  363. X;;;   output for you.  (Header comments are those placed between the 
  364. X;;;   signature and the body of functions or classes.  If you don't follow
  365. X;;;   this convention, then this code will need modification.)
  366. X
  367. X======================
  368. X;;; goto-file.el
  369. X
  370. X;;; By binding goto-file to a key or mouse stroke, you can essentially
  371. X;;; make filenames "hot"; it will attempt to find that file in the 
  372. X;;; current buffer's default directory.  If no such file exists, then 
  373. X;;; it checks the current tags-table, gambling that it is one of your
  374. X;;; source files and will be tagged.
  375. X;;;
  376. X;;; Furthermore, it will try to go to the right location in the file.
  377. X;;; If there is an adjacent line number, then it will go to that line.
  378. X;;; Or if there is an adjacent grep pattern, then it will find that pattern.
  379. X;;;
  380. X;;; For instance, if you are in a shell and do an "ls", you can then click on
  381. X;;; any file name to open the file.  If you do a "make", you can click on any
  382. X;;; error msg to take you to the line of the error.  If you are in dbx, and it
  383. X;;; outputs a break or an assert outputs file/line, then you can simply click
  384. X;;; on the filename to take you to the line.  If you do a "grep", then you
  385. X;;; can simply click on the filename of the match that you want to go to.
  386. X;;; IMO, this is preferable to M-x compile or grep, because there is no need
  387. X;;; to proceed in order.  It also works everywhere: in source files, in
  388. X;;; shells, in night build logs, in mail buffers, etc.
  389. X
  390. X======================
  391. X// etags++/c++file.c
  392. X//
  393. X// This .c file, written in C++, is intended to be included in etags++.c and hier++.c.
  394. X// It is a quick-and-dirty "fuzzy" parser for C++ files that identifies enough tokens for
  395. X// etags++ and hier++ to do a good job.  See those files for information on the resultant
  396. X// functionality.  This file simply provides the common parsing code.
  397. X
  398. X======================
  399. X// etags++/etags++.c
  400. X//
  401. X// This program reads in C++ code and generates a tags file for GNU Emacs.
  402. X// This program is more sophisticated than the standard etags program for C++
  403. X// programs.  It finds all classes, structs, unions, enums, enumerators, #defines,
  404. X// typedefs, functions (both global and member), and data (both global and member).
  405. X// Furthermore, it handles C++ scoping correctly, outputting fully-scoped tags
  406. X// at the end of each line.  Thus, we have modified our Emacs tags.el to search
  407. X// the fully-scoped names at the ends of the lines before the patterns.  It also
  408. X// handles template syntax.
  409. X//
  410. X// In addition, we have added support for a few important macro conventions that
  411. X// we use.  DECLARE_*(name,..) macros define the tag <name> in the current scope;
  412. X// DEFINE_*(class,name,...) macros define the tag <class>::<name>.  We use NOTE(name)
  413. X// macros to name comments, so that you can refer to them by See::name in other
  414. X// comments.  In Emacs, M-. on See::name will take you to the named comment.
  415. X//
  416. X// Note that this uses "fuzzy", quick-and-dirty parsing to find the tokens.  Thus, it
  417. X// can miss some things.  Also note that this is not an etags replacement -- it only
  418. X// supports C/C++ code.  The etags program will still be needed for TeX, Fortran, etc.
  419. X
  420. X======================
  421. X// etags++/hier++.c
  422. X//
  423. X// This program reads in C++ code and generates a "hier" file that displays the
  424. X// class hierarchy.  You can then use the GNU Emacs hier-mode for traversing the
  425. X// hierarchy and extracting information from your TAGS (if generated by etags++).
  426. X//
  427. X// Note that this program is built on the same quick-and-dirty "fuzzy" parser
  428. X// that etags++ was, and will suffer the same ability to be fooled sometimes.
  429. END_OF_FILE
  430.   if test 9444 -ne `wc -c <'cie/README'`; then
  431.     echo shar: \"'cie/README'\" unpacked with wrong size!
  432.   fi
  433.   # end of 'cie/README'
  434. fi
  435. if test -f 'cie/cie-mouse.el' -a "${1}" != "-c" ; then 
  436.   echo shar: Will not clobber existing file \"'cie/cie-mouse.el'\"
  437. else
  438.   echo shar: Extracting \"'cie/cie-mouse.el'\" \(9055 characters\)
  439.   sed "s/^X//" >'cie/cie-mouse.el' <<'END_OF_FILE'
  440. X;;; Mouse Settings to make tagnames and filenames "mouseable"
  441. X
  442. X;; Left = This Window;  Middle = Other Window
  443. X
  444. X;; Shift = Tag
  445. X(define-key mouse-map x-button-s-left          'x-find-tag-default)
  446. X(define-key mouse-map x-button-s-left-up       'x-mouse-ignore)
  447. X(define-key mouse-map x-button-s-middle        'x-find-tag-default-other-window)
  448. X(define-key mouse-map x-button-s-middle-up     'x-mouse-ignore)
  449. X;; Control = File
  450. X(define-key mouse-map x-button-c-left          'x-goto-file)
  451. X(define-key mouse-map x-button-c-left-up       'x-mouse-ignore)
  452. X(define-key mouse-map x-button-c-middle        'x-goto-file-other-window)
  453. X(define-key mouse-map x-button-c-middle-up     'x-mouse-ignore)
  454. X
  455. X
  456. X(autoload 'find-tag-default "tags" "Find potential tag at point.")
  457. X
  458. X(defun x-find-tag (arg)
  459. X  (x-mouse-set-point arg)
  460. X  (let ((tag (find-tag-default))) 
  461. X    (find-tag tag)
  462. X    ;; Wait for and discard the button-up key so the message is not flushed.
  463. X    (sit-for 1)
  464. X    (discard-input)
  465. X    (message "Find tag: %s" tag)))
  466. X
  467. X
  468. X(defun x-find-tag-default (arg)
  469. X  (x-mouse-set-point arg)
  470. X  (let ((tag (find-tag-default))) 
  471. X    (message "Find tag: %s" tag)
  472. X    (find-tag tag) ))
  473. X
  474. X
  475. X(defun x-find-tag-default-other-window (arg)
  476. X  (x-mouse-set-point arg)
  477. X  (let ((tag (find-tag-default))) 
  478. X    (message "Find tag: %s" tag)
  479. X    (find-tag-other-window tag) ))
  480. X
  481. X
  482. X(defun x-goto-file (arg)
  483. X  (x-mouse-set-point arg)
  484. X  (let ((goto-file-other-window-p nil))
  485. X    (goto-file) ) )
  486. X
  487. X
  488. X(defun x-goto-file-other-window (arg)
  489. X  (x-mouse-set-point arg)
  490. X  (let ((goto-file-other-window-p t))
  491. X    (goto-file) ) )
  492. X
  493. X
  494. X
  495. X;;;===== Mouse Command Defuns
  496. X
  497. X(defvar x-auto-mouse-select nil
  498. X  "When non-nil, always select the window containing the mouse.")
  499. X
  500. X;;; Redefined from x-mouse.el - dont leave the minibuffer via the mouse
  501. X(defun x-mouse-select (arg)
  502. X  "Select Emacs window the mouse is on."
  503. X  (let ((start-w (selected-window))
  504. X    (done nil)
  505. X    (w (selected-window))
  506. X    (rel-coordinate nil))
  507. X    (while (and (not done)
  508. X        (null (setq rel-coordinate
  509. X                (coordinates-in-window-p arg w))))
  510. X      (setq w (next-window w))
  511. X      (if (eq w start-w)
  512. X      (setq done t)))
  513. X    ;; Dont allow the user to exit the minibuffer using the mouse.
  514. X    (if (and (eq (selected-window) (minibuffer-window))
  515. X         (not (eq w (minibuffer-window))))
  516. X    (error ""))
  517. X    (select-window w)
  518. X    rel-coordinate))
  519. X
  520. X
  521. X(defun x-scroll-up (arg)
  522. X  "Scroll up the window the mouse is over."
  523. X  (let ((owin (selected-window)))
  524. X    (if (x-mouse-select arg)
  525. X    (progn
  526. X      (scroll-up nil)
  527. X      (or (eq owin (selected-window))
  528. X          x-auto-mouse-select
  529. X          (select-window owin))))))
  530. X
  531. X
  532. X(defun x-scroll-down (arg)
  533. X  "Scroll down the window the mouse is over."
  534. X  (let ((owin (selected-window)))
  535. X    (if (x-mouse-select arg)
  536. X    (progn
  537. X      (scroll-down nil)
  538. X      (or (eq owin (selected-window))
  539. X          x-auto-mouse-select
  540. X          (select-window owin))))))
  541. X
  542. X
  543. X(defun x-line-to-top (arg)
  544. X  "Scroll line at the mouse to top of window."
  545. X  (let ((owin (selected-window)))
  546. X    (if (x-mouse-select arg)
  547. X    (progn
  548. X      (save-excursion
  549. X        (x-mouse-set-point arg)
  550. X        (line-to-top-of-window))
  551. X      (or (eq owin (selected-window))
  552. X          x-auto-mouse-select
  553. X          (select-window owin))))))
  554. X
  555. X
  556. X(defun x-line-to-bottom (arg)
  557. X  "Scroll line at the mouse to bottom of window."
  558. X  (let ((owin (selected-window)))
  559. X    (if (x-mouse-select arg)
  560. X    (progn
  561. X      (save-excursion
  562. X        (x-mouse-set-point arg)
  563. X        (line-to-bottom-of-window))
  564. X      (or (eq owin (selected-window))
  565. X          x-auto-mouse-select
  566. X          (select-window owin))))))
  567. X
  568. X
  569. X(defun x-scroll-up-one (arg)
  570. X  "Scroll the window at the mouse one line up."
  571. X  (let ((owin (selected-window)))
  572. X    (if (x-mouse-select arg)
  573. X    (progn
  574. X      (scroll-one-line-up 1)
  575. X      (or (eq owin (selected-window))
  576. X          x-auto-mouse-select
  577. X          (select-window owin))))))
  578. X
  579. X
  580. X(defun x-scroll-down-one (arg)
  581. X  "Scroll the window at the mouse one line up."
  582. X  (let ((owin (selected-window)))
  583. X    (if (x-mouse-select arg)
  584. X    (progn
  585. X      (scroll-one-line-down 1)
  586. X      (or (eq owin (selected-window))
  587. X          x-auto-mouse-select
  588. X          (select-window owin))))))
  589. X
  590. X
  591. X(defun x-enlarge-window (arg)
  592. X  "Select Emacs window mouse is on, then grow it by one line."
  593. X  (if (x-mouse-select arg)
  594. X      (enlarge-window 1)))
  595. X
  596. X
  597. X;;; Redefined to blink cursor around region
  598. X(defun x-cut-text (arg &optional kill)
  599. X  "Copy text between point and mouse position into window system cut buffer.
  600. XSave in Emacs kill ring also."
  601. X  (if (coordinates-in-window-p arg (selected-window))
  602. X      (save-excursion
  603. X    (let ((opoint (point))
  604. X          beg end)
  605. X      (x-mouse-set-point arg)
  606. X      (sit-for 1)
  607. X      (setq beg (min opoint (point))
  608. X        end (max opoint (point)))
  609. X      (x-store-cut-buffer (buffer-substring beg end))
  610. X      (copy-region-as-kill beg end)
  611. X      (if kill (delete-region beg end))))
  612. X    (message "Mouse not in selected window")))
  613. X
  614. X
  615. X(defun x-cut-sexp (arg &optional kill)
  616. X  "Copy sexp starting at mouse into window system cut buffer.
  617. XSave in Emacs kill ring also."
  618. X  (save-window-excursion
  619. X    (x-mouse-select arg)
  620. X    (save-excursion
  621. X      (x-mouse-set-point arg)
  622. X      (let ((beg (point))
  623. X        end)
  624. X    (discard-input)
  625. X    (sit-for 1)
  626. X    (forward-sexp 1)
  627. X    (sit-for 1)
  628. X    (setq end (point))
  629. X    (x-store-cut-buffer (buffer-substring beg end))
  630. X    (copy-region-as-kill beg end)
  631. X    (if kill (delete-region beg end))
  632. X    ))))
  633. X
  634. X
  635. X(defun x-paste-sexp (arg)
  636. X  "Copy sexp at mouse into cut buffer and then paste at cursor."
  637. X  (x-cut-sexp arg)
  638. X  (insert (x-get-cut-buffer)))
  639. X
  640. X
  641. X(defun x-cut-and-wipe-word (arg)
  642. X  "Kill the word at the mouse."
  643. X  (x-mouse-set-point arg)
  644. X  (let ((beg (point))
  645. X    (end (save-excursion (forward-word 1) (point))))
  646. X    (x-store-cut-buffer (buffer-substring beg end))
  647. X    (copy-region-as-kill beg end)
  648. X    (delete-region beg end)))
  649. X
  650. X
  651. X(defun x-cut-and-wipe-sexp (arg)
  652. X  "Kill the sexp at the mouse."
  653. X  (x-mouse-set-point arg)
  654. X  (let ((beg (point))
  655. X    (end (save-excursion (forward-sexp 1) (sit-for 1) (point))))
  656. X    (x-store-cut-buffer (buffer-substring beg end))
  657. X    (copy-region-as-kill beg end)
  658. X    (delete-region beg end)))
  659. X
  660. X
  661. X(defun x-find-tag (arg)
  662. X  (x-mouse-set-point arg)
  663. X  (let ((tag (find-tag-default))) 
  664. X    (find-tag tag)
  665. X    ;; Wait for and discard the button-up key so the message is not flushed.
  666. X    (sit-for 1)
  667. X    (discard-input)
  668. X    (message "Find tag: %s" tag)))
  669. X
  670. X
  671. X(defun x-find-tag-default (arg)
  672. X  (x-mouse-set-point arg)
  673. X  (let ((tag (find-tag-default))) 
  674. X    (message "Find tag: %s" tag)
  675. X    (find-tag tag) ))
  676. X
  677. X
  678. X(defun x-find-tag-default-other-window (arg)
  679. X  (x-mouse-set-point arg)
  680. X  (let ((tag (find-tag-default))) 
  681. X    (message "Find tag: %s" tag)
  682. X    (find-tag-other-window tag) ))
  683. X
  684. X
  685. X(defun x-goto-file (arg)
  686. X  (x-mouse-set-point arg)
  687. X  (let ((goto-file-other-window-p nil))
  688. X    (goto-file) ) )
  689. X
  690. X
  691. X(defun x-goto-file-other-window (arg)
  692. X  (x-mouse-set-point arg)
  693. X  (let ((goto-file-other-window-p t))
  694. X    (goto-file) ) )
  695. X
  696. X
  697. X(defun x-search-forward (arg)
  698. X  (x-mouse-set-point arg)
  699. X  (skip-chars-forward " \t")
  700. X  (let* ((end (progn (forward-sexp 1) (point)))
  701. X     (start (save-excursion (forward-sexp -1) (point)))
  702. X     (string (buffer-substring start end)))
  703. X    (search-forward string)))
  704. X
  705. X
  706. X(defun x-search-backward (arg)
  707. X  (x-mouse-set-point arg)
  708. X  (skip-chars-forward " \t")
  709. X  (let* ((end (progn (forward-sexp 1) (point)))
  710. X     (start (progn (forward-sexp -1) (point)))
  711. X     (string (buffer-substring start end)))
  712. X    (search-backward string)))
  713. X
  714. X
  715. X;; Redefined to prevent clobbering "last-command" which is used by
  716. X;; x-search-forward/backward
  717. X
  718. X(defun x-flush-mouse-queue () 
  719. X  "Process all queued mouse events."
  720. X  ;; A mouse event causes a special character sequence to be given
  721. X  ;; as keyboard input.  That runs this function, which process all
  722. X  ;; queued mouse events and returns.
  723. X  (interactive)
  724. X  (while (> (x-mouse-events) 0)
  725. X    (x-proc-mouse-event)
  726. X    (and (boundp 'x-process-mouse-hook)
  727. X     (symbol-value 'x-process-mouse-hook)
  728. X     (funcall x-process-mouse-hook x-mouse-pos x-mouse-item)))
  729. X  
  730. X  )
  731. X
  732. X
  733. X;; the following function may look very much like x-buffer-menu
  734. X(defun x-command-history-menu (arg)
  735. X  "Pop up a menu of command history for selection with the mouse."
  736. X  (let ((menu
  737. X         (list "Command History Menu"
  738. X               (cons "Select Command"
  739. X                     (let ((tail command-history)
  740. X                           (prev "^ "); non existent command
  741. X                           head)
  742. X                       (while tail
  743. X                         (let ((elt (car tail)))
  744. X                           (if (not (string-match prev
  745. X                                                  (prin1-to-string elt)))
  746. X                               (setq head (cons
  747. X                                           (cons
  748. X                                             (setq prev (prin1-to-string elt))
  749. X                                            elt)
  750. X                                           head))))
  751. X                         (setq tail (cdr tail)))
  752. X                       (if head (reverse head)
  753. X                         (setq head (cons (cons "command-history empty"
  754. X                                                (prin1-to-string nil)) head)))
  755. X                       )))))
  756. X    (eval (x-popup-menu arg menu))))
  757. END_OF_FILE
  758.   if test 9055 -ne `wc -c <'cie/cie-mouse.el'`; then
  759.     echo shar: \"'cie/cie-mouse.el'\" unpacked with wrong size!
  760.   fi
  761.   # end of 'cie/cie-mouse.el'
  762. fi
  763. if test -f 'cie/cie.el' -a "${1}" != "-c" ; then 
  764.   echo shar: Will not clobber existing file \"'cie/cie.el'\"
  765. else
  766.   echo shar: Extracting \"'cie/cie.el'\" \(1529 characters\)
  767.   sed "s/^X//" >'cie/cie.el' <<'END_OF_FILE'
  768. X;;; Example Settings for CIE (c++_in_emacs) package
  769. X;;; Put desirable ones in your default.el, or simply load this file.
  770. X
  771. X
  772. X;;; You should add the following settings to your .emacs,
  773. X;;; modified as appropriate (esp. if you use save-tags-completion-alist)
  774. X;
  775. X;(setq tags-file-name "~/project/TAGS")
  776. X;(setq hier-file-name "~/project/CLASS.hier")
  777. X
  778. X
  779. X;;;===== Goto-File
  780. X(global-set-key "\C-c\C-f" 'goto-file)
  781. X(autoload 'goto-file "goto-file" 
  782. X      "Goto file (and line number or pattern) named at point." t)
  783. X
  784. X
  785. X;;;===== Hierarchy Mode (for .hier files created by hier++)
  786. X
  787. X(autoload 'hier-mode          "hier-mode" "Mode for viewing hierarchies generated by hier++." t)
  788. X
  789. X(setq auto-mode-alist (cons (cons "\\.hier$" 'hier-mode) auto-mode-alist))
  790. X
  791. X;;; add these functions to C++-mode keys
  792. X
  793. X(autoload 'class-hierarchy    "hier-mode" "Display the hierarchy for the given class."  t)
  794. X(autoload 'class-members      "hier-mode" "Display all members for the given class."    t)
  795. X(autoload 'class-data-members "hier-mode" "Display data members for the given class."   t)
  796. X
  797. X(setq c++-mode-hook 
  798. X      '(lambda ()
  799. X     (define-key c++-mode-map "\C-ch" 'class-hierarchy)
  800. X     (define-key c++-mode-map "\C-cm" 'class-members)
  801. X     (define-key c++-mode-map "\C-cd" 'class-data-members)))
  802. X
  803. X
  804. X;;;===== Minibuffer Yank (yank in the default)
  805. X
  806. X(autoload 'minibuffer-yank "minibuffer-yank" "Utility to yank in defaults." t)
  807. X
  808. X(define-key minibuffer-local-completion-map "\C-c\C-y" 'minibuffer-yank)
  809. X(define-key minibuffer-local-must-match-map "\C-c\C-y" 'minibuffer-yank)
  810. END_OF_FILE
  811.   if test 1529 -ne `wc -c <'cie/cie.el'`; then
  812.     echo shar: \"'cie/cie.el'\" unpacked with wrong size!
  813.   fi
  814.   # end of 'cie/cie.el'
  815. fi
  816. if test -f 'cie/class-manual.el' -a "${1}" != "-c" ; then 
  817.   echo shar: Will not clobber existing file \"'cie/class-manual.el'\"
  818. else
  819.   echo shar: Extracting \"'cie/class-manual.el'\" \(8751 characters\)
  820.   sed "s/^X//" >'cie/class-manual.el' <<'END_OF_FILE'
  821. X;;; class-manual.el
  822. X;;; Class Manual Generation
  823. X;;;   Code to use hier-mode (for hierarchies output by hier++) and etags++
  824. X;;;   functionality to build a class manual using the header comments in 
  825. X;;;   the code itself.  The formatting is in standard texinfo.
  826. X;;;   This is a hack that has been helpful for us, given our coding 
  827. X;;;   guidelines.  It will likely need modification to produce good
  828. X;;;   output for you.  (Header comments are those placed between the 
  829. X;;;   signature and the body of functions or classes.  If you don't follow
  830. X;;;   this convention, then this code will need modification.)
  831. X
  832. X;;; Copyright (C) 1993, Intellection Inc.
  833. X;;;
  834. X;;; Author: Brian M Kennedy (kennedy@intellection.com)
  835. X;;;
  836. X;;; This program is free software; you can redistribute it and/or modify
  837. X;;; it under the terms of the GNU General Public License as published by
  838. X;;; the Free Software Foundation; either version 1, or (at your option)
  839. X;;; any later version.
  840. X;;;
  841. X;;; This program is distributed in the hope that it will be useful,
  842. X;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  843. X;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  844. X;;; GNU General Public License for more details.
  845. X;;;
  846. X;;; A copy of the GNU General Public License can be obtained from the
  847. X;;; Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  848. X
  849. X;;; 92/09     Brian M Kennedy  Original 
  850. X
  851. X(provide 'class-manual)
  852. X(require 'hier-mode)
  853. X
  854. X
  855. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  856. X;; Manual Generation
  857. X
  858. X(defvar class-manual-copyright-string "1992 Intellection, Inc."
  859. X  "The desired copyright string to be put on the title page entry 
  860. X   generated by hier-insert-header.")
  861. X
  862. X
  863. X(defun insert-class-manual-header (title)
  864. X  "Insert the leading texinfo header necessary to for the other
  865. X   insert-class-manual- commands."
  866. X  (interactive "sTitle for document: ")
  867. X  (insert "\\input texinfo    @c -*-texinfo-*-" ?\n
  868. X      "@comment %**start of header" ?\n
  869. X      "@settitle " title ?\n
  870. X      "@setchapternewpage off" ?\n
  871. X      "@comment %**end of header" ?\n
  872. X      "" ?\n
  873. X      "@titlepage" ?\n
  874. X      "@sp 8" ?\n
  875. X      "@center @titlefont{" title "}" ?\n
  876. X      "" ?\n
  877. X      "@vskip 0pt plus 1filll" ?\n
  878. X      "@center Class Manual generated via hier++ on " (current-time-string) ?\n
  879. X      "@center Copyright @copyright{} " class-manual-copyright-string ?\n
  880. X      "@end titlepage" ?\n)
  881. X  )
  882. X
  883. X
  884. X(defun insert-all-class-manual-entries (only-if-commented-p members-p)
  885. X  "For every class in the named hier++ generated hierarchy file, in 
  886. X   alphabetic order, call hier-insert-class-entry to insert a manual
  887. X   entry about the class into the current buffer."
  888. X  (interactive (list (y-or-n-p "Generate entries only if commented? ")
  889. X             (y-or-n-p "Generate entries for class members? ") ))
  890. X  (if (not hier-file-name)
  891. X      (prompt-for-hier-file-name))
  892. X  (let (class-list)
  893. X    (save-excursion
  894. X      (message "Collecting class names...")
  895. X      (find-file hier-file-name)
  896. X      (goto-char (point-min))
  897. X      (while (search-forward "* " nil t)
  898. X    (setq class-list
  899. X          (add-unique-string (buffer-substring (point) 
  900. X                           (progn (while (looking-at "\\sw\\|\\s_")
  901. X                                (forward-char 1))
  902. X                              (point)))
  903. X                 class-list) ) ) )
  904. X    (insert "@chapter Classes Descriptions" ?\n)
  905. X    (while class-list
  906. X      (insert-class-manual-entry (car class-list) only-if-commented-p members-p)
  907. X      (setq class-list (cdr class-list)) ) ) )
  908. X
  909. X
  910. X(defun insert-class-manual-entry (class-name only-if-commented-p members-p)
  911. X  "Insert manual entry for given class into current buffer at point.
  912. X   It will contain the class name, a list of its direct base classes,
  913. X   a list of its direct descendants, a description, and a list of 
  914. X   entries for each of its members."
  915. X  (interactive (list (prompt-for-tag "Insert manual entry for class: ")
  916. X             (y-or-n-p "Generate entries only if commented? ")
  917. X             (y-or-n-p "Generate entries for class members? ") ))
  918. X  (if (not hier-file-name)
  919. X      (prompt-for-hier-file-name))
  920. X  (message "Generating manual entry for %s..." class-name)
  921. X
  922. X  (let (base-list derived-list comments)
  923. X    ;; collect class info
  924. X    (save-excursion
  925. X      (find-file hier-file-name)
  926. X      (hier-find class-name)
  927. X      (setq base-list (sort (hier-base-list) 'string<))
  928. X      (setq derived-list (sort (hier-derived-list) 'string<))
  929. X      (if (find-tag-if-present class-name) 
  930. X      (let ((end (save-excursion (re-search-forward "^[^/\n]*\\(;\\|{\\)" nil t) (point))))
  931. X        (while (search-forward "//" end t)
  932. X          (if (looking-at " ") (forward-char 1))
  933. X          (setq comments (concat comments "\n"
  934. X                     (buffer-substring (point)
  935. X                               (progn (end-of-line) (point)) ) )) ) 
  936. X        ) ) )
  937. X    ;; print class info 
  938. X    (if (or comments (not only-if-commented-p))
  939. X    (progn
  940. X      (insert ?\n ?\n ?\n "@section " class-name ?\n)
  941. X  
  942. X      (insert ?\n ?\n "@subsection Immediate Class Hierarchy" ?\n)
  943. X      ;; Base Classes
  944. X      (insert "The class " class-name " has ")
  945. X      (if (not base-list)
  946. X          (insert "no base classes." ?\n)
  947. X        (let ((num (length base-list)))
  948. X          (insert (int-to-string num) 
  949. X              (if (> num 1) " base classes:  " " base class:  ") 
  950. X              (car base-list) ) )
  951. X        (while (setq base-list (cdr base-list))
  952. X          (insert (if (cdr base-list) ", " ", and ") (car base-list)) ) 
  953. X        (insert "." ?\n) )
  954. X      ;; Derived Classes
  955. X      (insert "The class " class-name " has ")
  956. X      (if (not derived-list)
  957. X          (insert "no derived classes." ?\n)
  958. X        (let ((num (length derived-list)))
  959. X          (insert (int-to-string num) 
  960. X              (if (> num 1) " derived classes:  " " derived class:  ") 
  961. X              (car derived-list) ) )
  962. X        (while (setq derived-list (cdr derived-list))
  963. X          (insert (if (cdr derived-list) ", " ", and ") (car derived-list)) ) 
  964. X        (insert "." ?\n) )
  965. X      ;; Comment-based Description
  966. X      (insert ?\n ?\n "@subsection Description" ?\n
  967. X          ?\n (if comments (texify comments) "[No class comments found.]") ?\n)
  968. X      ;; Members
  969. X      (if members-p
  970. X          (let (member-list)
  971. X        ;; collect members
  972. X        (save-excursion
  973. X          (visit-tags-table-buffer)
  974. X          (while (search-forward (concat "\C-a" class-name "::") nil t)
  975. X            (skip-chars-backward "^\C-a")
  976. X            (setq member-list 
  977. X              (add-unique-string (buffer-substring (point)
  978. X                                   (progn (end-of-line) (point))) 
  979. X                         member-list))
  980. X            (forward-line 1) ))
  981. X        ;; print members
  982. X        (insert ?\n ?\n "@subsection Members" ?\n)
  983. X        (while member-list
  984. X          (insert-member-manual-entry (car member-list) only-if-commented-p)
  985. X          (setq member-list (cdr member-list)) )
  986. X        ) )
  987. X      )
  988. X      )
  989. X    )
  990. X  )
  991. X
  992. X
  993. X(defun insert-member-manual-entry (tag only-if-commented-p)
  994. X  "Insert the member description for class member `tag`."
  995. X  (interactive (list (prompt-for-tag "Insert manual entry for member: ")))
  996. X  (let (entry comments)
  997. X    ;; collect info
  998. X    (save-excursion
  999. X       (if (find-tag-if-present tag) 
  1000. X       (let ((start (save-excursion 
  1001. X              (re-search-backward "^[ \t\f]*$\\|;\\|{\\|}" nil t) 
  1002. X              (forward-line 1)
  1003. X              (point)))
  1004. X         (h-end (save-excursion 
  1005. X              (re-search-forward "^[ \t\f]*$\\|)\\|;\\|^[ \t]*:\\|{\\|}" nil t) 
  1006. X              (skip-chars-backward ":{;")
  1007. X              (point))) 
  1008. X         (c-end (save-excursion 
  1009. X              (re-search-forward "^[^/\n]*\\(;\\|{\\|}\\)" nil t) (point))) )
  1010. X         (setq entry (buffer-substring start h-end)) 
  1011. X         (while (search-forward "//" c-end t)
  1012. X           (if (looking-at " ") (forward-char 1))
  1013. X           (setq comments (concat comments "\n"
  1014. X                      (buffer-substring (point)
  1015. X                            (progn (end-of-line) (point)) ) )) )
  1016. X         ) ) )
  1017. X    ;; print info
  1018. X    (if (or comments (not only-if-commented-p))
  1019. X    (insert ?\n "@example" ?\n
  1020. X        (if entry entry "[This tag not found.]") ?\n
  1021. X        "@end example" ?\n
  1022. X        ?\n (if comments (texify comments) "[No comments found.]") ?\n) )
  1023. X    )
  1024. X  )
  1025. X
  1026. X
  1027. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1028. X;; Internal Functions
  1029. X
  1030. X(defun add-unique-string (string list)
  1031. X  "Add `string` into `list` in alphabetic order, 
  1032. X   only if `string` is not already in `list`.
  1033. X   Assumes that `list` is a sorted list of strings."
  1034. X  (if (or (not list) (string-lessp string (car list)))
  1035. X      (cons string list)
  1036. X    (let ((prev list))
  1037. X      (while (and (cdr prev) (string< (car (cdr prev)) string))
  1038. X    (setq prev (cdr prev)))
  1039. X      (if (or (not (cdr prev)) (not (string= (car (cdr prev)) string)))
  1040. X      (setcdr prev (cons string (cdr prev))) )
  1041. X      list)
  1042. X    )
  1043. X  )
  1044. X
  1045. X
  1046. X(defun find-tag-if-present (tagname &optional next other-window)
  1047. X  "Do find-tag with args.  If no error, return t; otherwise return nil."
  1048. X  (condition-case signals
  1049. X      (progn (find-tag tagname next other-window)
  1050. X         t)
  1051. X    (error nil) ) )
  1052. X
  1053. X
  1054. X(defun texify (string)
  1055. X  "Return string with TeX special chars @, {, } changed to spaces."
  1056. X  (let ((pos 0))
  1057. X    (while pos
  1058. X      (setq pos (string-match "{\\|}\\|@\\|\\\\" string pos))
  1059. X      (if pos (aset string pos ? )) ) 
  1060. X    string) )
  1061. END_OF_FILE
  1062.   if test 8751 -ne `wc -c <'cie/class-manual.el'`; then
  1063.     echo shar: \"'cie/class-manual.el'\" unpacked with wrong size!
  1064.   fi
  1065.   # end of 'cie/class-manual.el'
  1066. fi
  1067. if test -f 'cie/do-etags++' -a "${1}" != "-c" ; then 
  1068.   echo shar: Will not clobber existing file \"'cie/do-etags++'\"
  1069. else
  1070.   echo shar: Extracting \"'cie/do-etags++'\" \(1252 characters\)
  1071.   sed "s/^X//" >'cie/do-etags++' <<'END_OF_FILE'
  1072. X#!/usr/local/bin/bash
  1073. X#
  1074. X# THIS IS JUST AN EXAMPLE.
  1075. X# IT IS HIGHLY UNLIKELY THAT THIS IS USEFUL, AS-IS, FOR ANYONE.
  1076. X#
  1077. X# do-etags++
  1078. X#
  1079. X# This is an example of using etags++, hier++, and emacs in batch mode
  1080. X# to save out the tags-completion-alist in TAGS.alist.
  1081. X#
  1082. X# 1) Goes to my code directory (where TAGS should be created)
  1083. X# 2) Runs etags++ on all my source (.c files first so that M-. finds
  1084. X#    the definitions before the declarations)
  1085. X# 3) Loads up an Emacs with the tags just generated (depends upon $USER's
  1086. X#    .emacs having (setq tags-file-name "~/project/TAGS")) and writes out
  1087. X#    a TAGS.alist file, so successive Emacs' don't have to rebuild the alist.
  1088. X#
  1089. X# This is run automatically during my night-build.
  1090. X
  1091. Xpushd $HOME/project
  1092. X
  1093. Xetags++ tools/*/*.c \
  1094. X        tools/*/*.h  \
  1095. X        tools/roguewave/toolsrc/*.c \
  1096. X        tools/roguewave/rw/*.h \
  1097. X        rhythm/*/*.c \
  1098. X        rhythm/*/*.h
  1099. X
  1100. Xemacs -batch -u $USER -load tags -f save-tags-completion-alist
  1101. X# Assumes that -u $USER's .emacs specifies the appropriate TAGS file
  1102. X# such that -load tags builds the appropriate tags-completion-alist
  1103. X# such that -f save-tags-completion-alist has something to save out.
  1104. X
  1105. Xhier++  tools/*/*.h  \
  1106. X        tools/roguewave/rw/*.h \
  1107. X        rhythm/*/*.h
  1108. X
  1109. Xpopd
  1110. END_OF_FILE
  1111.   if test 1252 -ne `wc -c <'cie/do-etags++'`; then
  1112.     echo shar: \"'cie/do-etags++'\" unpacked with wrong size!
  1113.   fi
  1114.   chmod +x 'cie/do-etags++'
  1115.   # end of 'cie/do-etags++'
  1116. fi
  1117. if test -f 'cie/etags++/Makefile' -a "${1}" != "-c" ; then 
  1118.   echo shar: Will not clobber existing file \"'cie/etags++/Makefile'\"
  1119. else
  1120.   echo shar: Extracting \"'cie/etags++/Makefile'\" \(216 characters\)
  1121.   sed "s/^X//" >'cie/etags++/Makefile' <<'END_OF_FILE'
  1122. XBINS=etags++ hier++
  1123. X
  1124. XCC=CC
  1125. XCCFLAGS=-O
  1126. X
  1127. Xall:: $(BINS)
  1128. X
  1129. Xetags++: etags++.c c++file.c
  1130. X    $(CC) $(CCFLAGS) -o etags++ etags++.c
  1131. X
  1132. Xhier++: hier++.c c++file.c
  1133. X    $(CC) $(CCFLAGS) -o hier++  hier++.c
  1134. X
  1135. Xclean:
  1136. X    -rm -f $(BINS) *.o
  1137. END_OF_FILE
  1138.   if test 216 -ne `wc -c <'cie/etags++/Makefile'`; then
  1139.     echo shar: \"'cie/etags++/Makefile'\" unpacked with wrong size!
  1140.   fi
  1141.   # end of 'cie/etags++/Makefile'
  1142. fi
  1143. if test -f 'cie/etags++/hier++.c' -a "${1}" != "-c" ; then 
  1144.   echo shar: Will not clobber existing file \"'cie/etags++/hier++.c'\"
  1145. else
  1146.   echo shar: Extracting \"'cie/etags++/hier++.c'\" \(8876 characters\)
  1147.   sed "s/^X//" >'cie/etags++/hier++.c' <<'END_OF_FILE'
  1148. X////////////////////////////////////////////////////////////////////////////////
  1149. X// hier++.c
  1150. X//
  1151. X// This program reads in C++ code and generates a "hier" file that displays the
  1152. X// class hierarchy.  You can then use the GNU Emacs hier-mode for traversing the
  1153. X// hierarchy and extracting information from your TAGS (if generated by etags++).
  1154. X//
  1155. X// Note that this program is built on the same quick-and-dirty "fuzzy" parser
  1156. X// that etags++ was, and will suffer the same ability to be fooled sometimes.
  1157. X//
  1158. X// Author:  Brian M. Kennedy
  1159. X// (C) Copyright 1993, Intellection Inc.
  1160. X// Permission is granted to use, copy, or modify this code as long as this author and
  1161. X// copyright notice is maintained in all copies.
  1162. X//
  1163. X// Note:
  1164. X//   This is quick, hack code that was not written to be modifiable or maintainable -- beware!!
  1165. X//   I would not allow code such as this into our product!  But it is okay for a quick tool hack.
  1166. X//   If you are a user, I hope you enjoy it.  If you are modifier, my apologies ;-(
  1167. X
  1168. X#include "c++file.c"
  1169. X
  1170. X
  1171. X////////////////////////////////////////////////////////////////////////////////
  1172. X
  1173. Xstruct Element;
  1174. X
  1175. Xstruct Element_Link
  1176. X{
  1177. X  Element*      element;
  1178. X  Element_Link* next;
  1179. X
  1180. X  Element_Link (Element* element_arg, Element_Link* next_arg = 0);
  1181. X  
  1182. X};
  1183. X
  1184. X
  1185. XElement_Link::
  1186. XElement_Link (Element* element_arg, Element_Link* next_arg)
  1187. X:element(element_arg), next(next_arg)
  1188. X{}
  1189. X
  1190. X  
  1191. X////////////////////////////////////////////////////////////////////////////////
  1192. X
  1193. Xstruct Element
  1194. X{
  1195. X  const char*    name;
  1196. X  Element_Link*  parents;
  1197. X  Element_Link*  children;
  1198. X
  1199. X  Element (const C_File_Pos& name_pos);
  1200. X
  1201. X  static unsigned hash (const C_File_Pos& name);
  1202. X  unsigned hash () const;
  1203. X  
  1204. X  Element_Link* inc_parents  (Element* parent)
  1205. X  { return parents  = new Element_Link(parent, parents); }
  1206. X  
  1207. X  Element_Link* inc_children (Element* child)
  1208. X  { return children = new Element_Link(child, children); }
  1209. X
  1210. X  void print (ostream& os, unsigned indent) const;
  1211. X  
  1212. X};
  1213. X
  1214. X
  1215. XElement::
  1216. XElement (const C_File_Pos& name_pos)
  1217. X:name(0), parents(0), children(0)
  1218. X{
  1219. X  char* copy = new char [name_pos.length + 1];
  1220. X  strncpy(copy, name_pos.chars(), name_pos.length);
  1221. X  copy[name_pos.length] = 0;
  1222. X  name = copy;
  1223. X}
  1224. X
  1225. X
  1226. Xunsigned Element::
  1227. Xhash (const C_File_Pos& name)
  1228. X{
  1229. X  unsigned h = 0;
  1230. X  const char* s = name.chars();
  1231. X  for(unsigned i = 0; i < name.length; ++i, ++s)
  1232. X    h = (h << 2) + (unsigned char)(*s);
  1233. X  return h;
  1234. X}
  1235. X
  1236. X
  1237. Xunsigned Element::
  1238. Xhash () const
  1239. X{
  1240. X  unsigned h = 0;
  1241. X  for(const char* s = name; *s; ++s)
  1242. X    h = (h << 2) + (unsigned char)(*s);
  1243. X  return h;
  1244. X}
  1245. X
  1246. X
  1247. Xconst char blank_string [] = "                                        ";
  1248. X
  1249. Xinline const char*
  1250. Xblanks (unsigned n)
  1251. X    // Returns a string of 'n' blanks
  1252. X{  return blank_string + sizeof(blank_string) - n - 1; }
  1253. X
  1254. X
  1255. Xvoid Element::
  1256. Xprint (ostream& os, unsigned indent) const
  1257. X{
  1258. X  os << blanks(indent) << "* " << name << " ";
  1259. X  
  1260. X  for(Element_Link* link = parents; link; link = link->next)
  1261. X    os << " :" << link->element->name;
  1262. X  os << "\n";
  1263. X  
  1264. X  for(link = children; link; link = link->next)
  1265. X    link->element->print(os, indent+2);
  1266. X}
  1267. X
  1268. X    
  1269. X////////////////////////////////////////////////////////////////////////////////
  1270. X
  1271. Xstruct Hierarchy
  1272. X{
  1273. X  unsigned       size;
  1274. X  Element_Link** table;
  1275. X
  1276. X  Hierarchy (unsigned symbols);
  1277. X
  1278. X  Element* operator () (const C_File_Pos& name) const;
  1279. X  
  1280. X  Hierarchy& inc (Element* element);
  1281. X  Hierarchy& inc (const C_File_Pos& name) { return inc(new Element(name)); }
  1282. X
  1283. X  void print (ostream& os);
  1284. X
  1285. X};
  1286. X
  1287. X
  1288. XHierarchy::
  1289. XHierarchy (unsigned symbols)
  1290. X:size(2*symbols + 1), table(new Element_Link* [size])
  1291. X{
  1292. X  for(unsigned i = 0; i < size; ++i)
  1293. X    table[i] = 0;
  1294. X}
  1295. X
  1296. X
  1297. XElement* Hierarchy::
  1298. Xoperator () (const C_File_Pos& name) const
  1299. X{
  1300. X  unsigned index = Element::hash(name) % size;
  1301. X  Element_Link* link = table[index];
  1302. X  while(link && ((strlen(link->element->name) != name.length)
  1303. X         || strncmp(link->element->name, name.chars(), name.length)))
  1304. X    link = link->next;
  1305. X  if(link)
  1306. X    return link->element;
  1307. X  else
  1308. X  { table[index] = new Element_Link(new Element (name), table[index]);
  1309. X    return table[index]->element;
  1310. X  }
  1311. X}
  1312. X
  1313. X
  1314. XHierarchy& Hierarchy::
  1315. Xinc (Element* element)
  1316. X{
  1317. X  unsigned index = element->hash() % size;
  1318. X  table[index] = new Element_Link(element, table[index]);
  1319. X  return *this;
  1320. X}
  1321. X
  1322. X
  1323. Xvoid Hierarchy::
  1324. Xprint (ostream& os)
  1325. X{
  1326. X  for(unsigned index = 0; index < size; ++index)
  1327. X  { for(Element_Link* link = table[index]; link; link = link->next)
  1328. X    { if(!link->element->parents)
  1329. X    link->element->print(os, 0);
  1330. X    }
  1331. X  }
  1332. X}
  1333. X
  1334. X
  1335. X////////////////////////////////////////////////////////////////////////////////
  1336. X
  1337. Xinline void
  1338. Xparent_child (Element* parent, Element* child)
  1339. X{
  1340. X  parent->inc_children(child);
  1341. X  child->inc_parents(parent);
  1342. X}
  1343. X
  1344. X
  1345. XBoolean
  1346. Xaccess_kw_p (const C_File_Pos& name)
  1347. X{
  1348. X  const char* s = name.chars();
  1349. X  if(*s == 'p')
  1350. X  {
  1351. X    switch(name.length)
  1352. X    {
  1353. X    case 6:  return !strncmp(s, "public",    6);
  1354. X    case 7:  return !strncmp(s, "private",   7) ;
  1355. X    case 9:  return !strncmp(s, "protected", 9);
  1356. X    default: return FALSE;
  1357. X    }
  1358. X  }
  1359. X  else if (*s == 'v')
  1360. X  {
  1361. X    switch(name.length)
  1362. X    {
  1363. X    case 7:  return !strncmp(s, "virtual",   7) ;
  1364. X    default: return FALSE;
  1365. X    }
  1366. X  }
  1367. X  else
  1368. X    return FALSE;
  1369. X}
  1370. X
  1371. X
  1372. X////////////////////////////////////////////////////////////////////////////////
  1373. X
  1374. XHierarchy&
  1375. Xget_class_hier (Hierarchy& hier, const File& file)
  1376. X{
  1377. X  C_File_Pos pos (file);
  1378. X  while(pos.token != END_OF_FILE)
  1379. X  {
  1380. X    switch(pos.token)
  1381. X    {
  1382. X    case CLASS_KW:
  1383. X    case STRUCT_KW:
  1384. X      pos.next_code();
  1385. X      if(pos.token == IDENTIFIER)
  1386. X      { Element* child = hier(pos);
  1387. X    pos.next_code();
  1388. X    while(pos.token != SEMI_COLON && pos.token != OPEN_BRACE && pos.token != END_OF_FILE)
  1389. X    {
  1390. X      if(pos.token == IDENTIFIER && !access_kw_p(pos))
  1391. X      { Element* parent = hier(pos);
  1392. X        parent_child(parent, child);
  1393. X      }
  1394. X      pos.next_code();
  1395. X    }
  1396. X      }
  1397. X      else
  1398. X      { while(pos.token != SEMI_COLON && pos.token != OPEN_BRACE && pos.token != END_OF_FILE)
  1399. X      pos.next_code();
  1400. X      }
  1401. X      if(pos.token == OPEN_BRACE)
  1402. X    pos.close_brace();
  1403. X      break;
  1404. X    case UNION_KW:
  1405. X    case ENUM_KW:
  1406. X      pos.next_code();
  1407. X      while(pos.token != SEMI_COLON && pos.token != OPEN_BRACE && pos.token != END_OF_FILE)
  1408. X    pos.next_code();
  1409. X      if(pos.token == OPEN_BRACE)
  1410. X    pos.close_brace();
  1411. X      break;
  1412. X    case TYPEDEF_KW:        // only catches last typedef (e.g 'c' in typedef int a, b, c;)
  1413. X      pos.next_code();
  1414. X      while(pos.token != SEMI_COLON && pos.token != END_OF_FILE)
  1415. X    pos.next_code();
  1416. X      break;
  1417. X    case DEFINE:
  1418. X      pos.close_define();
  1419. X      break;
  1420. X    case OPEN_BRACE:
  1421. X      pos.close_brace();
  1422. X      break;
  1423. X    case OPEN_PARE:
  1424. X      pos.close_pare();
  1425. X      break;
  1426. X    }
  1427. X    pos.next_code();
  1428. X  }
  1429. X  return hier;
  1430. X}
  1431. X
  1432. X
  1433. X////////////////////////////////////////////////////////////////////////////////
  1434. X
  1435. Xvoid
  1436. Xusage_error (const char* progname)
  1437. X{ cerr << "Usage " << progname;
  1438. X  cerr << " [-a] [-f outfile] [-s num_symbols] [-k max_infile_kbytes] infile ...";
  1439. X  cerr << endl;
  1440. X  exit(BAD);
  1441. X}
  1442. X
  1443. X
  1444. Xmain (int argc, char** argv)
  1445. X{
  1446. X  unsigned argi = 0;
  1447. X  char* progname = argv[argi];
  1448. X  
  1449. X  // Default flags
  1450. X  Boolean     append     = FALSE;
  1451. X  const char* outfile    = 0;
  1452. X  int         size       = 1024;
  1453. X  int         symbols    = 2000;
  1454. X  
  1455. X  // Process flags
  1456. X  for(argi = 1; argi < argc && argv[argi][0] == '-'; ++argi)
  1457. X  {
  1458. X    switch(argv[argi][0])
  1459. X    {
  1460. X    case '?':
  1461. X    case 'h':
  1462. X      usage_error(progname);
  1463. X    case 'a':
  1464. X      append = TRUE;
  1465. X      break;
  1466. X    case 'f':
  1467. X      if(outfile)
  1468. X      { cerr << "The -f option may only be given once." << endl;
  1469. X    usage_error(progname);
  1470. X      }
  1471. X      if(argv[argi][1])
  1472. X    outfile = &argv[argi][1];
  1473. X      else if(argi < argc)
  1474. X    outfile = argv[++argi];
  1475. X      else
  1476. X      { cerr << "The -f option must be given an argument (the outfile name)" << endl;
  1477. X    usage_error(progname);
  1478. X      }
  1479. X      break;
  1480. X    case 'k':
  1481. X      if(argv[argi][1])
  1482. X    size = atoi(&argv[argi][1]);
  1483. X      else if(argi < argc)
  1484. X    size = atoi(argv[++argi]);
  1485. X      else
  1486. X      { cerr << "The -k option must be given an argument (the max_file_size in kbytes)" << endl;
  1487. X    usage_error(progname);
  1488. X      }
  1489. X      break;
  1490. X    case 's':
  1491. X      if(argv[argi][1])
  1492. X    symbols = atoi(&argv[argi][1]);
  1493. X      else if(argi < argc)
  1494. X    symbols = atoi(argv[++argi]);
  1495. X      else
  1496. X      { cerr << "The -s option must be given an argument (the expected number of symbols)" << endl;
  1497. X    usage_error(progname);
  1498. X      }
  1499. X      break;
  1500. X    default:
  1501. X      ;
  1502. X    }
  1503. X  }
  1504. X  
  1505. X  // Arg value checks
  1506. X  if(size < 64)
  1507. X    size = 64;
  1508. X  if(symbols < 1000)
  1509. X    symbols = 1000;
  1510. X  if(!outfile)
  1511. X    outfile = "CLASS.hier";
  1512. X  
  1513. X  // Create File for input
  1514. X  File infile (size*1024);
  1515. X
  1516. X  // Create empty hierarchy
  1517. X  Hierarchy hier (symbols);
  1518. X  
  1519. X  // Process files into hier
  1520. X  for(; argi < argc; ++argi)
  1521. X  {
  1522. X    infile.read(argv[argi]);
  1523. X    get_class_hier(hier, infile);
  1524. X  }
  1525. X
  1526. X  // Output hierarchy
  1527. X  ofstream out (outfile, (append ? ios::app : ios::out));
  1528. X  hier.print(out);
  1529. X  out << flush;
  1530. X
  1531. X  exit(GOOD);
  1532. X}
  1533. END_OF_FILE
  1534.   if test 8876 -ne `wc -c <'cie/etags++/hier++.c'`; then
  1535.     echo shar: \"'cie/etags++/hier++.c'\" unpacked with wrong size!
  1536.   fi
  1537.   # end of 'cie/etags++/hier++.c'
  1538. fi
  1539. if test -f 'cie/goto-file.el' -a "${1}" != "-c" ; then 
  1540.   echo shar: Will not clobber existing file \"'cie/goto-file.el'\"
  1541. else
  1542.   echo shar: Extracting \"'cie/goto-file.el'\" \(5953 characters\)
  1543.   sed "s/^X//" >'cie/goto-file.el' <<'END_OF_FILE'
  1544. X;;; goto-file.el
  1545. X
  1546. X;;; By binding goto-file to a key or mouse stroke, you can essentially
  1547. X;;; make filenames "hot"; it will attempt to find that file in the 
  1548. X;;; current buffer's default directory.  If no such file exists, then 
  1549. X;;; it checks the current tags-table, gambling that it is one of your
  1550. X;;; source files and will be tagged.
  1551. X;;;
  1552. X;;; Furthermore, it will try to go to the right location in the file.
  1553. X;;; If there is an adjacent line number, then it will go to that line.
  1554. X;;; Or if there is an adjacent grep pattern, then it will find that pattern.
  1555. X;;;
  1556. X;;; For instance, if you are in a shell and do an "ls", you can then click on
  1557. X;;; any file name to open the file.  If you do a "make", you can click on any
  1558. X;;; error msg to take you to the line of the error.  If you are in dbx, and it
  1559. X;;; outputs a break or an assert outputs file/line, then you can simply click
  1560. X;;; on the filename to take you to the line.  If you do a "grep", then you
  1561. X;;; can simply click on the filename of the match that you want to go to.
  1562. X;;; IMO, this is preferable to M-x compile or grep, because there is no need
  1563. X;;; to proceed in order.  It also works everywhere: in source files, in
  1564. X;;; shells, in night build logs, in mail buffers, etc.
  1565. X
  1566. X;;; Copyright (C) 1993, Intellection Inc.
  1567. X;;;
  1568. X;;; Author: Brian M Kennedy (kennedy@intellection.com)
  1569. X;;;
  1570. X;;; This program is free software; you can redistribute it and/or modify
  1571. X;;; it under the terms of the GNU General Public License as published by
  1572. X;;; the Free Software Foundation; either version 1, or (at your option)
  1573. X;;; any later version.
  1574. X;;;
  1575. X;;; This program is distributed in the hope that it will be useful,
  1576. X;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  1577. X;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1578. X;;; GNU General Public License for more details.
  1579. X;;;
  1580. X;;; A copy of the GNU General Public License can be obtained from the
  1581. X;;; Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1582. X
  1583. X;;; 92/07/23  Brian M Kennedy  Original
  1584. X
  1585. X(provide 'goto-file)
  1586. X
  1587. X(require 'tags)
  1588. X
  1589. X
  1590. X(defvar goto-file-chars "-A-Za-z./_=+~#0-9"
  1591. X  "Characters that goto-file considers part of a filename.
  1592. X   Intentionally does not include (by default) ,:<> and quotes because
  1593. X   these are more often delimiters than part of the filename.")
  1594. X
  1595. X(defvar goto-file-other-window-p t
  1596. X  "When non-nil, goto new file in other window.")
  1597. X
  1598. X(defun goto-file (&optional dont-use-tags-p)
  1599. X  "Attempts to identify a filename at or around point.  If it finds one,
  1600. X   then it attempts to find a line number of the form 'line nn' on the 
  1601. X   same line as the filename.  If there is no line number, then it checks
  1602. X   if the filename was followed by a colon.  If so, it assumes it is a 
  1603. X   grep-style pattern that was matched in the file.
  1604. X   It then tries to find a file by that filename in the current-dirctory.
  1605. X   If there is none and the optional argument is nil, then it attempts to
  1606. X   identify a file that has been tagged with the same name in order to get a
  1607. X   full pathname.
  1608. X   If it finds a file (either way), then it opens it in another window.
  1609. X   If there was line number information, then it will goto that line.
  1610. X   If not, and there was a grep-style pattern, then it searches for that
  1611. X   pattern in the file (and sets it up so that you can search for additional
  1612. X   matches via incremental search)."
  1613. X  (interactive "P")
  1614. X  (let ((filename nil)
  1615. X    (basename nil)
  1616. X    (file     nil)
  1617. X    (line     nil)
  1618. X    (pattern  nil))
  1619. X    (save-excursion
  1620. X      ;; Get filename
  1621. X      (skip-chars-backward goto-file-chars)
  1622. X      (let (start-point base-point end-point)
  1623. X    (setq start-point (point))
  1624. X    (skip-chars-forward "./~")  ;; strip leading context info for tagfile lookup
  1625. X    (setq base-point (point))
  1626. X    (skip-chars-forward goto-file-chars)
  1627. X    (setq end-point (point))
  1628. X    (setq filename (buffer-substring start-point end-point))
  1629. X    (setq basename (buffer-substring base-point end-point)) )
  1630. X      ;; Get pattern
  1631. X      (if (looking-at ":")
  1632. X      (progn (forward-char 1)
  1633. X         (setq pattern (buffer-substring (point)
  1634. X                         (progn (end-of-line) (point)))) ))
  1635. X      ;; Get line
  1636. X      (cond ((looking-at "([0-9]+")
  1637. X         (forward-char 1)
  1638. X         (setq line (string-to-int 
  1639. X             (buffer-substring (point)
  1640. X                       (progn (skip-chars-forward "0-9")
  1641. X                          (point) )))) )
  1642. X        ((looking-at ".*line [0-9]")
  1643. X         (re-search-forward ".*line ")
  1644. X         (setq line (string-to-int 
  1645. X             (buffer-substring (point)
  1646. X                       (progn (skip-chars-forward "0-9")
  1647. X                          (point) )))) )
  1648. X        ((re-search-backward "line [0-9]"
  1649. X                 (save-excursion (beginning-of-line) (point))
  1650. X                 t)
  1651. X         (forward-char 5)
  1652. X         (setq line (string-to-int 
  1653. X             (buffer-substring (point)
  1654. X                       (progn (skip-chars-forward "0-9")
  1655. X                          (point) )))) )
  1656. X        ))
  1657. X    ;; Goto the file
  1658. X    (if filename
  1659. X    (let ((fullname (expand-file-name filename)))
  1660. X      (if (and (not dont-use-tags-p)
  1661. X           (not (and fullname (file-exists-p fullname))))
  1662. X          (setq fullname (expand-tagged-file-name basename)))
  1663. X      (if (and fullname (file-exists-p fullname))
  1664. X          (progn
  1665. X        (if goto-file-other-window-p
  1666. X            (find-file-other-window fullname)
  1667. X          (find-file fullname))
  1668. X        (cond (line    (goto-line line))
  1669. X              (pattern (setq search-last-string pattern)
  1670. X                   (goto-char (point-min))
  1671. X                   (search-forward pattern nil t) )
  1672. X              ))
  1673. X        (if dont-use-tags-p
  1674. X        (error "No file named %s is in current directory." filename)
  1675. X          (error "No file named %s is in current or tagged directories." filename)
  1676. X          ) ))
  1677. X      (error "No filename found at point.") )))
  1678. X
  1679. X
  1680. X
  1681. X(defun expand-tagged-file-name (filename)
  1682. X  "Find a tagged file with a name that includes 'filename' in it.
  1683. X   If one is found, return that file's expanded filename.
  1684. X   Otherwise, return nil." 
  1685. X  ;; Find the tagged file
  1686. X  (save-excursion
  1687. X    (visit-tags-table-buffer)
  1688. X    (beginning-of-buffer)
  1689. X    (if (re-search-forward (concat "\f\n\\(.*/\\)?" filename ",") nil t)
  1690. X    (expand-file-name (file-of-tag) (file-name-directory tags-file-name)) )))
  1691. END_OF_FILE
  1692.   if test 5953 -ne `wc -c <'cie/goto-file.el'`; then
  1693.     echo shar: \"'cie/goto-file.el'\" unpacked with wrong size!
  1694.   fi
  1695.   # end of 'cie/goto-file.el'
  1696. fi
  1697. echo shar: End of archive 2 \(of 2\).
  1698. cp /dev/null ark2isdone
  1699. MISSING=""
  1700. for I in 1 2 ; do
  1701.     if test ! -f ark${I}isdone ; then
  1702.     MISSING="${MISSING} ${I}"
  1703.     fi
  1704. done
  1705. if test "${MISSING}" = "" ; then
  1706.     echo You have unpacked both archives.
  1707.     rm -f ark[1-9]isdone
  1708. else
  1709.     echo You still must unpack the following archives:
  1710.     echo "        " ${MISSING}
  1711. fi
  1712. exit 0
  1713. exit 0 # Just in case...
  1714.