Mercurial > emacs
comparison lisp/simple.el @ 55799:85609e1fa661
(eval-expression-print-format): New fun.
(eval-expression): Print additionally the value returned by
`eval-expression-print-format'.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Fri, 28 May 2004 21:00:14 +0000 |
parents | 969064cce54e |
children | 594a6cacebfe 62cf3d6337a0 |
comparison
equal
deleted
inserted
replaced
55798:a1bb695e9a0c | 55799:85609e1fa661 |
---|---|
783 If nil, don't change the value of `debug-on-error'." | 783 If nil, don't change the value of `debug-on-error'." |
784 :group 'lisp | 784 :group 'lisp |
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 |
791 &optional eval-expression-insert-value) | 808 &optional eval-expression-insert-value) |
792 "Evaluate EVAL-EXPRESSION-ARG and print value in the echo area. | 809 "Evaluate EVAL-EXPRESSION-ARG and print value in the echo area. |
817 (print-level eval-expression-print-level)) | 834 (print-level eval-expression-print-level)) |
818 (if eval-expression-insert-value | 835 (if eval-expression-insert-value |
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. |
826 COMMAND is a Lisp expression. Let user edit that expression in | 846 COMMAND is a Lisp expression. Let user edit that expression in |
827 the minibuffer, then read and evaluate the result." | 847 the minibuffer, then read and evaluate the result." |