diff options
| author | Gerd Moellmann | 2001-07-27 15:26:53 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-07-27 15:26:53 +0000 |
| commit | cb79ea6486c16cabfe57290aef03c83bee090f74 (patch) | |
| tree | 8d409224dc44ad92795afd155de08da7cb6b98c1 | |
| parent | f936978f843670594eea5f01345cc512622df7f7 (diff) | |
| download | emacs-cb79ea6486c16cabfe57290aef03c83bee090f74.tar.gz 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.
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 52 |
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." | |||
| 320 | (terpri))) | 320 | (terpri))) |
| 321 | 321 | ||
| 322 | 322 | ||
| 323 | (defun last-sexp-print () | 323 | (defun last-sexp-setup-props (beg end value alt1 alt2) |
| 324 | "Set up text properties for the output of `eval-last-sexp-1'. | ||
| 325 | BEG and END are the start and end of the output in current-buffer. | ||
| 326 | VALUE is the Lisp value printed, ALT1 and ALT2 are strings for the | ||
| 327 | alternative printed representations that can be displayed." | ||
| 328 | (let ((map (make-sparse-keymap))) | ||
| 329 | (define-key map "\C-m" 'last-sexp-toggle-display) | ||
| 330 | (define-key map [down-mouse-2] 'mouse-set-point) | ||
| 331 | (define-key map [mouse-2] 'last-sexp-toggle-display) | ||
| 332 | (add-text-properties | ||
| 333 | beg end | ||
| 334 | `(printed-value (,value ,alt1 ,alt2) | ||
| 335 | mouse-face highlight | ||
| 336 | keymap ,map | ||
| 337 | help-echo "RET, mouse-2: toggle abbreviated display" | ||
| 338 | rear-nonsticky (mouse-face keymap help-echo | ||
| 339 | printed-value))))) | ||
| 340 | |||
| 341 | |||
| 342 | (defun last-sexp-toggle-display () | ||
| 343 | "Toggle between abbreviated and unabbreviated printed representations." | ||
| 324 | (interactive) | 344 | (interactive) |
| 325 | (let ((value (get-text-property (point) 'printed-value))) | 345 | (let ((value (get-text-property (point) 'printed-value))) |
| 326 | (when value | 346 | (when value |
| 327 | (let ((beg (previous-single-property-change (point) 'printed-value)) | 347 | (let ((beg (previous-single-property-change (point) 'printed-value)) |
| 328 | (end (next-single-char-property-change (point) 'printed-value)) | 348 | (end (next-single-char-property-change (point) 'printed-value)) |
| 329 | (standard-output (current-buffer)) | 349 | (standard-output (current-buffer)) |
| 330 | (print-length nil) | 350 | (point (point))) |
| 331 | (print-level nil)) | ||
| 332 | (delete-region beg end) | 351 | (delete-region beg end) |
| 333 | (prin1 value))))) | 352 | (insert (nth 1 value)) |
| 353 | (last-sexp-setup-props beg (point) | ||
| 354 | (nth 0 value) | ||
| 355 | (nth 2 value) | ||
| 356 | (nth 1 value)) | ||
| 357 | (goto-char (min (point-max) point)))))) | ||
| 334 | 358 | ||
| 335 | 359 | ||
| 336 | (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) | 360 | (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) |
| @@ -401,20 +425,12 @@ With argument, print output into current buffer." | |||
| 401 | (when (and (bufferp standard-output) | 425 | (when (and (bufferp standard-output) |
| 402 | (or (not (null print-length)) | 426 | (or (not (null print-length)) |
| 403 | (not (null print-level))) | 427 | (not (null print-level))) |
| 404 | (not (string= unabbreviated (buffer-substring beg end)))) | 428 | (not (string= unabbreviated |
| 405 | (let ((map (make-sparse-keymap))) | 429 | (buffer-substring-no-properties beg end)))) |
| 406 | (define-key map "\C-m" 'last-sexp-print) | 430 | (last-sexp-setup-props beg end value |
| 407 | (define-key map [down-mouse-2] 'mouse-set-point) | 431 | unabbreviated |
| 408 | (define-key map [mouse-2] 'last-sexp-print) | 432 | (buffer-substring-no-properties beg end)) |
| 409 | (add-text-properties | 433 | ))))) |
| 410 | beg end | ||
| 411 | `(printed-value ,value | ||
| 412 | mouse-face highlight | ||
| 413 | keymap ,map | ||
| 414 | help-echo "RET, mouse-2: print unabbreviated" | ||
| 415 | read-nonsticky (mouse-face keymap help-echo | ||
| 416 | printed-value) | ||
| 417 | )))))))) | ||
| 418 | 434 | ||
| 419 | 435 | ||
| 420 | (defun eval-last-sexp (eval-last-sexp-arg-internal) | 436 | (defun eval-last-sexp (eval-last-sexp-arg-internal) |