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: Sat, 15 May 2004 11:09:07 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87sme2jen0.fsf@mail.jurta.org> References: <200405062008.i46K8x4R015248@brains.moreideas.ca> <87vfj3g1kv.fsf@mail.jurta.org> <8765b2g9x5.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1084608981 16836 80.91.224.253 (15 May 2004 08:16:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 15 May 2004 08:16:21 +0000 (UTC) Cc: emacs@whaite.ca, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat May 15 10:16:11 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 1BOuL4-0002Sv-00 for ; Sat, 15 May 2004 10:16:10 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BOuL4-0003v4-00 for ; Sat, 15 May 2004 10:16:10 +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 1BOuJI-000857-LD for emacs-devel@quimby.gnus.org; Sat, 15 May 2004 04:14:20 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BOuIx-00083E-Bs for emacs-devel@gnu.org; Sat, 15 May 2004 04:13:59 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BOuIR-0007zz-CE for emacs-devel@gnu.org; Sat, 15 May 2004 04:13:58 -0400 Original-Received: from [66.33.219.6] (helo=knife.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BOuIQ-0007zk-Ud; Sat, 15 May 2004 04:13:27 -0400 Original-Received: from mail.jurta.org (80-235-42-9-dsl.mus.estpak.ee [80.235.42.9]) by knife.dreamhost.com (Postfix) with ESMTP id F1A9BE4087; Sat, 15 May 2004 01:13:10 -0700 (PDT) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Fri, 14 May 2004 05:20:41 -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:23466 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:23466 Richard Stallman 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/