From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: printing most-negative-fixnum fails Date: Tue, 11 May 2004 03:17:52 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87vfj3g1kv.fsf@mail.jurta.org> References: <200405062008.i46K8x4R015248@brains.moreideas.ca> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1084242086 20640 80.91.224.253 (11 May 2004 02:21:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 11 May 2004 02:21:26 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue May 11 04:21:18 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BNMtS-0005ES-00 for ; Tue, 11 May 2004 04:21:18 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BNMtQ-0000KS-00 for ; Tue, 11 May 2004 04:21:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BNMoB-0003bK-BZ for emacs-devel@quimby.gnus.org; Mon, 10 May 2004 22:15:51 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BNMnr-0003ar-E5 for emacs-devel@gnu.org; Mon, 10 May 2004 22:15:31 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BNMnK-0003WJ-2W for emacs-devel@gnu.org; Mon, 10 May 2004 22:15:30 -0400 Original-Received: from [66.33.219.6] (helo=knife.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BNMnJ-0003Vy-Hg for emacs-devel@gnu.org; Mon, 10 May 2004 22:14:57 -0400 Original-Received: from mail.jurta.org (80-235-39-207-dsl.mus.estpak.ee [80.235.39.207]) by knife.dreamhost.com (Postfix) with ESMTP id C88A1E4027; Mon, 10 May 2004 19:14:51 -0700 (PDT) Original-To: Peter Whaite In-Reply-To: <200405062008.i46K8x4R015248@brains.moreideas.ca> (Peter Whaite's message of "Thu, 06 May 2004 16:08:58 -0400") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:23101 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:23101 Peter Whaite 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/