Windows 7 中的主目录和 .emacs 文件



我在 c:/emacs-23.3 中安装了 emacs 23.3.1。按照本页中的提示,我更新了 site-start.el 以设置 HOME 环境变量。

(setenv "HOME" "c:/users/USER/emacs")

我制作了 c:/users/USER/.emacs(就像我在 unix/mac 中所做的那样)来编写使用史莱姆的代码,但它似乎没有正确启动史莱姆。

这是在 Windows 7 中设置 emacs 的正确方法吗?我应该把 .emacs 文件放在哪里?

你需要在

计算机设置的环境变量中设置HOME(如果我没记错的话),或者将init文件放入默认目录(只需启动Emacs,然后按C-x C-f ~/即可查看实际目录)。我记得,在 Windows 上,初始化文件可以称为 _emacs ...

我正在将 emacs 作为便携式应用程序运行,这对我来说效果很好:

在 emacs 目录的根目录中创建一个批处理文件。例如,我创建了:

C:DropboxPortableAppsemacs-24.3run_emacs_portable.bat

然后,编辑文件并将以下文本放入其中:

set HOME=.
binrunemacs.exe %*

现在,我只是通过run_emacs_portable.bat文件启动 emacs,我的 HOME 文件夹总是指向我的 emacs 安装文件夹。

%* 允许您将参数传递给.bat文件并将它们转发到 runemacs.exe

在主目录中,.emacs.d 是自动创建的,您可以将 init.el 作为启动文件。另请参阅此问题。

要在 Windows 用户文件夹 (C:\Users\User\.emacs.d) 中设置 Emacs 主文件夹,只需将此代码添加到您当前的 init 文件中并重新启动 Emacs。

(when (eq system-type 'windows-nt)
  (unless (getenv "Home")
    (shell-command (format "setx "%s" "%s"" 'Home (getenv "UserProfile")))))
我喜欢

Роман Захаров 的答案,这似乎有利于维护跨平台配置,但它不起作用。

这就是最终对我有用的东西。

(when (eq system-type 'windows-nt)
  (setenv "Home" (getenv "UserProfile")))

你可以启动emacs,键入M-x pwd,这将显示你在Windows文件树中的位置。你可以把你的.emacs放在那里。

在Windows上,Emacs在启动时定义了一些属性,当你右键单击Windows系统上的可执行文件时可以找到。在那里您可以定义

  1. execution-directory,例如 "C:\Users\loggedin_user\" (在 paranthes 中)

  2. Emacs 执行的位置

  3. 并查找 .xemacs (.emacs) 目录,在那里可以找到它的 init.el。

  4. 以及您可以定义启动指令的位置(例如(setenv "HOME" "c:/Users/Username/") )等。

如果你配置了,下次 emacs 从你定义的目录开始,初始化文件

如果你想使用 c:/users/USER/

.emacs,你应该将 HOME 变量设置为 c:/users/USER,而不是 c:/users/USER/emacs。

最新更新