aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1998-04-13 06:55:34 +0000
committerKarl Heuer1998-04-13 06:55:34 +0000
commit7dbce55e8ffa07795e32d4c0acc5c59817ab1b59 (patch)
treea800b652ba22d581f1ace80c131f1c43f423232f
parent40437cf54922452d5d8ada8799fbc5e9858f5a3e (diff)
downloademacs-7dbce55e8ffa07795e32d4c0acc5c59817ab1b59.tar.gz
emacs-7dbce55e8ffa07795e32d4c0acc5c59817ab1b59.zip
(eval-defun): Arrange to use eval-region
even if we have to alter the form.
-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.
342With argument, insert value in current buffer after the defun." 342With argument, insert value in current buffer after the defun."
343 (interactive "P") 343 (interactive "P")
344 (let ((standard-output (if eval-defun-arg-internal (current-buffer) t)) 344 (let ((standard-output (if eval-defun-arg-internal (current-buffer) t))
345 (form (save-excursion 345 end form)
346 (end-of-defun) 346 ;; Read the form from the buffer, and record where it ends.
347 (beginning-of-defun) 347 (save-excursion
348 (read (current-buffer))))) 348 (end-of-defun)
349 (beginning-of-defun)
350 (setq form (read (current-buffer)))
351 (setq end (point)))
352 ;; Alter the form if necessary.
349 (cond ((and (eq (car form) 'defvar) 353 (cond ((and (eq (car form) 'defvar)
350 (cdr-safe (cdr-safe form))) 354 (cdr-safe (cdr-safe form)))
351 ;; Force variable to be bound. 355 ;; Force variable to be bound.
@@ -354,7 +358,16 @@ With argument, insert value in current buffer after the defun."
354 (default-boundp (nth 1 form))) 358 (default-boundp (nth 1 form)))
355 ;; Force variable to be bound. 359 ;; Force variable to be bound.
356 (set-default (nth 1 form) (eval (nth 2 form))))) 360 (set-default (nth 1 form) (eval (nth 2 form)))))
357 (prin1 (eval form)))) 361 ;; Now arrange for eval-region to "read" the (possibly) altered form.
362 ;; eval-region handles recording which file defines a function or variable.
363 (save-excursion
364 (let ((load-read-function
365 #'(lambda (ignore)
366 ;; Skipping to the end of the specified region
367 ;; will make eval-region return.
368 (goto-char end)
369 form)))
370 (eval-region (point) end standard-output)))))
358 371
359(defun lisp-comment-indent () 372(defun lisp-comment-indent ()
360 (if (looking-at "\\s<\\s<\\s<") 373 (if (looking-at "\\s<\\s<\\s<")