changeset 22933:f85d55276ec5

(print_escape_multibyte, Qprint_escape_multibyte) (Qprint_escape_nonascii): New variables. (syms_of_print): Initialize them and set up Lisp variable. (PRINTPREPARE): Bind print-escape-multibyte to t if appropriate. Also bind print-escape-nonascii if appropriate. (print): Test print_escape_multibyte and print_escape_nonascii, rather than enable-multibyte-characters.
author Richard M. Stallman <rms@gnu.org>
date Fri, 07 Aug 1998 07:22:27 +0000
parents 0e0275920715
children c3b29b916c9c
files src/print.c
diffstat 1 files changed, 32 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/print.c	Fri Aug 07 07:15:37 1998 +0000
+++ b/src/print.c	Fri Aug 07 07:22:27 1998 +0000
@@ -128,13 +128,18 @@
 
 int print_escape_newlines;
 
-Lisp_Object Qprint_escape_newlines;
-
 /* Nonzero means to print single-byte non-ascii characters in strings as
    octal escapes.  */
 
 int print_escape_nonascii;
 
+/* Nonzero means to print multibyte characters in strings as hex escapes.  */
+
+int print_escape_multibyte;
+
+Lisp_Object Qprint_escape_newlines;
+Lisp_Object Qprint_escape_multibyte, Qprint_escape_nonascii;
+
 /* Nonzero means print (quote foo) forms as 'foo, etc.  */
 
 int print_quoted;
@@ -261,6 +266,12 @@
    if (NILP (printcharfun))					\
      {								\
        Lisp_Object string;					\
+       if (NILP (current_buffer->enable_multibyte_characters)	\
+	   && ! print_escape_multibyte)				\
+         specbind (Qprint_escape_multibyte, Qt);		\
+       if (! NILP (current_buffer->enable_multibyte_characters)	\
+	   && ! print_escape_nonascii)				\
+         specbind (Qprint_escape_nonascii, Qt);			\
        if (print_buffer != 0)					\
 	 {							\
 	   string = make_string_from_bytes (print_buffer,	\
@@ -1269,8 +1280,7 @@
 		  PRINTCHAR ('\\');
 		  PRINTCHAR ('f');
 		}
-	      else if ((! SINGLE_BYTE_CHAR_P (c)
-			&& NILP (current_buffer->enable_multibyte_characters)))
+	      else if (! SINGLE_BYTE_CHAR_P (c) && print_escape_multibyte)
 		{
 		  /* When multibyte is disabled,
 		     print multibyte string chars using hex escapes.  */
@@ -1279,12 +1289,11 @@
 		  strout (outbuf, -1, -1, printcharfun, 0);
 		  need_nonhex = 1;
 		}
-	      else if (SINGLE_BYTE_CHAR_P (c)
-		       && ! ASCII_BYTE_P (c)
-		       && (! NILP (current_buffer->enable_multibyte_characters)
-			   || print_escape_nonascii))
+	      else if (SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c)
+		       && print_escape_nonascii)
 		{
-		  /* When multibyte is enabled or when explicitly requested,
+		  /* When printing in a multibyte buffer
+		     or when explicitly requested,
 		     print single-byte non-ASCII string chars
 		     using octal escapes.  */
 		  unsigned char outbuf[5];
@@ -1842,11 +1851,17 @@
   print_escape_newlines = 0;
 
   DEFVAR_BOOL ("print-escape-nonascii", &print_escape_nonascii,
-    "Non-nil means print non-ASCII characters in strings as backslash-NNN.\n\
-NNN is the octal representation of the character's value.\n\
+    "Non-nil means print unibyte non-ASCII chars in strings as \\OOO.\n\
+\(OOO is the octal representation of the character code.)\n\
 Only single-byte characters are affected, and only in `prin1'.");
   print_escape_nonascii = 0;
 
+  DEFVAR_BOOL ("print-escape-multibyte", &print_escape_multibyte,
+    "Non-nil means print multibyte characters in strings as \\xXXXX.\n\
+\(XXX is the hex representation of the character code.)\n\
+This affects only `prin1'.");
+  print_escape_multibyte = 0;
+
   DEFVAR_BOOL ("print-quoted", &print_quoted,
     "Non-nil means print quoted forms with reader syntax.\n\
 I.e., (quote foo) prints as 'foo, (function foo) as #'foo, and, backquoted\n\
@@ -1891,6 +1906,12 @@
   Qprint_escape_newlines = intern ("print-escape-newlines");
   staticpro (&Qprint_escape_newlines);
 
+  Qprint_escape_multibyte = intern ("print-escape-multibyte");
+  staticpro (&Qprint_escape_multibyte);
+
+  Qprint_escape_nonascii = intern ("print-escape-nonascii");
+  staticpro (&Qprint_escape_nonascii);
+
 #ifndef standalone
   defsubr (&Swith_output_to_temp_buffer);
 #endif /* not standalone */