views:

49

answers:

2

I just installed Emacs Speaks Statistics, which is when this error started showing up. Uninstalling hasn't fixed it.

When I use C-x C-f, I can navigate normally, but when I actually press enter, Emacs seems to insert "/Application Data/Application Data/" after "~" in all paths, e.g. if I navigate to:

c:/Documents and Settings/admin/My Documents/sig.html

And press enter, I open:

~/Application Data/Application Data/My Documents/sig.html

Any idea what variables I can edit to fix this?

A: 

Check your HOME variable. Maybe it points to c:/Documents and Settings/admin/Application Data

The function that expands file names is : expand-file-name

Jérôme Radix
A: 

This seems to be a botch-up between current and cached values related to $HOME. The problem is that the pattern used to match the home directory isn't the same any more.

At some point (setq filename (abbreviate-file-name (expand-file-name filename))) messes up the name.

Here's a work-around I whipped up and added to .emacs, _emacs, .emacs.el or Application Data.emacs.d\init.el to get the abbreviated-home-dir back in shape:

Don't forget: do not byte-compile your init file or you may be out-of-sync.

;;; files.el mistakenly initializes abbreviated-home-dir just once
;;; not realizing that its value should change when HOME is redefined.
;;; Thus abbreviated-home-dir is "^c:/Documents and settings/USER/Application Data\\(/\\|\\'\\)"
;;; when it should, now, be "^c:/Documents and settings/USER\\(/\\|\\'\\)"
;;; Then when you try to open "^c:/Documents and settings/USER/Application Data/"
;;; The name is abbreviated to "~", but expanded back to "c:/Documents and settings/USER/"
;;; losing part of the name ("Application Data/")
;;; 
;;; Rather than explicitly re-initialize abbreviated-home-dir, it should be set to nil
;;; (setq abbreviated-home-dir "$foo") ;; Impossible pattern match.
;;; This causes the filepath to never match, and ~ is never abbreviated.
;;;
;;; We _could_ explicitly initialize it:
;;; (setq abbreviated-home-dir "^c:/Documents and settings/badgerb\\(/\\|\\'\\)")
;;; But this is a bad idea.  It is _highly_ dependent on the workings of files.el, and it
;;; seems better to me to just clear the value and let files.el re-initialize it.
(setq abbreviated-home-dir nil)
Bernard A. Badger