From xemacs-m  Sun Feb 16 03:16:36 1997
Received: from venus.Sun.COM (venus.Sun.COM [192.9.25.5])
	by xemacs.org (8.8.5/8.8.5) with SMTP id DAA21689
	for <xemacs-beta@xemacs.org>; Sun, 16 Feb 1997 03:16:35 -0600 (CST)
Received: from infodock.com (wave.infodock.com [206.13.40.192]) by venus.Sun.COM (SMI-8.6/mail.byaddr) with ESMTP id BAA22944 for <xemacs-beta@xemacs.org>; Sun, 16 Feb 1997 01:16:04 -0800
Received: (from weiner@localhost) by infodock.com (8.7.4/8.7.3) id BAA03800; Sun, 16 Feb 1997 01:15:16 -0800
Date: Sun, 16 Feb 1997 01:15:16 -0800
From: Bob Weiner <weiner@infodock.com>
Message-Id: <199702160915.BAA03800@infodock.com>
To: rms@gnu.ai.mit.edu, kwzh@gnu.ai.mit.edu, xemacs-beta@xemacs.org
Subject: eval-last-sexp, {C-x C-e}, now can evaluate interactive forms.

It occurred to me today that it is a bit silly that when eval-last-sexp
is applied to an (interactive ...) form, the form simply returns nil.
A more useful outcome would be to have it evaluate as it would when
the function is called interactively.  I simply extended eval-last-sexp to
do this.  Evaluate either the GNU Emacs or the XEmacs version
of eval-last-sexp below and then try it out on these forms as examples:
        (interactive "P")
        (interactive "fFile: \nnNum: ")
        (interactive (list (buffer-name) (buffer-size)))

I hope you'll make this the default behavior; it will even make a good
learning tool for new Emacs Lisp programmers.

Bob

;;
;; Version For GNU Emacs:
;;
(defun eval-last-sexp (eval-last-sexp-arg-internal)
  "Evaluate sexp before point; print value in minibuffer.
With argument, print output into current buffer."
  (interactive "P")
  (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))
	(opoint (point)))
    (prin1 (let ((stab (syntax-table))
		 expr)
	     (eval (unwind-protect
		       (save-excursion
			 (set-syntax-table emacs-lisp-mode-syntax-table)
			 (forward-sexp -1)
			 (save-restriction
			   (narrow-to-region (point-min) opoint)
			   (setq expr (read (current-buffer)))
			   (if (and (consp expr)
				    (eq (car expr) 'interactive))
			       (list 'quote
				     (call-interactively
				      (eval (` (lambda (&rest args)
						 (, expr) args)))))
			     expr)))
		     (set-syntax-table stab)))))))

;;
;; Version for XEmacs:
;;
(defun eval-last-sexp (eval-last-sexp-arg-internal) ;dynamic scoping wonderment
  "Evaluate sexp before point; print value in minibuffer.
With argument, print output into current buffer."
  (interactive "P")
  (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))
	(opoint (point)))
    (prin1 (let ((stab (syntax-table))
		 expr)
	     (eval-interactive
	      (unwind-protect
		  (save-excursion
		    (set-syntax-table emacs-lisp-mode-syntax-table)
		    (forward-sexp -1)
		    (save-restriction
		      (narrow-to-region (point-min) opoint)
		      (setq expr (read (current-buffer)))
		      (if (and (consp expr)
			       (eq (car expr) 'interactive))
			  (list 'quote
				(call-interactively
				 (eval (` (lambda (&rest args)
					    (, expr) args)))))
			expr)))
		(set-syntax-table stab)))))))

