我是恶评的作者,在回购中可以找到少于200行的完整源代码。
基本上我有这样的东西。
(evil-define-operator evil-commentary (beg end type)
"Comment or uncomment region that {motion} moves over."
:move-point nil
(interactive "<R>")
(let ((comment-function
(cdr (assoc major-mode
evil-commentary-comment-function-for-mode-alist))))
(if comment-function (funcall comment-function beg end)
(comment-or-uncomment-region beg end))))
(defun evil-commentary-comment-for-org (beg end)
"Comment function for `org-mode'."
(interactive "r")
(if (and (fboundp 'org-in-src-block-p)
(org-in-src-block-p))
(evil-commentary-do-in-org-src-block beg end
(call-interactively 'evil-commentary))
(comment-or-uncomment-region beg end)))其思想是evil-commentary将在一个组织文件中调用evil-commentary-comment-for-org,如果我们处于src块中,evil-commentary-comment-for-org将在src-edit缓冲区(现在有不同的major-mode)中再次调用evil-commentary。
安装工作正常,但是当我编译代码时,我得到了一个无限循环evil-commentary -> evil-commentary-comment-for-org -> evil-commentary.有Variable binding depth exceeds max-specpdl-size错误..。
我发现,如果在加载org之后编译代码,它就能工作,但这不是我想要的,因为如果用户使用旧版本的org进行编译,然后对其进行升级,evil-commentary将停止工作。(package.el的一个缺陷)
谢谢!
发布于 2015-10-26 15:41:42
问题在这条线中,它扩展到:
(org-babel-do-in-edit-buffer
(call-interactively 'evil-commentary))如果您没有加载org,那么字节编译器就不知道org-babel-do-in-edit-buffer是一个宏,并且无法展开它。因此,它只是编译了一个名为org-babel-do-in-edit-buffer的函数(到目前为止还不知道)。
当执行到达该行时,首先计算函数参数(就像在任何其他函数调用中那样),然后就有了无限循环。
尝试在一个org块中要求eval-when-compile。
https://stackoverflow.com/questions/33348527
复制相似问题