home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / mutt / tags.mut < prev    next >
Text File  |  1988-04-04  |  2KB  |  71 lines

  1.  ;; Lookup stuff in a tags file
  2.  
  3.  ;; To create a tags file in:
  4.  ;;   current directory: ctags -xtw files >Tags
  5.  ;;   a subtree: find . -name '*.[ch]' -print | xargs ctags -xtw >Tags
  6.  ;; Keep the tags file in the directory it is created in
  7.  
  8. (include spoint.mut)
  9.  
  10. (string tags-path 150   file-name 200 text 200)
  11. (const tag-buffer "*TAGS*")
  12.  
  13. (defun
  14.   lookup-tag (string tag) HIDDEN    ; search the tags buffer for a tag
  15.   {
  16.     (bool s)
  17.  
  18.     (s TRUE)(save-point)
  19.     (switch-to-buffer tag-buffer)(beginning-of-buffer)
  20.     (msg "Looking for tag ...")
  21.     (if (re-search-forward (concat '^' tag '\ '))
  22.       {
  23.     (looking-at '\ *\d+ \([^ ]+\)\ +\(.+\)')
  24.     (file-name (get-matched '\1'))
  25.     (text (get-matched '\2'))
  26.       }
  27.       { (msg tag " not found.")(s FALSE) }
  28.     )
  29.     (restore-point)
  30.     s
  31.   }
  32.   get-tag-name HIDDEN
  33.   {
  34.     (string tag 100)
  35.     (if (== "" (tag (ask "Tag to look for: ")))
  36.       { (looking-at '\w+')(get-matched '&') }
  37.       tag
  38.     )
  39.   }
  40.   goto-tag
  41.   {
  42.     (string tag 100)
  43.     (tag (get-tag-name))
  44.     (if (lookup-tag tag)
  45.     {
  46.       (visit-file (concat tags-path (substr file-name 1 200)))
  47.       (if (search-forward text)
  48.         {(arg-prefix 1)(reposition-window)}    ; move to top of screen
  49.     (msg "tag file is out of date")
  50.       )
  51.     })
  52.   }
  53.   where-is-tag
  54.   {
  55.     (string tag 100)
  56.     (tag (get-tag-name))
  57.     (if (lookup-tag tag)
  58.     (msg tag " is in " tags-path (substr file-name 1 200)))
  59.   }
  60.   select-tag-file MAIN
  61.   {
  62.     (tags-path (ask "DIRECTORY tags file is in: "))
  63.     (save-point)
  64.     (kill-buffer tag-buffer)
  65.     (switch-to-buffer tag-buffer)(read-file (concat tags-path "/Tags"))
  66.     (buffer-flags -1 0x6)
  67.     (restore-point)
  68.     (msg "Loaded tags")
  69.   }
  70. )
  71.