控制字节编译的详细程度(CL库)

时间:2012-09-27 00:07:12

标签: emacs compilation elisp

当批量编译多个eLisp文件时,编译器的输出会出现Warning: function `position' from cl package called at runtime警告。我理解,虽然对cl包的政策不太满意。但这使得发现其他更有用的警告变得更加困难。那么,虽然没有真正的方法来避免警告,有没有办法有选择地关闭某种模式的所有警告?

编辑:(附上一个例子)

创建名为doodles.el的文件

(require 'cl)
(eval-when-compile (require 'cl))

(dotimes (i 1)
  (position ?\x "x"))

M-x byte-compile-file RET doodles.el

切换到*Compile-Log*缓冲区:

doodles.el:1:1:Warning: cl package required at runtime

这就是你得到的。

2 个答案:

答案 0 :(得分:5)

您可以使用设置byte-compile-warnings变量的局部变量块来控制字节编译器警告。要关闭CL-at-runtime警告,请将其放在模块末尾附近:

;; Local Variables:
;; byte-compile-warnings: (not cl-functions)
;; End:

答案 1 :(得分:1)

警告function position from cl package called at runtime不存在是因为关于CL的政策(当然,它确实与它有关),但指出了一个真正的实际问题:你使用position不是(require 'cl)的文件。该文件可能(eval-when-compile (require 'cl)),这意味着CL在编译期间可用(例如,扩展CL宏),但不会在运行时加载。

这通常不会导致错误,因为某处的某个其他文件对您来说(require 'cl),但这只是你的幸运。

相关问题