2

我想cc-mode.el用另一个文件覆盖默认的 Emacs。在我的.emacs中,我有以下行:

(add-to-list 'load-path "/usr/home/smooth/emacs" t)

这可以正常加载本地 Emacs 配置文件。例如

(require 'go-mode-autoloads)

go-mode.el可以从上述目录加载。

我尝试将所需的cc-mode.el文件放入上述目录,希望它会覆盖默认的 Emacs c-mode。但是,它没有加载cc-mode.el我放入的文件/usr/home/smooth/emacs。相反,它继续使用默认的。

如何让 Emacs 使用我的cc-mode.el文件而不是默认文件?我已经用 Google 进行了广泛的搜索并尝试了 Emacs Wiki,但我找不到正确的页面。

或者,我如何将 Emacs 设置为使用另一个文件而c-mode不是系统默认值?我不介意将当前重命名cc-mode.el为另一个名称。

我的 Emacs 版本是 25.2。

4

2 回答 2

0

查看 Emacs Wiki,我注意到“加载路径”的末尾没有“t”,所以我删除了它并开始工作。上面的“t”可能是问题的根源。非常奇怪的是,我试图绕过的 cc-mode 中的不当行为也消失了。上面的“t”可能导致了某种其他错误。有关 Emacs Wiki 页面,请参阅 emacswiki.org/emacs/LoadPath。

我找到了这个页面:gnu.org/software/emacs/manual/html_node/elisp/...。它说通常,如果添加元素,则将其添加到符号的前面,但如果可选参数 append 为非零,则将其添加到末尾。看来我是在最后添加的。我不确定为什么会如此可怕地破坏 cc-mode,因为它一直在工作,直到我几天前切换到 emacs 25.2。现在运行良好。

于 2017-05-05T12:45:17.390 回答
0

您可以使用load-library( 或load)无条件地加载库,即使它提供的功能已经提供(例如,由另一个库或同一库的另一个版本已经加载)。

只需将要加载的库放在靠近开头的目录中load-path,然后调用load-library.

[Note, however, that loading (or reloading) a library does NOT cancel out defvars and defcustoms that might already have been evaluated. For example, if library foo.el has a defcustom for foo-option and it has been loaded, and then you load your own version of foo.el that has such a defcustom but with a different default value, yours will be ignored. This is part of the behavior of defvar and defcustom.]

于 2017-05-05T13:49:04.090 回答