Function: edit-and-eval-command

edit-and-eval-command is a byte-compiled function defined in simple.el.gz.

Signature

(edit-and-eval-command PROMPT COMMAND)

Documentation

Prompting with PROMPT, let user edit COMMAND and eval result.

COMMAND is a Lisp expression. Let user edit that expression in the minibuffer, then read and evaluate the result.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun edit-and-eval-command (prompt command)
  "Prompting with PROMPT, let user edit COMMAND and eval result.
COMMAND is a Lisp expression.  Let user edit that expression in
the minibuffer, then read and evaluate the result."
  (let ((command
	 (let ((print-level nil)
	       (minibuffer-history-sexp-flag (1+ (minibuffer-depth))))
	   (unwind-protect
	       (read-from-minibuffer prompt
				     (prin1-to-string command)
				     read-expression-map t
				     'command-history)
	     ;; If command was added to command-history as a string,
	     ;; get rid of that.  We want only evaluable expressions there.
             (when (stringp (car command-history))
               (pop command-history))))))

    (add-to-history 'command-history command)
    (eval command)))