comparison lisp/emacs-lisp/lisp-mode.el @ 51425:346b661f431e

(eval-last-sexp-1): Add save-excursion.
author Richard M. Stallman <rms@gnu.org>
date Tue, 03 Jun 2003 11:10:31 +0000
parents 0e0d3c3dca7f
children d3d6b202a5f2
comparison
equal deleted inserted replaced
51424:26d468be5b3c 51425:346b661f431e
467 (let ((value 467 (let ((value
468 (eval (let ((stab (syntax-table)) 468 (eval (let ((stab (syntax-table))
469 (opoint (point)) 469 (opoint (point))
470 ignore-quotes 470 ignore-quotes
471 expr) 471 expr)
472 (with-syntax-table emacs-lisp-mode-syntax-table 472 (save-excursion
473 ;; If this sexp appears to be enclosed in `...' 473 (with-syntax-table emacs-lisp-mode-syntax-table
474 ;; then ignore the surrounding quotes. 474 ;; If this sexp appears to be enclosed in `...'
475 (setq ignore-quotes 475 ;; then ignore the surrounding quotes.
476 (or (eq (following-char) ?\') 476 (setq ignore-quotes
477 (eq (preceding-char) ?\'))) 477 (or (eq (following-char) ?\')
478 (forward-sexp -1) 478 (eq (preceding-char) ?\')))
479 ;; If we were after `?\e' (or similar case), 479 (forward-sexp -1)
480 ;; use the whole thing, not just the `e'. 480 ;; If we were after `?\e' (or similar case),
481 (when (eq (preceding-char) ?\\) 481 ;; use the whole thing, not just the `e'.
482 (forward-char -1) 482 (when (eq (preceding-char) ?\\)
483 (when (eq (preceding-char) ??) 483 (forward-char -1)
484 (forward-char -1))) 484 (when (eq (preceding-char) ??)
485 485 (forward-char -1)))
486 ;; Skip over `#N='s. 486
487 (when (eq (preceding-char) ?=) 487 ;; Skip over `#N='s.
488 (let (labeled-p) 488 (when (eq (preceding-char) ?=)
489 (save-excursion 489 (let (labeled-p)
490 (skip-chars-backward "0-9#=") 490 (save-excursion
491 (setq labeled-p (looking-at "\\(#[0-9]+=\\)+"))) 491 (skip-chars-backward "0-9#=")
492 (when labeled-p 492 (setq labeled-p (looking-at "\\(#[0-9]+=\\)+")))
493 (forward-sexp -1)))) 493 (when labeled-p
494 494 (forward-sexp -1))))
495 (save-restriction 495
496 ;; vladimir@cs.ualberta.ca 30-Jul-1997: skip ` in 496 (save-restriction
497 ;; `variable' so that the value is returned, not the 497 ;; vladimir@cs.ualberta.ca 30-Jul-1997: skip ` in
498 ;; name 498 ;; `variable' so that the value is returned, not the
499 (if (and ignore-quotes 499 ;; name
500 (eq (following-char) ?`)) 500 (if (and ignore-quotes
501 (forward-char)) 501 (eq (following-char) ?`))
502 (narrow-to-region (point-min) opoint) 502 (forward-char))
503 (setq expr (read (current-buffer))) 503 (narrow-to-region (point-min) opoint)
504 ;; If it's an (interactive ...) form, it's more 504 (setq expr (read (current-buffer)))
505 ;; useful to show how an interactive call would 505 ;; If it's an (interactive ...) form, it's more
506 ;; use it. 506 ;; useful to show how an interactive call would
507 (and (consp expr) 507 ;; use it.
508 (eq (car expr) 'interactive) 508 (and (consp expr)
509 (setq expr 509 (eq (car expr) 'interactive)
510 (list 'call-interactively 510 (setq expr
511 (list 'quote 511 (list 'call-interactively
512 (list 'lambda 512 (list 'quote
513 '(&rest args) 513 (list 'lambda
514 expr 514 '(&rest args)
515 'args))))) 515 expr
516 expr)))))) 516 'args)))))
517 expr)))))))
517 (let ((unabbreviated (let ((print-length nil) (print-level nil)) 518 (let ((unabbreviated (let ((print-length nil) (print-level nil))
518 (prin1-to-string value))) 519 (prin1-to-string value)))
519 (print-length eval-expression-print-length) 520 (print-length eval-expression-print-length)
520 (print-level eval-expression-print-level) 521 (print-level eval-expression-print-level)
521 (char-string (prin1-char value)) 522 (char-string (prin1-char value))