从函数中获取最新命令,但函数超过" max-lisp-eval-depth"

时间:2015-08-10 12:50:36

标签: emacs lisp elisp

这为Emacs包Emacs commands history定义了Helm的头盔来源。

(defvar helm-source-emacs-commands-history
    (helm-build-sync-source "Emacs commands history"
    :candidates (lambda ()
                    (let ((cmds))
                    (dolist (elem extended-command-history)
                        (push (intern elem) cmds))
                    cmds))
    :coerce #'intern-soft
    :action #'command-execute)
    "Emacs commands history")

从此源获取您使用M-x调用的最新命令。我想有一个函数,它调用我之前在Emacs中使用M-x调用的最新命令。我看了documentation about list elements

Function: car cons-cell
This function returns the value referred to by the first slot of the cons cell cons-cell. In other words, it returns the CAR of cons-cell.

As a special case, if cons-cell is nil, this function returns nil. Therefore, any list is a valid argument. An error is signaled if the argument is not a cons cell or nil.

(car '(a b c))
    ⇒ a
(car '())
    ⇒ nil

所以我假设我需要用push替换car,然后返回结果。

(dolist (elem extended-command-history)
(car (intern elem))) 

但是我收到了错误消息

Debugger entered -- Lisp error (wrong-type-argument listp Info-next)
(Info-Next)

Info-Next确实是我用M-x跟注的最新命令。但是,我不理解错误。另一种获取最新调用函数的方法。

(defun foobar ()
    (interactive)
    (call-interactively (intern (car extended-command-history))))

调用foobar后,我收到以下错误:

funcall-interactively: Lisp nesting exceeds `max-lisp-eval-depth'

有关获得最新命令的任何建议吗?

0 个答案:

没有答案