[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printing most-negative-fixnum fails
From: |
Juri Linkov |
Subject: |
Re: printing most-negative-fixnum fails |
Date: |
Sat, 15 May 2004 11:09:07 +0300 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
Richard Stallman <address@hidden> writes:
> However, adding an option is a very undesirable way to solve such a
> problem. It is costly in complexity and will leave many users
> unsatisfied.
Instead of adding an option, I propose to add a new function
to format values of evaluated expressions. This function
will return a formatted string based on the result of evaluation.
Another reason for having a special formatting function is that the
same formatting is used in three places: eval-last-sexp (C-x C-e),
eval-expression (M-:) and edebug.
Currently, by default it prints a character, until the problem with
printing characters will be resolved. But at least with a separate
formatting function users can easily change the default format by
redefining this function.
Index: emacs/lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.642
diff -u -r1.642 simple.el
--- emacs/lisp/simple.el 7 May 2004 22:31:54 -0000 1.642
+++ emacs/lisp/simple.el 15 May 2004 07:15:29 -0000
@@ -772,6 +819,21 @@
:type 'boolean
:version "21.1")
+(defun eval-expression-display-format (value)
+ "Default function to format values of evaluated expressions.
+Return a formatted string which is displayed in the echo area
+in addition to the value printed by prin1 in functions that
+display results of expression evaluation."
+ (if (integerp value)
+ (let ((char-string (prin1-char value)))
+ (if char-string
+ (format " (0%o, 0x%x) = %s" value value char-string)
+ (format " (0%o, 0x%x)" value value)))))
+
;; We define this, rather than making `eval' interactive,
;; for the sake of completion of names like eval-region, eval-current-buffer.
(defun eval-expression (eval-expression-arg
@@ -806,7 +868,10 @@
(with-no-warnings
(let ((standard-output (current-buffer)))
(eval-last-sexp-print-value (car values))))
- (prin1 (car values) t))))
+ (prog1
+ (prin1 (car values) t)
+ (let ((str (eval-expression-display-format (car values))))
+ (if str (princ str t)))))))
(defun edit-and-eval-command (prompt command)
"Prompting with PROMPT, let user edit COMMAND and eval result.
Index: emacs/lisp/emacs-lisp/lisp-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v
retrieving revision 1.156
diff -u -r1.156 lisp-mode.el
--- emacs/lisp/emacs-lisp/lisp-mode.el 11 May 2004 03:17:59 -0000 1.156
+++ emacs/lisp/emacs-lisp/lisp-mode.el 15 May 2004 07:15:26 -0000
@@ -524,13 +526,13 @@
(prin1-to-string value)))
(print-length eval-expression-print-length)
(print-level eval-expression-print-level)
- (char-string (prin1-char value))
(beg (point))
end)
(prog1
(prin1 value)
- (if (and (eq standard-output t) char-string)
- (princ (concat " = " char-string)))
+ (if (eq standard-output t)
+ (let ((str (eval-expression-display-format value)))
+ (if str (princ str))))
(setq end (point))
(when (and (bufferp standard-output)
(or (not (null print-length))
Index: emacs/lisp/emacs-lisp/edebug.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/edebug.el,v
retrieving revision 3.67
diff -u -r3.67 edebug.el
--- emacs/lisp/emacs-lisp/edebug.el 22 Mar 2004 15:27:46 -0000 3.67
+++ emacs/lisp/emacs-lisp/edebug.el 15 May 2004 07:15:29 -0000
@@ -3692,8 +3692,7 @@
(setq edebug-previous-result
(concat "Result: "
(edebug-safe-prin1-to-string edebug-previous-value)
- (let ((name (prin1-char edebug-previous-value)))
- (if name (concat " = " name))))))
+ (eval-expression-display-format edebug-previous-value))))
(defun edebug-previous-result ()
"Print the previous result."
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: printing most-negative-fixnum fails, (continued)
- Re: printing most-negative-fixnum fails, Richard Stallman, 2004/05/11
- Re: printing most-negative-fixnum fails, Juri Linkov, 2004/05/11
- Re: printing most-negative-fixnum fails, Richard Stallman, 2004/05/14
- Re: printing most-negative-fixnum fails, Kenichi Handa, 2004/05/14
- Re: printing most-negative-fixnum fails, Juri Linkov, 2004/05/15
- Re: printing most-negative-fixnum fails, Richard Stallman, 2004/05/15
- Re: printing most-negative-fixnum fails, David Kastrup, 2004/05/15
- Re: printing most-negative-fixnum fails, Juri Linkov, 2004/05/15
- Re: printing most-negative-fixnum fails, Kenichi Handa, 2004/05/18
- Re: printing most-negative-fixnum fails, Juri Linkov, 2004/05/19
- Re: printing most-negative-fixnum fails,
Juri Linkov <=
- Re: printing most-negative-fixnum fails, Richard Stallman, 2004/05/15
- Re: printing most-negative-fixnum fails, Juri Linkov, 2004/05/15
- Re: printing most-negative-fixnum fails, Kenichi Handa, 2004/05/11
- Re: printing most-negative-fixnum fails, Stefan Monnier, 2004/05/11
- Re: printing most-negative-fixnum fails, Kenichi Handa, 2004/05/12
Re: printing most-negative-fixnum fails, Stefan Monnier, 2004/05/10