summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorGerd Moellmann <gerd@gnu.org>2001-07-26 12:31:38 +0000
committerGerd Moellmann <gerd@gnu.org>2001-07-26 12:31:38 +0000
commit5f0962558df85aeae85511bf2abf85e6a035544d (patch)
tree9cb3280673329ff58bcdc503c47375ecf3cc6726 /lisp/emacs-lisp
parent8c3b00cbc782478efd4682ef12542937d7d59228 (diff)
downloademacs-5f0962558df85aeae85511bf2abf85e6a035544d.tar.gz
emacs-5f0962558df85aeae85511bf2abf85e6a035544d.tar.bz2
emacs-5f0962558df85aeae85511bf2abf85e6a035544d.zip
(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.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/lisp-mode.el31
1 files changed, 28 insertions, 3 deletions
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.