diff options
| author | Juri Linkov | 2004-05-28 21:00:14 +0000 |
|---|---|---|
| committer | Juri Linkov | 2004-05-28 21:00:14 +0000 |
| commit | fa219ebdf78561d9f74619522ab9c70bc1badafa (patch) | |
| tree | e52f8a475969a161e9b75596ae8ebf12276e9b38 | |
| parent | b40ea20a66404a42ee11d2690b8aa8657fba3388 (diff) | |
| download | emacs-fa219ebdf78561d9f74619522ab9c70bc1badafa.tar.gz emacs-fa219ebdf78561d9f74619522ab9c70bc1badafa.zip | |
(eval-expression-print-format): New fun.
(eval-expression): Print additionally the value returned by
`eval-expression-print-format'.
| -rw-r--r-- | lisp/simple.el | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 1cf3601b5b1..c72b6a929de 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -785,6 +785,23 @@ If nil, don't change the value of `debug-on-error'." | |||
| 785 | :type 'boolean | 785 | :type 'boolean |
| 786 | :version "21.1") | 786 | :version "21.1") |
| 787 | 787 | ||
| 788 | (defun eval-expression-print-format (value) | ||
| 789 | "Format VALUE as a result of evaluated expression. | ||
| 790 | Return a formatted string which is displayed in the echo area | ||
| 791 | in addition to the value printed by prin1 in functions which | ||
| 792 | display the result of expression evaluation." | ||
| 793 | (if (and (integerp value) | ||
| 794 | (or (not (eq this-command 'eval-last-sexp)) | ||
| 795 | (eq this-command last-command) | ||
| 796 | (and (boundp 'edebug-active) edebug-active))) | ||
| 797 | (let ((char-string | ||
| 798 | (if (or (and (boundp 'edebug-active) edebug-active) | ||
| 799 | (eq this-command 'eval-last-sexp)) | ||
| 800 | (prin1-char value)))) | ||
| 801 | (if char-string | ||
| 802 | (format " (0%o, 0x%x) = %s" value value char-string) | ||
| 803 | (format " (0%o, 0x%x)" value value))))) | ||
| 804 | |||
| 788 | ;; We define this, rather than making `eval' interactive, | 805 | ;; We define this, rather than making `eval' interactive, |
| 789 | ;; for the sake of completion of names like eval-region, eval-current-buffer. | 806 | ;; for the sake of completion of names like eval-region, eval-current-buffer. |
| 790 | (defun eval-expression (eval-expression-arg | 807 | (defun eval-expression (eval-expression-arg |
| @@ -819,7 +836,10 @@ the echo area." | |||
| 819 | (with-no-warnings | 836 | (with-no-warnings |
| 820 | (let ((standard-output (current-buffer))) | 837 | (let ((standard-output (current-buffer))) |
| 821 | (eval-last-sexp-print-value (car values)))) | 838 | (eval-last-sexp-print-value (car values)))) |
| 822 | (prin1 (car values) t)))) | 839 | (prog1 |
| 840 | (prin1 (car values) t) | ||
| 841 | (let ((str (eval-expression-print-format (car values)))) | ||
| 842 | (if str (princ str t))))))) | ||
| 823 | 843 | ||
| 824 | (defun edit-and-eval-command (prompt command) | 844 | (defun edit-and-eval-command (prompt command) |
| 825 | "Prompting with PROMPT, let user edit COMMAND and eval result. | 845 | "Prompting with PROMPT, let user edit COMMAND and eval result. |