Xref: utzoo gnu.emacs.help:757 comp.emacs:9852 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!tut.cis.ohio-state.edu!moose.crd.ge.com!montnaro From: montnaro@moose.crd.ge.com (Skip Montanaro) Newsgroups: gnu.emacs.help,comp.emacs Subject: Re: Hack to find-file-noselect for Suns running Automounter Message-ID: <9101130217.AA17734@moose.crd.Ge.Com> Date: 13 Jan 91 02:17:08 GMT References: <91Jan12.123858pst.6149@origami.parc.xerox.com> Sender: daemon@tut.cis.ohio-state.edu Reply-To: montanaro@crdgw1.ge.com (Skip Montanaro) Followup-To: gnu.emacs.help Organization: Gatewayed from the GNU Project mailing list help-gnu-emacs@prep.ai.mit.edu Lines: 36 Larry Masinter suggested a better solution to removing the Sun automounter prefix. Rather than modify find-file-noselect, he suggested replacing expand-file-name with a front-end Lisp function. Since expand-file-name is lower-level than find-file-noselect, more potentially troublesome filenames are corrected. In addition to solving the problem for more cases, Larry's solution is much shorter. Larry, thanks for the idea. Here's the code. ---------- (require 'cl) (defvar automounter-regexp "^/tmp_mnt" "Prefix tacked on by Sun's automounter. Used to hack it back off.") (or (fboundp 'unhacked-expand-file-name) (setf (symbol-function 'unhacked-expand-file-name) (symbol-function 'expand-file-name))) (defun expand-file-name (file &optional default) "Convert FILENAME to absolute, and canonicalize it. Second arg DEFAULT is directory to start with if FILENAME is relative (does not start with slash); if DEFAULT is nil or missing, the current buffer's value of default-directory is used. Filenames containing . or .. as components are simplified; initial ~ is expanded. If the variable automounter-regexp is non-nil that prefix is stripped from the filename. See also the function substitute-in-file-name." (let ((filename (unhacked-expand-file-name file default))) (if (and automounter-regexp (string-match automounter-regexp filename)) (setq filename (substring filename (match-end 0)))) filename)) ---------- Skip (montanaro@crdgw1.ge.com)