home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / alt / lucidem / bug / 330 < prev    next >
Encoding:
Text File  |  1992-11-09  |  2.0 KB  |  51 lines

  1. x-gateway: rodan.UU.NET from bug-lucid-emacs to alt.lucid-emacs.bug; Mon, 9 Nov 1992 14:18:54 EST
  2. Date: Mon, 9 Nov 1992 11:18:47 PST
  3. Message-ID: <9211091918.AA06576@thalidomide.lucid>
  4. X-Windows: Garbage at your fingertips.
  5. From: jwz@lucid.com (Jamie Zawinski)
  6. Sender: jwz%thalidomide@lucid.com
  7. Subject: Re: automatic load-path generation
  8. Newsgroups: alt.lucid-emacs.bug
  9. Path: sparky!uunet!wendy-fate.uu.net!bug-lucid-emacs
  10. Lines: 39
  11.  
  12. To use the startup.el that I recently sent out, you need to add the
  13. following forms to the front of it.
  14.  
  15. I'd really appreciate some feedback (positive or negative) on whether this
  16. startup code does what you need, because otherwise I'm going to put it in
  17. 19.4 and get a lot of complaints if it has missed the mark again...
  18.  
  19.     -- Jamie
  20.  
  21.  
  22. ;; This should really be in files.el, but is used very early.
  23. (defvar directory-abbrev-alist
  24.   nil
  25.   "*Alist of abbreviations for file directories.
  26. A list of elements of the form (FROM . TO), each meaning to replace
  27. FROM with TO when it appears in a directory name.
  28. This replacement is done when setting up the default directory
  29. of a newly visited file.  *Every* FROM string should start with `^'.
  30.  
  31. Use this feature when you have directories which you normally refer to
  32. via absolute symbolic links.  Make TO the name of the link, and FROM
  33. the name it is linked to.")
  34.  
  35. (defun abbreviate-file-name (filename &optional hack-homedir)
  36.   "Return a version of FILENAME shortened using directory-abbrev-alist.
  37. See \\[describe-variable] directory-abbrev-alist RET for more information.
  38. If optional argument HACK-HOMEDIR is non-nil, then This also substitutes
  39. \"~\" for the user's home directory."
  40.   (let ((tail directory-abbrev-alist))
  41.     (while tail
  42.       (if (string-match (car (car tail)) filename)
  43.       (setq filename
  44.         (concat (cdr (car tail)) (substring filename (match-end 0)))))
  45.       (setq tail (cdr tail))))
  46.   (if (and hack-homedir
  47.        (string-match (concat "^" (regexp-quote (expand-file-name "~")))
  48.              filename))
  49.       (setq filename (concat "~" (substring filename (match-end 0)))))
  50.   filename)
  51.