diff options
| author | Richard M. Stallman | 1998-08-07 07:22:27 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-08-07 07:22:27 +0000 |
| commit | 835d0be6dde6c2b83162ede3362c14027d658a6a (patch) | |
| tree | c18b85c3209622d55738217b963c983ba1b68632 /src | |
| parent | ad4ac475214d945898ff36f7c147b44e1a748c11 (diff) | |
| download | emacs-835d0be6dde6c2b83162ede3362c14027d658a6a.tar.gz emacs-835d0be6dde6c2b83162ede3362c14027d658a6a.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/print.c | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/src/print.c b/src/print.c index 9cb8b1b960c..499e2e46738 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -128,13 +128,18 @@ Lisp_Object Vprint_level; | |||
| 128 | 128 | ||
| 129 | int print_escape_newlines; | 129 | int print_escape_newlines; |
| 130 | 130 | ||
| 131 | Lisp_Object Qprint_escape_newlines; | ||
| 132 | |||
| 133 | /* Nonzero means to print single-byte non-ascii characters in strings as | 131 | /* Nonzero means to print single-byte non-ascii characters in strings as |
| 134 | octal escapes. */ | 132 | octal escapes. */ |
| 135 | 133 | ||
| 136 | int print_escape_nonascii; | 134 | int print_escape_nonascii; |
| 137 | 135 | ||
| 136 | /* Nonzero means to print multibyte characters in strings as hex escapes. */ | ||
| 137 | |||
| 138 | int print_escape_multibyte; | ||
| 139 | |||
| 140 | Lisp_Object Qprint_escape_newlines; | ||
| 141 | Lisp_Object Qprint_escape_multibyte, Qprint_escape_nonascii; | ||
| 142 | |||
| 138 | /* Nonzero means print (quote foo) forms as 'foo, etc. */ | 143 | /* Nonzero means print (quote foo) forms as 'foo, etc. */ |
| 139 | 144 | ||
| 140 | int print_quoted; | 145 | int print_quoted; |
| @@ -261,6 +266,12 @@ glyph_to_str_cpy (glyphs, str) | |||
| 261 | if (NILP (printcharfun)) \ | 266 | if (NILP (printcharfun)) \ |
| 262 | { \ | 267 | { \ |
| 263 | Lisp_Object string; \ | 268 | Lisp_Object string; \ |
| 269 | if (NILP (current_buffer->enable_multibyte_characters) \ | ||
| 270 | && ! print_escape_multibyte) \ | ||
| 271 | specbind (Qprint_escape_multibyte, Qt); \ | ||
| 272 | if (! NILP (current_buffer->enable_multibyte_characters) \ | ||
| 273 | && ! print_escape_nonascii) \ | ||
| 274 | specbind (Qprint_escape_nonascii, Qt); \ | ||
| 264 | if (print_buffer != 0) \ | 275 | if (print_buffer != 0) \ |
| 265 | { \ | 276 | { \ |
| 266 | string = make_string_from_bytes (print_buffer, \ | 277 | string = make_string_from_bytes (print_buffer, \ |
| @@ -1269,8 +1280,7 @@ print (obj, printcharfun, escapeflag) | |||
| 1269 | PRINTCHAR ('\\'); | 1280 | PRINTCHAR ('\\'); |
| 1270 | PRINTCHAR ('f'); | 1281 | PRINTCHAR ('f'); |
| 1271 | } | 1282 | } |
| 1272 | else if ((! SINGLE_BYTE_CHAR_P (c) | 1283 | else if (! SINGLE_BYTE_CHAR_P (c) && print_escape_multibyte) |
| 1273 | && NILP (current_buffer->enable_multibyte_characters))) | ||
| 1274 | { | 1284 | { |
| 1275 | /* When multibyte is disabled, | 1285 | /* When multibyte is disabled, |
| 1276 | print multibyte string chars using hex escapes. */ | 1286 | print multibyte string chars using hex escapes. */ |
| @@ -1279,12 +1289,11 @@ print (obj, printcharfun, escapeflag) | |||
| 1279 | strout (outbuf, -1, -1, printcharfun, 0); | 1289 | strout (outbuf, -1, -1, printcharfun, 0); |
| 1280 | need_nonhex = 1; | 1290 | need_nonhex = 1; |
| 1281 | } | 1291 | } |
| 1282 | else if (SINGLE_BYTE_CHAR_P (c) | 1292 | else if (SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c) |
| 1283 | && ! ASCII_BYTE_P (c) | 1293 | && print_escape_nonascii) |
| 1284 | && (! NILP (current_buffer->enable_multibyte_characters) | ||
| 1285 | || print_escape_nonascii)) | ||
| 1286 | { | 1294 | { |
| 1287 | /* When multibyte is enabled or when explicitly requested, | 1295 | /* When printing in a multibyte buffer |
| 1296 | or when explicitly requested, | ||
| 1288 | print single-byte non-ASCII string chars | 1297 | print single-byte non-ASCII string chars |
| 1289 | using octal escapes. */ | 1298 | using octal escapes. */ |
| 1290 | unsigned char outbuf[5]; | 1299 | unsigned char outbuf[5]; |
| @@ -1842,11 +1851,17 @@ Also print formfeeds as backslash-f."); | |||
| 1842 | print_escape_newlines = 0; | 1851 | print_escape_newlines = 0; |
| 1843 | 1852 | ||
| 1844 | DEFVAR_BOOL ("print-escape-nonascii", &print_escape_nonascii, | 1853 | DEFVAR_BOOL ("print-escape-nonascii", &print_escape_nonascii, |
| 1845 | "Non-nil means print non-ASCII characters in strings as backslash-NNN.\n\ | 1854 | "Non-nil means print unibyte non-ASCII chars in strings as \\OOO.\n\ |
| 1846 | NNN is the octal representation of the character's value.\n\ | 1855 | \(OOO is the octal representation of the character code.)\n\ |
| 1847 | Only single-byte characters are affected, and only in `prin1'."); | 1856 | Only single-byte characters are affected, and only in `prin1'."); |
| 1848 | print_escape_nonascii = 0; | 1857 | print_escape_nonascii = 0; |
| 1849 | 1858 | ||
| 1859 | DEFVAR_BOOL ("print-escape-multibyte", &print_escape_multibyte, | ||
| 1860 | "Non-nil means print multibyte characters in strings as \\xXXXX.\n\ | ||
| 1861 | \(XXX is the hex representation of the character code.)\n\ | ||
| 1862 | This affects only `prin1'."); | ||
| 1863 | print_escape_multibyte = 0; | ||
| 1864 | |||
| 1850 | DEFVAR_BOOL ("print-quoted", &print_quoted, | 1865 | DEFVAR_BOOL ("print-quoted", &print_quoted, |
| 1851 | "Non-nil means print quoted forms with reader syntax.\n\ | 1866 | "Non-nil means print quoted forms with reader syntax.\n\ |
| 1852 | I.e., (quote foo) prints as 'foo, (function foo) as #'foo, and, backquoted\n\ | 1867 | I.e., (quote foo) prints as 'foo, (function foo) as #'foo, and, backquoted\n\ |
| @@ -1891,6 +1906,12 @@ with #N= for the specified value of N."); | |||
| 1891 | Qprint_escape_newlines = intern ("print-escape-newlines"); | 1906 | Qprint_escape_newlines = intern ("print-escape-newlines"); |
| 1892 | staticpro (&Qprint_escape_newlines); | 1907 | staticpro (&Qprint_escape_newlines); |
| 1893 | 1908 | ||
| 1909 | Qprint_escape_multibyte = intern ("print-escape-multibyte"); | ||
| 1910 | staticpro (&Qprint_escape_multibyte); | ||
| 1911 | |||
| 1912 | Qprint_escape_nonascii = intern ("print-escape-nonascii"); | ||
| 1913 | staticpro (&Qprint_escape_nonascii); | ||
| 1914 | |||
| 1894 | #ifndef standalone | 1915 | #ifndef standalone |
| 1895 | defsubr (&Swith_output_to_temp_buffer); | 1916 | defsubr (&Swith_output_to_temp_buffer); |
| 1896 | #endif /* not standalone */ | 1917 | #endif /* not standalone */ |