1.安裝
1、 emacs官網獲取安裝程序:
http://www.gnu.org/software/emacs/
2.、GNU Emacs for Windows can be downloaded from a nearby GNU mirror; or the main GNU FTP server.
Unzip the zip file preserving the directory structure, and run bin\runemacs.exe
. Alternatively, create a desktop shortcut to bin\runemacs.exe
, and start Emacs by double-clicking on that shortcut's icon
3、配置文件路徑配置
官方說明:
On Windows, the .emacs file may be called _emacs for backward compatibility with DOS and FAT filesystems where filenames could not start with a dot. Some users prefer to continue using such a name, because Explorer cannot create a file with a name starting with a dot, even though the filesystem and most other programs can handle it. In Emacs 22 and later, the init file may also be called.emacs.d/init.el. Many of the other files that are created by lisp packages are now stored in the.emacs.ddirectory too, so this keeps all your Emacs related files in one place.
All the files mentioned above should go in your HOME directory. The HOME directory is determined by following the steps below:
- If the environment variableHOME is set, use the directory it indicates.
- If the registry entry
HKCU\SOFTWARE\GNU\Emacs\HOME
is set, use the directory it indicates.- If the registry entry
HKLM\SOFTWARE\GNU\Emacs\HOME
is set, use the directory it indicates. Not recommended, as it results in users sharing the same HOME directory.- If C:\.emacs exists, then use C:/. This is for backward compatibility, as previous versions defaulted to C:/if HOME was not set.
- Use the user's AppData directory, usually a directory called Application Data under the user's profile directory, the location of which varies according to Windows version and whether the computer is part of a domain.
參考:https://blog.csdn.net/lihenair/article/details/19050479
方法一:原文:https://blog.csdn.net/zhuxiaoyang2000/article/details/8819601
默認情況下,Windows系統中Emacs的配置文件.emacs在C:\Users\<username>\AppData\Roaming。這個目錄很深,而且默認狀態下AppData目錄是隱藏的。最最關鍵的是:如果系統盤一旦出問題,之前的.emacs配置文件和.el的擴展都得重新配置和下載。可以用如下方式重新配置Emacs默認目錄。
啟動emacs,在 Option 菜單中隨便更改一下設置,如 取消Ignore Case for Search,之后點 Save Options。這一步不是多余的哦,因為默認情況下emacs不會在一啟動的時候就生成 .emacs 配置文件和 .emacs.d目錄的。這步生成的 .emacs 目錄還是在 C:\Users\<username>\AppData\Roaming 下,因為我們並沒有做別的設置移動它嘛~
下面就進入關鍵步驟了,打開 C:\Users\<username>\AppData\Roaming\.emacs 配置文件,修改內容為
(load-file "D:/OpenSource/emacs-24.3/.emacs")
(注意用“/”而非“\”,否則Emacs不能正確識別)這個配置意思很明顯了,emacs在啟動的時候會加載 C:/Users/<username>/AppData/Roaming/.emacs 這個配置文件,而該文件又加載另一個 D:/OpenSource/emacs-24.3/.emacs 配置文件。這樣,自然就成功實現了配置的轉移嘍~好了,從現在起就不用進入 C:/Users/<username>/AppData/Roaming/.emacs 這個冗的路徑嘍!
上一步,我們把emacs的配置文件用 (load-file ...) 配置已經指向到 D:/OpenSource/emacs-24.3/.emacs 了,那就拷貝 .emacs 文件放到 D:/OpenSource/emacs-24.3/ 里吧(Windows下好像不能建立以 . 開頭的文件吧)。然后,打開D:/OpenSource/emacs-23.2/.emacs,在開頭添加如下配置:
(setenv "HOME" "D:/OpenSource/emacs-24.3")
(setenv "PATH" "D:/OpenSource/emacs-24.3")
;;set the default file path
(setq default-directory "~/")
恩,是的,這里重新給 HOME PATH 等定義了新的路徑~~~寫到這里大家該明白了,就是把配置轉移了一下而已。
好了,現在就可以了把 D:/OpenSource/emacs-24.3 當成emacs的 HOME了。
方法二:
打開注冊表,找到HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs(如果沒有則手動添加項), 在此項下添加字符串值,名稱為HOME,值為D:\Emacs23.2。這樣做的目的是讓D:\Emacs23.2成為Emacs的home路徑(傳說中 的home path,以后你將會經常看到“home目錄”、“home directory”等等)。
4、創建配置文件.emacs.d目錄和.emacs文件(.emacs文件的優先級更高)
相信.emacs.d目錄和.emacs文件是困擾大家很久的問題了,其實有個簡單的辦法 可以解決此問題。啟動emacs(注:win7系統需要右鍵“以管理員身份運行”),用鼠標點擊Options菜單,隨便點擊一兩個選項,比如點擊一下Active Region Highlighting,然后點擊Save Options。先不要擔心你會破壞了什么東西,這樣做的目的是讓emacs自動創建.emacs.d目錄以及.emacs文件!觀察你的Emacs窗口 最后一行,是否顯示“Wrote D:/Emacs23.2/.emacs”?如果是的話就對了,當你選擇Save Options的時候,Emacs會在home路徑下產生.emacs文件,並把配置信息寫進這個文件。D:\Emacs23.2\目錄下將會產生這兩個文件。