我在 Ubuntu 12.04 上使用 Gnu Emacs 24.3。
我下载了 dired+.el
从这里:http://www.emacswiki.org/emacs/dired%2b.el .然后我尝试在 Emacs 中对该文件进行字节编译。我做了一个文件 bytecomp.el
:
(byte-compile-file "dired+.el")
并运行以下命令:
bash$ emacs -batch -l bytecomp.el -kill
并收到以下错误消息:
In toplevel form:
dired+.el:1114:1:Error: Cannot open load file: dired+
更新
更改文件
bytecomp.el
到:(add-to-list 'load-path "~/emacs/test/bytecompile")
(byte-compile-file "dired+.el")
正在运行
emacs -batch -l bytecomp.el -kill
来自同一目录( ~/emacs/test/bytecompile
)给出了另一个错误消息:Recursive load: "/home/fcihh/emacs/test/bytecompile/bytecomp.el", "/home/fcihh/emacs/test/bytecompile/bytecomp.el", "/home/fcihh/emacs/test/bytecompile/bytecomp.el", "/home/fcihh/emacs/test/bytecompile/bytecomp.el", "/home/fcihh/emacs/test/bytecompile/bytecomp.el"
最佳答案
您需要输入 dired+.el
在您的 load-path
.dired+.el
明确地这样做:
(provide 'dired+)
(require 'dired+) ; Ensure loaded before compile this.
这是一个 Emacs-Lisp 习惯用法,可确保在编译之前加载库。对于 Dired+,这是合适的。
所以这样做:
(add-to-list 'load-path "/your/path/to/dired+/")
此处使用的习语的相关文档是 (elisp)
Named Features
.这里有一点:Although top-level calls to `require' are evaluated during byte
compilation, `provide' calls are not. Therefore, you can ensure that a
file of definitions is loaded before it is byte-compiled by including a
`provide' followed by a `require' for the same feature, as in the
following example.
(provide 'my-feature) ; Ignored by byte compiler,
; evaluated by `load'.
(require 'my-feature) ; Evaluated by byte compiler.
The compiler ignores the `provide', then processes the `require' by
loading the file in question. Loading the file does execute the
`provide' call, so the subsequent `require' call does nothing when the
file is loaded.
关于emacs - 字节编译 emacs lisp 文件 : Error: Cannot open load file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20526714/