unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: printing most-negative-fixnum fails
Date: Tue, 11 May 2004 03:17:52 +0300	[thread overview]
Message-ID: <87vfj3g1kv.fsf@mail.jurta.org> (raw)
In-Reply-To: <200405062008.i46K8x4R015248@brains.moreideas.ca> (Peter Whaite's message of "Thu, 06 May 2004 16:08:58 -0400")

Peter Whaite <emacs@whaite.ca> writes:
> Minor annoyance is that evaluating most-negative-fixnum in *scratch*
> (Lisp Interaction mode) fails...

This bug is caused by calling `(downcase most-negative-fixnum)'
in `event-modifiers' called from `prin1-char'.

I remember it was agreed some time ago that by default C-x C-e should
not display numbers as characters to avoid all related problems.

Below is a patch that introduces an option to control character display.

Also it is useful to display octal and hex values as well, like
for example, C-x = already does.

Index: emacs/lisp/emacs-lisp/lisp-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v
retrieving revision 1.155
diff -u -w -b -r1.155 lisp-mode.el
--- emacs/lisp/emacs-lisp/lisp-mode.el	22 Mar 2004 15:31:46 -0000	1.155
+++ emacs/lisp/emacs-lisp/lisp-mode.el	10 May 2004 22:42:32 -0000
@@ -519,18 +521,25 @@
 			 expr)))))))
       (eval-last-sexp-print-value value))))
 
+(defvar eval-last-sexp-print-char nil
+  "*Non-nil means display the result of evaluation as a character.")
+
 (defun eval-last-sexp-print-value (value)
   (let ((unabbreviated (let ((print-length nil) (print-level nil))
 			 (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)))
+      (when (eq standard-output t)
+        (if (integerp value)
+            (princ (format " (0%o, 0x%x)" value value)))
+        (if eval-last-sexp-print-char
+            (let ((char-string (prin1-char value)))
+              (if char-string
+                  (princ (concat " = " char-string))))))
       (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 -w -b -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	10 May 2004 22:42:31 -0000
@@ -3692,8 +3692,11 @@
   (setq edebug-previous-result
 	(concat "Result: "
 		(edebug-safe-prin1-to-string edebug-previous-value)
+                (if (integerp edebug-previous-value)
+                    (format " (0%o, 0x%x)" edebug-previous-value edebug-previous-value))
+		(if eval-last-sexp-print-char
 		(let ((name (prin1-char edebug-previous-value)))
-                 (if name (concat " = " name))))))
+                 (if name (concat " = " name)))))))
 
 (defun edebug-previous-result ()
   "Print the previous result."

-- 
Juri Linkov
http://www.jurta.org/emacs/

  reply	other threads:[~2004-05-11  0:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-06 20:08 printing most-negative-fixnum fails Peter Whaite
2004-05-11  0:17 ` Juri Linkov [this message]
2004-05-11  3:20   ` Stefan Monnier
2004-05-11 16:57     ` Juri Linkov
2004-05-12 19:41       ` Richard Stallman
2004-05-11 12:23   ` Richard Stallman
2004-05-11 16:47     ` Juri Linkov
2004-05-14  9:20       ` Richard Stallman
2004-05-14 11:46         ` Kenichi Handa
2004-05-15  8:17           ` Juri Linkov
2004-05-15  8:53           ` Richard Stallman
2004-05-15  9:19             ` David Kastrup
2004-05-15 20:03             ` Juri Linkov
2004-05-18 13:03               ` Kenichi Handa
2004-05-19  8:36           ` Juri Linkov
2004-05-15  8:09         ` Juri Linkov
2004-05-15 18:34           ` Richard Stallman
2004-05-15 19:32             ` Juri Linkov
2004-05-12  1:41     ` Kenichi Handa
2004-05-12  2:06       ` Stefan Monnier
2004-05-12  4:43         ` Kenichi Handa
2004-05-11  2:48 ` Stefan Monnier
2004-05-11  3:11   ` Luc Teirlinck
2004-05-11  4:26     ` Kenichi Handa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vfj3g1kv.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).