Subject: bug#508: emacs 22.2.1 becomes confused

From: Sven Joachim <[email-masked]>
Date: Mon, 30 Jun 2008 19:53:51 +0200

On 2008-06-30 17:03 +0200, Bruce Korb wrote:

> I recently re-installed my system.  For various reasons not worth
> going into here,
> I renamed my home directory from /home/foo to /home/Foo and re-created my
> "foo" user name.  It is not possible to edit anything in the /home/Foo hierarchy
> with emacs.  At all.  I can cd to the correct directory and invoke "emacs file"
> and it will try to open the equivalently named file under /home/foo.  Somebody
> somewhere fiddled some code such that tab-completion works correctly, but
> when it comes to actually "visiting" the file, the blasted thing substitutes
> "$HOME" for "/home/Foo".

This is with HOME=/home/foo, I suppose?  Because when I tried to
reproduce it, I set $HOME to /home/Foo and files beneath /home/foo
became inaccessible.

>  Someone please be kind enough to find that
> "strncasecmp" and replace it with "strncmp" and put out an emergency fix.

Actually, this is not a problem in the C code, but rather in Lisp, in
the function abbreviate-file-name.

The following patch tries to take care of this by matching the home
directory case-sensitively on systems which usually have such
filesystems, could you please test it?

--8<---------------cut here---------------start------------->8---
--- files.el.~1.985.~	2008-06-11 07:54:21.000000000 +0200
+++ files.el	2008-06-30 19:37:37.000000000 +0200
@@ -1412,7 +1412,10 @@
 	     (file-exists-p (file-name-directory
 			     (substring filename (1- (match-end 0))))))
 	(setq filename (substring filename (1- (match-end 0)))))
-    (let ((tail directory-abbrev-alist))
+    (let ((tail directory-abbrev-alist)
+	  (case-fold-search
+	   (if (memq system-type '(ms-dos windows-nt darwin macos vax-vms axp-vms))
+	       t nil)))
       ;; If any elt of directory-abbrev-alist matches this name,
       ;; abbreviate accordingly.
       (while tail
--8<---------------cut here---------------end--------------->8---

Changelog entry:

2008-06-30  Sven Joachim  <[email-masked]>

	* files.el (abbreviate-file-name): Match the home directory
	case-sensitively on systems that have case-sensitive filesystems.

Regards,
        Sven