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

发布于 2024-09-17 22:37:45 字数 352 浏览 6 评论 0原文

我刚刚安装了 Emacs Speaks Statistics,此时就开始出现此错误。卸载了也没解决。

当我使用 Cx Cf 时,我可以正常导航,但是当我实际按下 Enter 时,Emacs 似乎在所有路径中的“~”之后插入“/Application Data/Application Data/”,例如,如果我导航到:

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

然后按 Enter,我打开:

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

知道我可以编辑哪些变量来解决此问题吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

猫卆 2024-09-24 22:37:45

检查你的 HOME 变量。也许它指向c:/Documents and Settings/admin/Application Data

扩展文件名的函数是:expand-file-name

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

很酷又爱笑 2024-09-24 22:37:45

这似乎是与 $HOME 相关的当前值和缓存值之间的混乱。
问题是用于匹配主目录的模式
不再一样了。

在某个时刻
(setq 文件名
(缩写文件名
(扩展文件名 文件名)))
把名字搞乱了。

这是我创建并添加到 .emacs、_emacs、.emacs.el 或
应用程序数据.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)

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)
寒江雪… 2024-09-24 22:37:45

Emacs 在最近的版本中更改了 home 的默认位置——新的默认位置就是您所看到的。显式地将 env var HOME 设置为您想要的任何内容,一切都会好起来的。

Emacs changed the default location of home in recent releases -- the new default is what you're seeing. Explicitly set env var HOME to whatever you want and things will be OK.

水中月 2024-09-24 22:37:45

您也许可以使用 Mx setenv 更改此行为。例如:

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

如果可行,您可以将其添加

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

到 init 文件中以获得更永久的解决方案。

You might be able to change this behavior by using M-x 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文