home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / emacs / 2687 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  2.7 KB

  1. Xref: sparky comp.emacs:2687 comp.lang.functional:944
  2. Path: sparky!uunet!darwin.sura.net!Sirius.dfn.de!zrz.tu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!uknet!icdoc!news!dbh
  3. From: dbh@doc.ic.ac.uk (Denis Howe)
  4. Newsgroups: comp.emacs,comp.lang.functional
  5. Subject: Re: Emacs TAGS  for haskell / gofer
  6. Message-ID: <DBH.92Jul23150006@wombat.doc.ic.ac.uk>
  7. Date: 23 Jul 92 15:00:06 GMT
  8. References: <1834@miranda>
  9. Sender: usenet@doc.ic.ac.uk
  10. Distribution: eunet
  11. Organization: Computing Department, Imperial College, London, UK
  12. Lines: 57
  13. In-Reply-To: eglen@uk.co.gec-mrc's message of 22 Jul 92 14:12:16 GMT
  14. Nntp-Posting-Host: wombat.doc.ic.ac.uk
  15.  
  16. In article <1834@miranda> eglen@uk.co.gec-mrc (Stephen Eglen) wrote:
  17.  
  18. >I am writing some Haskell code within the emacs editor.  Does anyone
  19. >know of a program that will create a TAGS file, given some haskell files?
  20.  
  21. Your wish is my command :-)
  22. --------8<---------8<-------- CUT HERE --------8<---------8<--------
  23. : fptags 0.01 09-Apr-1992
  24.  
  25. #Create an emacs tags file for functional programs
  26.  
  27. #Please send me a copy of any modifications you make.
  28. #Denis Howe <dbh@doc.ic.ac.uk>
  29. #0.00 20-Sep-1991 created
  30. #0.01 09-Apr-1992 don't count ==, <=, >= as definition
  31.  
  32. #The algorithm for spotting identifiers is crude to the point of
  33. #vulgarity.  Any line containing an = is assumed to define an
  34. #identifier.  If there are no non-white characters before the = then
  35. #the definition is assumed to start on the previous line.  White
  36. #characters are space, tab and > (for literate programs).
  37.  
  38. #The tags file is not in the format produced by ctags but rather,
  39. #that produced by etags and used by GNU-Emacs's find-tag command.
  40.  
  41. #Does not tag constructors in sum data types.
  42.  
  43. #The tags file, TAGS, is created in the current directory.  It
  44. #contains an entry for each argument file.  The entry begins with a
  45. #line containing just ^L.  The next line contains the filename, a
  46. #comma and the number of following bytes before the next ^L or EOF.
  47. #Subsequent lines should give the location within the argument file of
  48. #identifier definitions.  Each line contains a prefix of a line from
  49. #the argument file, a ^?, the line number within the argument file, a
  50. #comma and the position of the start of that line in bytes from the
  51. #start of the argument file.
  52.  
  53. [ -z "$1" ] && echo usage: $0 files && exit 1
  54. exec > TAGS
  55. tf=/tmp/fp$$
  56. for f
  57. do    echo " "
  58.     sed 's/==//g
  59.     s/>=/=/g
  60.     s/<=//g' $f | awk '
  61.     /^[>     ]*\=/{ print prevline "" NR-1 "," prevpos; }
  62.     /[^>     ].*\=/{ print $0 "" NR "," pos; }
  63.     { prevline = $0; prevpos = pos; pos += length($0); }
  64.     ' | sed 's/[     )]*=.*//
  65.     s//=/g' > $tf
  66.     echo -n $f,; echo `wc -c < $tf`        #lose spaces
  67.     cat $tf
  68. done
  69. rm -f $tf
  70. --
  71. Denis Howe <dbh@doc.ic.ac.uk>
  72. Does this question have an answer?
  73.