🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98331

Canonical file names

#98331
From: Timothy_Freeman
Date: Thu, 17 Oct 1991 09:10
32 lines
1899 bytes
Epoch, which is based on Emacs version 18.55, tends to allow one to
open up a file in multiple buffers if there are symbolic links in its
pathname.  For instance, if /usr/tsf/foo is a symlink to the directory
/usr/tsf/bar, I can visit both of the files /usr/tsf/foo/x and
/usr/tsf/bar/x, and they get separate buffers which I can then edit
independently.  One fix for this is to canonicalize all filenames
before visiting the file.  Here's a function that does that for unix:

(defun canonicalize-filename (file)
  "Return the absolute pathname of FILE's ultimate target."
  ;(debug "File is %s." file)
  (let* ((tfile (expand-file-name file))
	 (sfile (file-symlink-p tfile)))
    (if sfile
	(canonicalize-filename
	 (expand-file-name sfile (file-name-directory tfile)))
	(let ((dir (file-name-directory tfile)))
	  (if (equal dir "/")
	      tfile
	      (concat
	       (canonicalize-filename
		(substring dir 0 -1))
	       "/"
	       (file-name-nondirectory tfile)))))))

A call to this function in the appropriate place in find-file could
easily be inserted.

In the above example, (canonicalize-filename "/usr/tsf/foo/x") =
(canonicalize-filename "/usr/tsf/bar/x") = "/usr/tsf/bar/x".

Tim
Technical Details
Message-ID: <2631.687719412@U.ERGO.CS.CMU.EDU>
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!Sirius.dfn.de!darwin.sura.net!udel!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!u.ergo.cs.cmu.edu!Timothy_Freeman

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,93affaf11ca501e8,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-10-17 02:10:12 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!Sirius.dfn.de!darwin.sura.net!udel!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!u.ergo.cs.cmu.edu!Timothy_Freeman
From: Timothy_Freeman@u.ergo.cs.cmu.edu
Newsgroups: gnu.emacs.bug
Subject: Canonical file names
Message-ID: <2631.687719412@U.ERGO.CS.CMU.EDU>
Date: 17 Oct 91 09:10:12 GMT
Sender: gnulists@ai.mit.edu
Reply-To: Tim Freeman <tsf@cs.cmu.edu>
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 32
Approved: bug-gnu-emacs@prep.ai.mit.edu