简体   繁体   English

当我使用Cx Cf时,为什么W32 Emacs会在“〜/”开头的文件路径中插入“ / Application Data / Application Data /”?

[英]Why would W32 Emacs insert “/Application Data/Application Data/” into a filepath starting with ~/ when I use C-x C-f?

I just installed Emacs Speaks Statistics, which is when this error started showing up. 我刚刚安装了Emacs Speaks Statistics,该错误开始出现时。 Uninstalling hasn't fixed it. 卸载尚未解决。

When I use Cx Cf, I can navigate normally, but when I actually press enter, Emacs seems to insert "/Application Data/Application Data/" after "~" in all paths, eg if I navigate to: 当我使用Cx Cf时,我可以正常导航,但是当我实际按Enter键时,Emacs似乎在所有路径中的“〜”之后插入“ / Application Data / Application Data /”,例如,如果我导航至:

c:/Documents and Settings/admin/My Documents/sig.html c:/ Documents and Settings / admin /我的文档/sig.html

And press enter, I open: 然后按Enter,我打开:

~/Application Data/Application Data/My Documents/sig.html 〜/应用程序数据/应用程序数据/我的文档/sig.html

Any idea what variables I can edit to fix this? 知道我可以编辑哪些变量来解决此问题吗?

You might be able to change this behavior by using Mx setenv . 您可以使用Mx setenv更改此行为。 For example: 例如:

M-x setenv <RET> HOME <RET> c:/Documents and Settings/admin

If that works, you can add 如果可行,您可以添加

(setenv "HOME" "c:/Documents and Settings/admin")

to your init file for a more permanent solution. 到您的init文件中,以获得更永久的解决方案。

Check your HOME variable. 检查您的HOME变量。 Maybe it points to c:/Documents and Settings/admin/Application Data 也许它指向c:/Documents and Settings/admin/Application Data

The function that expands file names is : expand-file-name 扩展文件名的功能是: expand-file-name

This seems to be a botch-up between current and cached values related to $HOME. 这似乎是与$ 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. 有时(setq文件名(缩写文件名(扩展文件名文件名)))弄乱了名称。

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: 我整理了一个变通方法,并将其添加到.emacs,_emacs,.emacs.el或Application Data.emacs.d \\ init.el中,以使缩写的home-dir恢复原状:

Don't forget: do not byte-compile your init file or you may be out-of-sync. 不要忘了: 不要字节编译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)

Emacs changed the default location of home in recent releases -- the new default is what you're seeing. Emacs在最新版本中更改了默认的家庭位置-新的默认设置就是您所看到的。 Explicitly set env var HOME to whatever you want and things will be OK. 将env var HOME显式设置为您想要的任何值,一切都会好起来的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM