diff --git a/src/print.c b/src/print.c index dca095f281..909c55efed 100644 --- a/src/print.c +++ b/src/print.c @@ -1908,8 +1908,16 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) { case_Lisp_Int: { - int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); - strout (buf, len, len, printcharfun); + if (print_integers_as_characters && CHARACTERP (obj)) + { + printchar ('?', printcharfun); + print_string (CALLN (Fstring, obj), printcharfun); + } + else + { + int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } } break; @@ -2247,6 +2255,10 @@ syms_of_print (void) that represents the number without losing information. */); Vfloat_output_format = Qnil; + DEFVAR_BOOL ("print-integers-as-characters", print_integers_as_characters, + doc: /* Print integers as characters. */); + print_integers_as_characters = 0; + DEFVAR_LISP ("print-length", Vprint_length, doc: /* Maximum length of list to print before abbreviating. A value of nil means no limit. See also `eval-expression-print-length'. */);