[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16828: 24.3.50; eval-expression, character representation of integer

From: npostavs
Subject: bug#16828: 24.3.50; eval-expression, character representation of integer results time-consuming
Date: Sat, 25 Mar 2017 23:45:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

tags 16828 patch

martin rudalics <address@hidden> writes:

>> Especially on Cygwin, it's very annoying when edebugging.  Displaying
>> a character for the number of a point or a result of a calculation is
>> useless.
> The most annoying aspect here is that it very often finds a character
> with a superscript and increases the height of my echo area.  Think of
> how valuable this is when debugging code resizing the echo area ;-)

I wonder how it could take so long to fix this silly thing.

>From 301202a7963ee377bf0f51f703e0282782c7a6c1 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <address@hidden>
Date: Sat, 25 Mar 2017 23:31:11 -0400
Subject: [PATCH v1] Limit integers printed as characters (Bug#16828)

* lisp/simple.el (eval-expression-print-maximum-character): New
(eval-expression-print-format): Only display value as character if
it's equal or less than `eval-expression-print-maximum-character'.
* doc/emacs/building.texi (Lisp Eval): Document it.
* etc/NEWS: Announce it.
 doc/emacs/building.texi |  6 +++++-
 etc/NEWS                |  4 ++++
 lisp/simple.el          | 14 +++++++++++---
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index ba8eae0759..2ee08e2505 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -1485,7 +1485,8 @@ Lisp Eval
 Emacs Lisp expression preceding point in the buffer, and displays the
 value in the echo area.  When the result of an evaluation is an
 integer, it is displayed together with the value in other formats
-(octal, hexadecimal, and character).
+(octal, hexadecimal, and character if
address@hidden allows it).
   If @kbd{M-:} or @kbd{C-x C-e} is given a prefix argument, it inserts
 the value into the current buffer at point, rather than displaying it
@@ -1524,6 +1525,7 @@ Lisp Eval
 @vindex eval-expression-print-level
 @vindex eval-expression-print-length
address@hidden eval-expression-print-maximum-character
 @vindex eval-expression-debug-on-error
   The options @code{eval-expression-print-level} and
 @code{eval-expression-print-length} control the maximum depth and
@@ -1533,6 +1535,8 @@ Lisp Eval
 printed in full.  @code{eval-expression-debug-on-error} controls
 whether evaluation errors invoke the debugger when these commands are
 used; its default is @code{t}.
address@hidden prevents large integers
+from being displayed as characters.
 @node Lisp Interaction
 @section Lisp Interaction Buffers
diff --git a/etc/NEWS b/etc/NEWS
index 62d06f3561..c09cc390bb 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -334,6 +334,10 @@ always restricting the margin to a quarter of the window.
 ** Emacsclient has a new option -u/--suppress-output.  The option
 suppresses display of return values from the server process.
+** The new variable 'eval-expression-print-maximum-character' prevents
+large integers from being displayed as characters.
 * Editing Changes in Emacs 26.1
diff --git a/lisp/simple.el b/lisp/simple.el
index 681cf83807..599c7ebf30 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1450,6 +1450,13 @@ eval-expression-debug-on-error
   :type 'boolean
   :version "21.1")
+(defcustom eval-expression-print-maximum-character 127
+  "The largest integer that will be displayed as a character.
+This affects printing by `eval-expression-print-format'."
+  :group 'lisp
+  :type 'integer
+  :version "26.1")
 (defun eval-expression-print-format (value)
   "If VALUE in an integer, return a specially formatted string.
 This string will typically look like \" (#o1, #x1, ?\\C-a)\".
@@ -1460,9 +1467,10 @@ eval-expression-print-format
           (or (eq standard-output t)
               (zerop (prefix-numeric-value current-prefix-arg))))
       (let ((char-string
-            (if (and (characterp value)
-                     (char-displayable-p value))
-                (prin1-char value))))
+             (and (characterp value)
+                  (<= value eval-expression-print-maximum-character)
+                  (char-displayable-p value)
+                  (prin1-char value))))
         (if char-string
             (format " (#o%o, #x%x, %s)" value value char-string)
           (format " (#o%o, #x%x)" value value)))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]