comparison lisp/emacs-lisp/lisp-mode.el @ 91010:aaccdab0ee26

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 852-856) - Update from CVS - Merge from emacs--rel--22 * emacs--rel--22 (patch 93-96) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 245) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-249
author Miles Bader <miles@gnu.org>
date Tue, 21 Aug 2007 04:54:03 +0000
parents 539530fa389c 6499a8de7fcb
children bdb3fe0ba9fa
comparison
equal deleted inserted replaced
91009:e7395a700642 91010:aaccdab0ee26
537 (and string 537 (and string
538 (= (car (read-from-string string)) char) 538 (= (car (read-from-string string)) char)
539 string)))) 539 string))))
540 540
541 541
542 (defun preceding-sexp ()
543 "Return sexp before the point."
544 (let ((opoint (point))
545 ignore-quotes
546 expr)
547 (save-excursion
548 (with-syntax-table emacs-lisp-mode-syntax-table
549 ;; If this sexp appears to be enclosed in `...'
550 ;; then ignore the surrounding quotes.
551 (setq ignore-quotes
552 (or (eq (following-char) ?\')
553 (eq (preceding-char) ?\')))
554 (forward-sexp -1)
555 ;; If we were after `?\e' (or similar case),
556 ;; use the whole thing, not just the `e'.
557 (when (eq (preceding-char) ?\\)
558 (forward-char -1)
559 (when (eq (preceding-char) ??)
560 (forward-char -1)))
561
562 ;; Skip over `#N='s.
563 (when (eq (preceding-char) ?=)
564 (let (labeled-p)
565 (save-excursion
566 (skip-chars-backward "0-9#=")
567 (setq labeled-p (looking-at "\\(#[0-9]+=\\)+")))
568 (when labeled-p
569 (forward-sexp -1))))
570
571 (save-restriction
572 ;; vladimir@cs.ualberta.ca 30-Jul-1997: skip ` in
573 ;; `variable' so that the value is returned, not the
574 ;; name
575 (if (and ignore-quotes
576 (eq (following-char) ?`))
577 (forward-char))
578 (narrow-to-region (point-min) opoint)
579 (setq expr (read (current-buffer)))
580 ;; If it's an (interactive ...) form, it's more
581 ;; useful to show how an interactive call would
582 ;; use it.
583 (and (consp expr)
584 (eq (car expr) 'interactive)
585 (setq expr
586 (list 'call-interactively
587 (list 'quote
588 (list 'lambda
589 '(&rest args)
590 expr
591 'args)))))
592 expr)))))
593
594
542 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) 595 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal)
543 "Evaluate sexp before point; print value in minibuffer. 596 "Evaluate sexp before point; print value in minibuffer.
544 With argument, print output into current buffer." 597 With argument, print output into current buffer."
545 (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))) 598 (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t)))
546 (let ((value 599 (eval-last-sexp-print-value (eval (preceding-sexp)))))
547 (eval (let ((stab (syntax-table)) 600
548 (opoint (point))
549 ignore-quotes
550 expr)
551 (save-excursion
552 (with-syntax-table emacs-lisp-mode-syntax-table
553 ;; If this sexp appears to be enclosed in `...'
554 ;; then ignore the surrounding quotes.
555 (setq ignore-quotes
556 (or (eq (following-char) ?\')
557 (eq (preceding-char) ?\')))
558 (forward-sexp -1)
559 ;; If we were after `?\e' (or similar case),
560 ;; use the whole thing, not just the `e'.
561 (when (eq (preceding-char) ?\\)
562 (forward-char -1)
563 (when (eq (preceding-char) ??)
564 (forward-char -1)))
565
566 ;; Skip over `#N='s.
567 (when (eq (preceding-char) ?=)
568 (let (labeled-p)
569 (save-excursion
570 (skip-chars-backward "0-9#=")
571 (setq labeled-p (looking-at "\\(#[0-9]+=\\)+")))
572 (when labeled-p
573 (forward-sexp -1))))
574
575 (save-restriction
576 ;; vladimir@cs.ualberta.ca 30-Jul-1997: skip ` in
577 ;; `variable' so that the value is returned, not the
578 ;; name
579 (if (and ignore-quotes
580 (eq (following-char) ?`))
581 (forward-char))
582 (narrow-to-region (point-min) opoint)
583 (setq expr (read (current-buffer)))
584 ;; If it's an (interactive ...) form, it's more
585 ;; useful to show how an interactive call would
586 ;; use it.
587 (and (consp expr)
588 (eq (car expr) 'interactive)
589 (setq expr
590 (list 'call-interactively
591 (list 'quote
592 (list 'lambda
593 '(&rest args)
594 expr
595 'args)))))
596 expr)))))))
597 (eval-last-sexp-print-value value))))
598 601
599 (defun eval-last-sexp-print-value (value) 602 (defun eval-last-sexp-print-value (value)
600 (let ((unabbreviated (let ((print-length nil) (print-level nil)) 603 (let ((unabbreviated (let ((print-length nil) (print-level nil))
601 (prin1-to-string value))) 604 (prin1-to-string value)))
602 (print-length eval-expression-print-length) 605 (print-length eval-expression-print-length)