home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / me34src.zip / me3 / mutt / package / webindex.mut < prev    next >
Text File  |  1995-01-14  |  4KB  |  177 lines

  1. ;; webindex.mut : Indexer for web for ME.
  2. ;; See also: web.mut
  3. ;; C Durland 5/93 Public Domain
  4.  
  5. (include me.mh)
  6.  
  7. ;; Need additional indexes for:
  8. ;;   package.doc
  9.  
  10. (const
  11.   INDEX-BUFFER        "*web-index*"
  12.   INDEX-FILE-NAME    "web.idx"
  13. )
  14.  
  15. (const        ;; Index tags
  16.   ZIP-TAG        "0"
  17.   DOC-TAG        "1"
  18.   PACKAGE-TAG        "2"
  19.  
  20.   MISC-MUTT-CODE    "7"
  21.   MAN-TAGO        "8"
  22. )
  23.  
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;; Create Index ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27.  
  28. ;; Index format:
  29. ;;   =#=file-name=#=tag
  30. ;;   index-entry-in-file
  31. ;;   ...
  32. ;;   <space><key>[<space><key>...]<space>index-entry
  33. ;;   ...
  34. ;; Example:
  35. ;;   =#=me2.doc=#=1
  36. ;;   beginning-of-buffer
  37. ;;   visit-file
  38. ;;    C-a beginning-of-buffer
  39. ;;    C-XC-F C-XC-V visit-file
  40.  
  41. (defun
  42.   make-index
  43.   {
  44.     (int index)
  45.  
  46.     (if (== -2 (index (attached-buffer INDEX-BUFFER)))
  47.     (index (create-buffer INDEX-BUFFER BFHooHum)))
  48.  
  49.     (current-buffer index)(clear-buffer)
  50.  
  51.     (insert-text "=#=regexp.doc=#=" MAN-TAGO)
  52.  
  53.     (process-doc-file "mutt2.doc")
  54.     (process-doc-file "me3mutt.doc")
  55.     (process-doc-file "me3.doc")
  56.     (process-package  "package.doc")
  57.     (process-*Help*)
  58. (current-buffer index TRUE)
  59.   }
  60.   process-doc-file (string fname) HIDDEN
  61.   {
  62.     (int index bf)
  63.     (string item)
  64.  
  65.     (if (not (file-exists fname))
  66.     { (msg "File " fname " doesn't exist.") FALSE (done) })
  67.     (current-buffer (bf (create-buffer "*web-file*" 0)))
  68.     (read-file fname)
  69.  
  70.     (index (attached-buffer INDEX-BUFFER))
  71.     (current-buffer index)(end-of-buffer)
  72.  
  73.     (insert-text "=#=" fname "=#=" DOC-TAG)
  74.  
  75.     (while TRUE
  76.       {
  77.         (current-buffer bf)
  78.     (if (not (re-search-forward '^(\([^     )]+\)')) (break))
  79.  
  80.     (item (get-matched '\1'))
  81.  
  82.     (current-buffer index)
  83.         ;; Don't add duplicates (not that it matters)
  84.     (beginning-of-buffer)
  85.     (if (not (search-forward (concat "^J" item "^J")))
  86.       {
  87.         (end-of-buffer)
  88.         (insert-text item)
  89.       })
  90.       })
  91.   }
  92. ;;!!!??? do I need this when i use describe-key?
  93.   process-*Help* HIDDEN
  94.   {
  95.     (int index help)
  96.     (string key pgm)
  97.  
  98.     (if (== -2 (index (attached-buffer INDEX-BUFFER)))
  99.     { (msg "No index buffer!")(halt) })
  100.  
  101.     (describe-bindings)
  102.     (current-buffer (help (attached-buffer "*Help*")))
  103.     (while (re-search-forward '^\(.+\)\ +\.+\(.+\)$')
  104.       {
  105.     (pgm (get-matched '\1'))
  106.     (key (get-matched '\2'))
  107.     (current-buffer index)
  108.         ;; if pgm doesn't exist, don't add key to index
  109.     (beginning-of-buffer)
  110.     (if (search-forward pgm)
  111.       {
  112.         (end-of-buffer)
  113.         (insert-text " " key " " pgm)
  114.       })
  115.  
  116.     (current-buffer help)
  117.       })
  118.   }
  119.   process-package; (string fname) HIDDEN
  120.   {
  121.     (int index bf)
  122.     (string package function)
  123.  
  124. (string fname)
  125. (fname (ask "package: "))
  126.  
  127.     (if (not (file-exists fname))
  128.     { (msg "File " fname " doesn't exist.") FALSE (done) })
  129.     (current-buffer (bf (create-buffer "*web-file*" 0)))
  130.     (read-file fname)
  131.  
  132.     (index (attached-buffer INDEX-BUFFER))
  133.     (current-buffer index)(end-of-buffer)
  134.  
  135.     (insert-text "=#=" fname "=#=" PACKAGE-TAG)
  136.  
  137.     (current-buffer bf)
  138.     (if (not (re-search-forward '^Package:\ +\(.+\)')) (done))
  139.  
  140.     (while (not (EoB))
  141.       {
  142. ;        (current-buffer bf)
  143. ;    (if (not (re-search-forward '^Package:\ +\(.+\)')) (break))
  144.  
  145.     (package (get-matched '\1'))
  146.  
  147.     (current-buffer index)
  148.         ;; Don't add duplicates (not that it matters)
  149.     (beginning-of-buffer)
  150.     (if (not (search-forward (concat "^J" package "^J")))
  151.       {
  152.         (end-of-buffer)
  153.         (insert-text package)
  154.       })
  155.  
  156.     (current-buffer bf)
  157.     (while (search-for '  (\([^     ]+\))')
  158.       {
  159.         (function (get-matched '\1'))
  160.         (current-buffer index)
  161.         (end-of-buffer)
  162.         (insert-text " " function " " package)
  163.         (current-buffer bf)
  164.       })
  165.       })
  166.   }
  167.   search-for (string re) HIDDEN
  168.   {
  169.     (while (forward-line 1)
  170.       {
  171.     (if (looking-at 'Package:\ +\(.+\)') (break))
  172.     (if (looking-at re) { TRUE (done) })
  173.       })
  174.     FALSE
  175.   }
  176. )
  177.