home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / manpath.el < prev    next >
Encoding:
Text File  |  1990-07-22  |  2.4 KB  |  66 lines

  1. ;From ark1!nems!mimsy!haven!purdue!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!apple!sun-barr!newstop!sun!rberlin Wed Dec  6 12:18:31 1989
  2. ;Article 809 of gnu.emacs:
  3. ;Path: ark1!nems!mimsy!haven!purdue!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!apple!sun-barr!newstop!sun!rberlin
  4. ;>From rberlin@birdland.sun.com (Rich Berlin)
  5. ;Newsgroups: gnu.emacs
  6. ;Subject: Re: MANPATH
  7. ;Message-ID: <RBERLIN.89Dec1180023@birdland.sun.com>
  8. ;Date: 2 Dec 89 02:00:23 GMT
  9. ;References: <8911212118.AA29799@sn1987a.compass.com>
  10. ;Sender: news@sun.Eng.Sun.COM
  11. ;Distribution: gnu
  12. ;Organization: Sun Microsystems
  13. ;Lines: 49
  14. ;
  15. ;This ought to fill the bill.
  16. ;
  17. ;-- Rich
  18.  
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  20. ;; manpath.el --- find /cat? directories using MANPATH environment variable.
  21. ;; Author          : Rich Berlin
  22. ;; Created On      : Thu Sep  1 16:52:15 1988
  23. ;; Last Modified By: SILL D E
  24. ;; Last Modified On: Tue Jul 24 10:20:07 1990
  25. ;; Update Count    : 6
  26. ;; Status          : In daily use, probably OK.
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28.  
  29. ;; This is a handy way to keep up-to-date with the MANPATH in your .cshrc.
  30. ;; I use this by loading this file, and then doing
  31. ;; (setq manual-formatted-dirlist (search-manpath-for-cat-directories))
  32. ;;
  33. ;; Of some interest is csh-path-to-list, which you may want to use
  34. ;; for other purposes.
  35.  
  36. (defun search-manpath-for-cat-directories ()
  37.   "Return a list of all 'cat' directories in the current path specified\n\
  38. by the 'MANPATH' environment variable."
  39.   (search-path-for-files-matching
  40.    (csh-path-to-list (getenv "MANPATH")) "cat.+"))
  41.  
  42. (defun csh-path-to-list (string)
  43.   (if (null string)
  44.       (setq string "/usr/man"))
  45.   (let ((path nil) index)
  46.     (while (setq index (string-match ":" string))
  47.       (setq path (append path (list (substring string 0 index))))
  48.       (setq string (substring string (1+ index))))
  49.     (setq path (append path (list string)))))
  50.  
  51.  
  52. (defun search-path-for-files-matching (path regexp)
  53.   (if (null path)
  54.       (list regexp)
  55.     (let (curr-dir directory-list)
  56.       (setq regexp (format "^%s$" regexp))  ; So files MATCH regexp, instead
  57.       (while path                ; of just CONTAINING regexp.
  58.     (setq curr-dir (car path))
  59.     (setq path (cdr path))
  60.     (if (file-exists-p curr-dir)
  61.         (setq directory-list (append directory-list
  62.                      (directory-files curr-dir t regexp)))))
  63.       directory-list)))
  64.  
  65.  
  66.