From: Gerd Moellmann Date: Thu, 26 Jul 2001 12:31:38 +0000 (+0000) Subject: (last-sexp-print): New function. X-Git-Tag: emacs-pretest-21.0.105~380 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5f0962558df85aeae85511bf2abf85e6a035544d;p=emacs.git (last-sexp-print): New function. (eval-last-sexp-1): Give printed text a `keymap' property and bind and in that map to a function printing the unabbreviated value. --- diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 252e35d33cb..093357c5b43 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -319,6 +319,18 @@ which see." (eval-last-sexp t) (terpri))) + +(defun last-sexp-print () + (interactive) + (let ((value (get-text-property (point) 'printed-value))) + (when value + (let ((beg (previous-single-property-change (point) 'printed-value)) + (end (next-single-char-property-change (point) 'printed-value)) + (standard-output (current-buffer))) + (delete-region beg end) + (prin1 value))))) + + (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in minibuffer. With argument, print output into current buffer." @@ -378,10 +390,23 @@ With argument, print output into current buffer." (set-syntax-table stab)))))) (let ((print-length eval-expression-print-length) (print-level eval-expression-print-level) - (start (point))) + (beg (point))) (prin1 value) - (when (bufferp standard-output) - (put-text-property start (point) 'printed-value value)))))) + (when (and (bufferp standard-output) + (or (not (null print-length)) + (not (null print-level)))) + (let ((map (make-sparse-keymap)) + (end (point))) + (define-key map "\C-m" 'last-sexp-print) + (define-key map [down-mouse-2] 'mouse-set-point) + (define-key map [mouse-2] 'last-sexp-print) + (add-text-properties + beg end + `(printed-value ,value + mouse-face highlight + keymap ,map + help-echo "RET, mouse-2: print unabbreviated")))))))) + (defun eval-last-sexp (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in minibuffer.