This defines the Helm-source for
Emacs commands history.
(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")
From this source you get the latest commands that you called with
M-x. I would have a function, that calls the latest command that I called with
M-x earlier. I read the 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
So I assume I need to replace the
car, and return the result.
(dolist (elem extended-command-history) (car (intern elem)))
But I got the error message
Debugger entered -- Lisp error (wrong-type-argument listp Info-next) (Info-Next)
Info-Next was indeed the latest command that I called with
M-x. However, I don't understand the error. Another way to get the latest called function.
(defun foobar () (interactive) (call-interactively (intern (car extended-command-history))))
foobar, I get the following error:
funcall-interactively: Lisp nesting exceeds `max-lisp-eval-depth'
Any suggestion to get the latest command?