summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/lisp-mode.el
diff options
context:
space:
mode:
authorGerd Moellmann <gerd@gnu.org>2001-07-27 15:26:53 +0000
committerGerd Moellmann <gerd@gnu.org>2001-07-27 15:26:53 +0000
commitcb79ea6486c16cabfe57290aef03c83bee090f74 (patch)
tree8d409224dc44ad92795afd155de08da7cb6b98c1 /lisp/emacs-lisp/lisp-mode.el
parentf936978f843670594eea5f01345cc512622df7f7 (diff)
downloademacs-cb79ea6486c16cabfe57290aef03c83bee090f74.tar.gz
emacs-cb79ea6486c16cabfe57290aef03c83bee090f74.tar.bz2
emacs-cb79ea6486c16cabfe57290aef03c83bee090f74.zip
(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.
Diffstat (limited to 'lisp/emacs-lisp/lisp-mode.el')
-rw-r--r--lisp/emacs-lisp/lisp-mode.el52
1 files changed, 34 insertions, 18 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 0241993421c..7cae7a92a7b 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -320,17 +320,41 @@ which see."
(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 @@ With argument, print output into current buffer."
(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)