changeset 38572:107f826252d2

(last-sexp-print): New function. (eval-last-sexp-1): Give printed text a `keymap' property and bind <mouse-2> and <RET> in that map to a function printing the unabbreviated value.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 26 Jul 2001 12:31:38 +0000
parents a404db64bdb2
children 37d0e44d564c
files lisp/emacs-lisp/lisp-mode.el
diffstat 1 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/lisp-mode.el	Thu Jul 26 10:06:32 2001 +0000
+++ b/lisp/emacs-lisp/lisp-mode.el	Thu Jul 26 12:31:38 2001 +0000
@@ -319,6 +319,18 @@
     (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 @@
 		     (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.