简体   繁体   English

在Ubuntu中更改.emacs目录

[英]Change .emacs directory in Ubuntu

Currently my .emacs file is found in /home So is my .emacs.d folder and I suppose some other files like diary, notes etc will be created in this folder. 目前我的.emacs文件位于/ home所以我的.emacs.d文件夹,我想在这个文件夹中会创建一些其他文件,如日记,笔记等。

I find this really messy and I want all my emacs related files(including the .emacs) and folders in a single folder, say /home/EmacsHome 我发现这非常混乱,我想把所有与emacs相关的文件(包括.emacs)和文件夹放在一个文件夹中,比如/ home / EmacsHome

How do I do that in Ubuntu 12.04? 我如何在Ubuntu 12.04中做到这一点? In windows I did this by setting an environment variable HOME to the path of EmacsHome. 在Windows中,我通过将环境变量HOME设置为EmacsHome的路径来完成此操作。 But, in Ubuntu, the HOME variable will be used for several other programs as well, so I dont want to change that. 但是,在Ubuntu中,HOME变量也将用于其他几个程序,所以我不想改变它。

Emacs already supports a config directory for holding everything Emacs-related: ~/.emacs.d . Emacs已经支持一个配置目录,用于保存与Emacs相关的所有内容: ~/.emacs.d Just use that. 只是使用它。

Rename ~/.emacs to ~/.emacs.d/init.el , and you're virtually done. ~/.emacs重命名为~/.emacs.d/init.el ,您实际上已经完成了。

If you have any other emacs-specific files outside of that directory, you might need to set a variable here or there to relocate them, or simply rename the file -- these days the defaults tend to automatically be within ~/.emacs.d , but an older filename in the home directory might still take precedence. 如果你在该目录之外还有其他特定于emacs的文件,你可能需要在这里或那里设置一个变量来重新定位它们,或者只是重命名文件 - 这些天默认值往往自动在~/.emacs.d ,但主目录中的旧文件名可能仍然优先。

eg: the bookmarks file used to be ~/.emacs.bmk but if you haven't customized the variable then you can simply rename it to ~/.emacs.d/bookmarks . 例如:书签文件曾经是~/.emacs.bmk但如果你没有自定义变量,那么你可以简单地将它重命名为~/.emacs.d/bookmarks See Ch f locate-user-emacs-file RET and Mx find-variable RET bookmark-default-file RET for details. 有关详细信息,请参阅Ch f locate-user-emacs-file RETMx find-variable RET bookmark-default-file RET

If you're not sure how to proceed for any given file(s), you could just update the question with the details. 如果您不确定如何处理任何给定文件,您可以使用详细信息更新问题。

And as Alberto Zaccagni said, just create a symlink if you want an alternative name to access the directory. 正如Alberto Zaccagni所说,如果你想要一个替代名称来访问目录,只需创建一个符号链接。 Although personally I would suggest retaining ~/.emacs.d as the real directory, and making the alternative name the link, like so: 虽然我个人建议保留~/.emacs.d作为真实目录,并将替代名称作为链接,如下所示:

ln -s ~/.emacs.d /home/EmacsHome

This works for OSX, so perhaps for you too . 这适用于OSX,所以也许也适合你。 . . just change the paths to whatever suits your needs. 只需改变适合您需求的路径即可。 The user-emacs-directory is where you would set the equivalent of .emacs.d . user-emacs-directory是您设置等效.emacs.d I have everything related to Emacs in my user-emacs-directory . 我在user-emacs-directory拥有与Emacs相关的所有内容。 If you use package manager, the elpa directory would be automatically crated there also. 如果您使用包管理器,那么elpa目录也会自动包装。

(setq default-directory "~/.0.data/")

(setq user-emacs-directory "~/.0.data/.0.emacs/")

(setq diary-file "~/emacs/diary")

You could create a symbolic link to them, like so 你可以创建一个符号链接,就像这样

ln -s /home/EmacsHome ~/.emacs.d

The first argument is the folder where you want the folders to be, the second one is where emacs usually looks for its configuration files, so with this approach you can put the folder wherever you like. 第一个参数是您希望文件夹所在的文件夹,第二个参数是emacs通常查找其配置文件的位置,因此使用此方法您可以将文件夹放在任何您喜欢的位置。

There's also another solution: 还有另一个解决方案:

cd your-directory
HOME=$PWD emacs -L .

taken from https://github.com/capitaomorte/yasnippet#important-note-regarding-bug-reporting 摘自https://github.com/capitaomorte/yasnippet#important-note-regarding-bug-reporting

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM