Where is the .emacs file in windows GNU emacs

隐身守侯 提交于 2019-12-29 07:05:11

问题


Where is the .emacs file in windows (I'm using Emacs-23-CvsP091103-EmacsW32-1.58 )

When Emacs starts up, it attempts to load and execute the contents of a file commonly called .emacs (though it may have other names, see Where do I put my init file?) which contains any customizations you have made. You can manually add lisp code to your .emacs, or you can use the Customization interface accessible from the Options menu. If the file does not exist, Emacs will start with the default settings.


回答1:


In your home directory. You can set this directory by setting the HOME environment variable. If home isn't set, it will look in your Application Data directory. On XP, that's something like C:\Documents and Settings\<username>\Application Data, on Vista and later C:\Users\<username>\AppData.

If you open up emacs, and try editing (with C-x C-f) ~/.emacs, that should generally open up the .emacs that Emacs will be loading.

See the Windows Emacs FAQ for more details.

To set the HOME environment variable, open the System Control Panel, go to the Advanced tab, click Environment Variables, then click the New button in the "User variables" section.




回答2:


The best way to find out where .emacs resides by default on a particular system is without a doubt C-h v user-emacs-directory. The user-emacs-directory variable is platform dependent and is helpful on each and every OS.




回答3:


My version of emacs on windows (22.3.1) places the init file there: ~/.emacs/init.el

(see Brian Campbell's post for the definition of ~, which is HOME).




回答4:


Add following code to a file (e.g. 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

Open emacs and M-x load-file c:/.emacs.

Then it will relocate .emacs to c:/.emacs.

I use this when I copy my emacs to a new computer.

More information please visit my blog abuot emacs. http://coordinate.sinaapp.com/?cat=3




回答5:


See this link to choose the location of your .emacs file when you install emacs:

http://www.claremontmckenna.edu/pages/faculty/alee/emacs/emacs.html



来源:https://stackoverflow.com/questions/1966380/where-is-the-emacs-file-in-windows-gnu-emacs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!