这似乎是与 $HOME 相关的当前值和缓存值之间的错误。问题是用于匹配主目录的模式不再相同。
在某些时候 (setq filename (abbreviate-file-name (expand-file-name filename))) 会弄乱名称。
这是我整理并添加到 .emacs、_emacs、.emacs.el 或 Application Data.emacs.d\init.el 以使 abbreviated-home-dir 恢复原状的解决方法:
不要忘记:不要对你的 init 文件进行字节编译,否则你可能会不同步。
;;; 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)