comparison lisp/emacs-lisp/lisp-mode.el @ 27303:6af9b684a1a0

(eval-last-sexp-1): Renamed from eval-last-sexp. Don't bind debug-on-error here. (eval-last-sexp): New function. Bind debug-on-error if eval-expression-debug-on-error is non-nil. (eval-defun-2, eval-defun): Likewise.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 12 Jan 2000 13:10:17 +0000
parents baffb2de5ce9
children a681b4de47a1
comparison
equal deleted inserted replaced
27302:1cb6c18c3163 27303:6af9b684a1a0
330 (let ((standard-output (current-buffer))) 330 (let ((standard-output (current-buffer)))
331 (terpri) 331 (terpri)
332 (eval-last-sexp t) 332 (eval-last-sexp t)
333 (terpri))) 333 (terpri)))
334 334
335 (defun eval-last-sexp (eval-last-sexp-arg-internal) 335 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal)
336 "Evaluate sexp before point; print value in minibuffer. 336 "Evaluate sexp before point; print value in minibuffer.
337 With argument, print output into current buffer." 337 With argument, print output into current buffer."
338 (interactive "P") 338 (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t)))
339 (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))
340 (debug-on-error eval-expression-debug-on-error))
341 (let ((value 339 (let ((value
342 (eval (let ((stab (syntax-table)) 340 (eval (let ((stab (syntax-table))
343 (opoint (point)) 341 (opoint (point))
344 ignore-quotes 342 ignore-quotes
345 expr) 343 expr)
383 (set-syntax-table stab)))))) 381 (set-syntax-table stab))))))
384 (let ((print-length eval-expression-print-length) 382 (let ((print-length eval-expression-print-length)
385 (print-level eval-expression-print-level)) 383 (print-level eval-expression-print-level))
386 (prin1 value))))) 384 (prin1 value)))))
387 385
386 (defun eval-last-sexp (eval-last-sexp-arg-internal)
387 "Evaluate sexp before point; print value in minibuffer.
388 With argument, print output into current buffer."
389 (interactive "P")
390 (if (null eval-expression-debug-on-error)
391 (eval-last-sexp-1 eval-last-sexp-arg-internal)
392 (let ((old-value (make-symbol "t")) new-value value)
393 (let ((debug-on-error old-value))
394 (setq value (eval-last-sexp-1 eval-last-sexp-arg-internal))
395 (setq new-value debug-on-error))
396 (unless (eq old-value new-value)
397 (setq debug-on-error new-value))
398 value)))
399
388 ;; Change defvar into defconst within FORM, 400 ;; Change defvar into defconst within FORM,
389 ;; and likewise for other constructs as necessary. 401 ;; and likewise for other constructs as necessary.
390 (defun eval-defun-1 (form) 402 (defun eval-defun-1 (form)
391 (cond ((and (eq (car form) 'defvar) 403 (cond ((and (eq (car form) 'defvar)
392 (cdr-safe (cdr-safe form))) 404 (cdr-safe (cdr-safe form)))
399 form) 411 form)
400 ((eq (car form) 'progn) 412 ((eq (car form) 'progn)
401 (cons 'progn (mapcar 'eval-defun-1 (cdr form)))) 413 (cons 'progn (mapcar 'eval-defun-1 (cdr form))))
402 (t form))) 414 (t form)))
403 415
404 (defun eval-defun (eval-defun-arg-internal) 416 (defun eval-defun-2 (eval-defun-arg-internal)
405 "Evaluate defun that point is in or before. 417 "Evaluate defun that point is in or before.
406 The value is displayed in the minibuffer. 418 The value is displayed in the minibuffer.
407 If the current defun is actually a call to `defvar', 419 If the current defun is actually a call to `defvar',
408 then reset the variable using the initial value expression 420 then reset the variable using the initial value expression
409 even if the variable already has some other value. 421 even if the variable already has some other value.
440 ;; will make eval-region return. 452 ;; will make eval-region return.
441 (goto-char ,end) 453 (goto-char ,end)
442 ',form)))))) 454 ',form))))))
443 ;; The result of evaluation has been put onto VALUES. So return it. 455 ;; The result of evaluation has been put onto VALUES. So return it.
444 (car values)) 456 (car values))
457
458 (defun eval-defun (eval-defun-arg-internal)
459 "Evaluate defun that point is in or before.
460 The value is displayed in the minibuffer.
461 If the current defun is actually a call to `defvar',
462 then reset the variable using the initial value expression
463 even if the variable already has some other value.
464 \(Normally `defvar' does not change the variable's value
465 if it already has a value.\)
466
467 With argument, insert value in current buffer after the defun.
468 Return the result of evaluation."
469 (interactive "P")
470 (if (null eval-expression-debug-on-error)
471 (eval-defun-2 eval-defun-arg-internal)
472 (let ((old-value (make-symbol "t")) new-value value)
473 (let ((debug-on-error old-value))
474 (setq value (eval-defun-2 eval-defun-arg-internal))
475 (setq new-value debug-on-error))
476 (unless (eq old-value new-value)
477 (setq debug-on-error new-value))
478 value)))
479
445 480
446 (defun lisp-comment-indent () 481 (defun lisp-comment-indent ()
447 (if (looking-at "\\s<\\s<\\s<") 482 (if (looking-at "\\s<\\s<\\s<")
448 (current-column) 483 (current-column)
449 (if (looking-at "\\s<\\s<") 484 (if (looking-at "\\s<\\s<")