在Windows的GNU emacs中,.emacs文件在哪里?

5
在Windows中,.emacs文件在哪里(我正在使用Emacs-23-CvsP091103-EmacsW32-1.58)?
当Emacs启动时,它会尝试加载和执行一个名为.emacs的文件(尽管它可能有其他名称,请参见我应该把我的init文件放在哪里?),其中包含您所做的任何自定义。您可以手动向.emacs添加lisp代码,也可以使用从选项菜单访问的自定义界面。如果文件不存在,Emacs将使用默认设置启动。

1
参见:https://dev59.com/sHVC5IYBdhLWcg3wxEJ1 - Michael Paulukonis
4个回答

14

在您的主目录中。您可以通过设置HOME环境变量来设置此目录。如果没有设置home,它将在应用程序数据目录中查找。在XP上,类似于 C:\Documents and Settings\<username>\Application Data,在Vista和以后版本中为C:\Users\<username>\AppData

如果您打开emacs,并尝试使用C-x C-f编辑~/.emacs,那通常会打开Emacs将要加载的.emacs

有关详细信息,请参见Windows Emacs FAQ

要设置 HOME 环境变量,请打开系统控制面板,转到高级选项卡,单击环境变量,然后在“用户变量”部分中单击新建按钮。


2

找到.emacs文件在特定系统上的默认位置,最好的方法无疑是使用C-h v user-emacs-directoryuser-emacs-directory变量是与平台相关的,并且在每个操作系统上都很有帮助。


0

将以下代码添加到文件中(例如c:/.emacs)。

;; This function must be at begin
(defun zxy-relocate-dotemacs ()
  "Relocate .emacs file"
  (interactive)
  (with-temp-buffer
    (let (print-level print-length)
      (insert (format "(load-file \"%s\")" load-file-name))
      (if (file-exists-p "~/.emacs")
          (message "[zxy] Don't need relocate .emacs file!")
        (progn
          (message "[zxy] Relocate .emacs file.")
          (write-file "~/.emacs"))))))
(zxy-relocate-dotemacs)
;; Your configuration here

打开emacs并输入M-x load-file c:/.emacs。

然后它将把.emacs文件重定位到c:/.emacs。

当我将我的emacs复制到新电脑上时,我使用这个方法。

更多信息请访问我的博客关于emacs。 http://coordinate.sinaapp.com/?cat=3


0

我在 Windows 上使用的 Emacs 版本是 22.3.1,其初始化文件位于以下位置: ~/.emacs/init.el

(请参阅 Brian Campbell 的帖子以获取 ~(即 HOME)的定义)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接