windows系统中Emacs的HOME目录及配置文件的正确路径

摘要:
.macs文件_目录下的emacs文件或init.el(22或更高版本)文件。emacs和。emacs。d可以放在Linux下的这个目录中,其值用作主目录~如果注册表项HKCU SOFTWARE GNU Emacs home存在,其值将用作主目录~~如果注册表项HKLM SOFTWARE NU Emacs home存在,则其值将作为主目录。

最近爱折腾的毛病又犯了,开始折腾起Emacs,在自定义Emacs的配置文件存放位置时遇到一点问题,不过,在GNU的Emacs站点,看到这么一段话

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:

  1. If the environment variableHOME is set, use the directory it indicates.
  2. If the registry entry HKCU\SOFTWARE\GNU\Emacs\HOME is set, use the directory it indicates.
  3. 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.
  4. If C:\.emacs exists, then use C:/. This is for backward compatibility, as previous versions defaulted to C:/ if HOME was not set.
  5. 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.

也就是说,Emacs的配置文件有三种格式:.emacs文件、_emacs文件或者.emacs.d目录下的init.el(22或者更高版本)文件,但是,不管哪种格式,必须放对正确的目录Emacs才能找到,这个正确的目录就是HOME目录。


熟悉Linux的朋友一般都知道home目录,简单的用~表示,或者用全路径表示为/home/<xxx>,其中xxx表示用户名字,所以,在Linux下将.emacs和.emacs.d放到这个目录下就行了,但windows没有home目录的概念,所以,Emacs就按如下方式来查找配置文件:

  1. 如果设置了HOME环境变量,那么就用它的值作为home目录~
  2. 如果存在注册表键值HKCU\SOFTWARE\GNU\Emacs\HOME,就用它的值作为home目录~
  3. 如果存在注册表键值HKLM\SOFTWARE\GNU\Emacs\HOME,就用它的值作为home目录~(和2的区别是,2只是针对当前用户的注册表路径,3则是针对所有用户)
  4. 如果存在C:\.emacs,就用C:\作为home目录~
  5. 如果以上都不存在的话,就使用<system root>\Users\<user name>\AppData\Roaming作为home目录~(对于XP和较早windows用户,需要到Documents and Settings目录下去找)

从以上策略来看,1是比较好的做法,所以优先级也最高,应该是属于建议的方式,于是,新建一个HOME环境变量,将它的值设为想要放置Emacs配置文件的地方既可。

之前我是按以上方法设置的HOME目录,不过现在我后悔了,因为我发现不光是Emacs会使用HOME这个环境变量,会使用这个变量的至少还有以下程序或者插件:

  1. VIM,VIM会把_viminfo文件放在这个目录;
  2. VIM的neocomplcache插件,它会放置一个.neocon目录进去;
  3. firefox的pentadactyl插件,它会放一个pentadactyl目录进去。

所以,个人建议:

  1. 如果你希望有一个公共的目录存放这些配置,就像Linux下的~目录一样,那么设置HOME这个环境变量最适合不过;
  2. 如果你希望这个目录只存放Emacs的配置,那么,还是不要用HOME环境变量了,去注册表里面添加一个HOME键值吧。(至少我个人比较偏向于这个方式)

免责声明:文章转载自《windows系统中Emacs的HOME目录及配置文件的正确路径》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇linux中给数据加上行号最优化算法4.0【信赖域方法】下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

linux常见故障处理

目录 一. 文件和目录类 1.1 File exist 文件已经存在 1.2 No such file or directory 没有这个文件或目录(这个东西不存在) 1.3 command not found 命令找不到(没有这个命令) 1.4 invalid option 无效的参数(不可用的参数) 1.5 overwrite 覆盖 1.6 r...

attrib命令

attrib指令的格式和常用参数为:ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [[drive:] [path] filename] [/S [/D]]   +    设置属性。   -     清除属性。   R    只读文件属性。   A    存档文件属性。   S    系统文件属性。   H ...

Python之os库的使用

1. os库基本介绍 os库提供通用的、基本的操作系统交互功能 os 库是Python标准库,包含几百个函数 常用路径操作、进程管理、环境参数等几类 详解介绍 路径操作:os.path子库,处理文件路径及信息 进程管理:启动系统中其他程序 环境参数:获得系统软硬件信息等环境参数 2. os库之路径操作 os库使用os.path子库来进行路径操作,...

unity sprite怎么获取切割后的图

学习了一段时间的unity,对里面的组件有一个大致的了解,但是具体操作来说还不是很熟悉,今天看了一片关于unity sprite怎么获取切割后的图的文章,感觉还不错。 假设有一张png/tga图集,导入到Unity,放置目录"Assets/Resources/UI"(UI文件夹可替换成其他的,重要的是要在"Assets/Resources/"路径下),默认...

MySQL日志系统(redo log、undo log、binlog)

1.redo log(重做日志) InnoDB引擎特有的日志   当数据库对数据做修改的时候,需要把数据页从磁盘读到buffer pool中,然后在buffer pool中进行修改,那么这个时候buffer pool中的数据页就与磁盘上的数据页内容不一致,称buffer pool的数据页为dirty page 脏数据,如果这个时候发生非正常的DB服务重启...

服务器双向同步( 可实时 ) unison + inotify

一. Unison简介 Unison是Windows、Linux以及其他Unix平台下都可以使用的文件同步工具,它能使两个文件夹(本地或网络上的)保持内容的一致。1. 跨平台使用;对内核和用户权限没有特别要求;  2. Unison是双向的,它能自动处理两分拷贝中更新没有冲突的部分,有冲突的部分将会显示出来让用户选择更新策略; 3. 只要是能连通的两台主机...