summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1998-04-13 06:55:34 +0000
committerKarl Heuer <kwzh@gnu.org>1998-04-13 06:55:34 +0000
commit7dbce55e8ffa07795e32d4c0acc5c59817ab1b59 (patch)
treea800b652ba22d581f1ace80c131f1c43f423232f /lisp/emacs-lisp
parent40437cf54922452d5d8ada8799fbc5e9858f5a3e (diff)
downloademacs-7dbce55e8ffa07795e32d4c0acc5c59817ab1b59.tar.gz
emacs-7dbce55e8ffa07795e32d4c0acc5c59817ab1b59.tar.bz2
emacs-7dbce55e8ffa07795e32d4c0acc5c59817ab1b59.zip
(eval-defun): Arrange to use eval-region
even if we have to alter the form.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/lisp-mode.el23
1 files changed, 18 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 109a891b579..473ecd734e8 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -342,10 +342,14 @@ Print value in minibuffer.
With argument, insert value in current buffer after the defun."
(interactive "P")
(let ((standard-output (if eval-defun-arg-internal (current-buffer) t))
- (form (save-excursion
- (end-of-defun)
- (beginning-of-defun)
- (read (current-buffer)))))
+ end form)
+ ;; Read the form from the buffer, and record where it ends.
+ (save-excursion
+ (end-of-defun)
+ (beginning-of-defun)
+ (setq form (read (current-buffer)))
+ (setq end (point)))
+ ;; Alter the form if necessary.
(cond ((and (eq (car form) 'defvar)
(cdr-safe (cdr-safe form)))
;; Force variable to be bound.
@@ -354,7 +358,16 @@ With argument, insert value in current buffer after the defun."
(default-boundp (nth 1 form)))
;; Force variable to be bound.
(set-default (nth 1 form) (eval (nth 2 form)))))
- (prin1 (eval form))))
+ ;; Now arrange for eval-region to "read" the (possibly) altered form.
+ ;; eval-region handles recording which file defines a function or variable.
+ (save-excursion
+ (let ((load-read-function
+ #'(lambda (ignore)
+ ;; Skipping to the end of the specified region
+ ;; will make eval-region return.
+ (goto-char end)
+ form)))
+ (eval-region (point) end standard-output)))))
(defun lisp-comment-indent ()
(if (looking-at "\\s<\\s<\\s<")