changeset 38585:f2c0f6df43ab

(last-sexp-setup-props): New function. (last-sexp-toggle-display): Renamed from last-sexp-print. (last-sexp-toggle-display, eval-last-sexp-1): Use last-sexp-setup-props.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 27 Jul 2001 15:26:53 +0000
parents 9987609b0554
children fde4f76bf531
files lisp/emacs-lisp/lisp-mode.el
diffstat 1 files changed, 34 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/lisp-mode.el	Fri Jul 27 11:13:18 2001 +0000
+++ b/lisp/emacs-lisp/lisp-mode.el	Fri Jul 27 15:26:53 2001 +0000
@@ -320,17 +320,41 @@
     (terpri)))
 
 
-(defun last-sexp-print ()
+(defun last-sexp-setup-props (beg end value alt1 alt2)
+  "Set up text properties for the output of `eval-last-sexp-1'.
+BEG and END are the start and end of the output in current-buffer.
+VALUE is the Lisp value printed, ALT1 and ALT2 are strings for the 
+alternative printed representations that can be displayed."
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-m" 'last-sexp-toggle-display)
+    (define-key map [down-mouse-2] 'mouse-set-point)
+    (define-key map [mouse-2] 'last-sexp-toggle-display)
+    (add-text-properties
+     beg end 
+     `(printed-value (,value ,alt1 ,alt2)
+		     mouse-face highlight 
+		     keymap ,map
+		     help-echo "RET, mouse-2: toggle abbreviated display"
+		     rear-nonsticky (mouse-face keymap help-echo
+						printed-value)))))
+
+
+(defun last-sexp-toggle-display ()
+  "Toggle between abbreviated and unabbreviated printed representations."
   (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))
-	    (print-length nil)
-	    (print-level nil))
+	    (point (point)))
 	(delete-region beg end)
-	(prin1 value)))))
+	(insert (nth 1 value))
+	(last-sexp-setup-props beg (point) 
+			       (nth 0 value)
+			       (nth 2 value)
+			       (nth 1 value))
+	(goto-char (min (point-max) point))))))
 
 
 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal)
@@ -401,20 +425,12 @@
 	(when (and (bufferp standard-output)
 		   (or (not (null print-length))
 		       (not (null print-level)))
-		   (not (string= unabbreviated (buffer-substring beg end))))
-	  (let ((map (make-sparse-keymap)))
-	    (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"
-			     read-nonsticky (mouse-face keymap help-echo
-							printed-value)
-			     ))))))))
+		   (not (string= unabbreviated
+				 (buffer-substring-no-properties beg end))))
+	  (last-sexp-setup-props beg end value 
+				 unabbreviated
+				 (buffer-substring-no-properties beg end))
+	  )))))
 
 
 (defun eval-last-sexp (eval-last-sexp-arg-internal)