aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2000-07-14 01:56:14 +0000
committerKenichi Handa2000-07-14 01:56:14 +0000
commit74383408f31d0b7cdb54990295b83d17f80db298 (patch)
tree83f528d1e9e05cad478b86eb51ed1d8fd5789317 /src/coding.c
parentd5aa31d88c0fc24ee2c758d9d0121ed7757bc865 (diff)
downloademacs-74383408f31d0b7cdb54990295b83d17f80db298.tar.gz
emacs-74383408f31d0b7cdb54990295b83d17f80db298.zip
(inhibit_iso_escape_detection): New variable.
(syms_of_coding): Make it a Lisp variable. (detect_coding_iso2022): If inhibit_iso_escape_detection is nonzero, ignore ISO2022's escape sequence.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/coding.c b/src/coding.c
index 536ad60f5ca..3a53c95e7e7 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -383,6 +383,9 @@ Lisp_Object Vlatin_extra_code_table;
383/* Flag to inhibit code conversion of end-of-line format. */ 383/* Flag to inhibit code conversion of end-of-line format. */
384int inhibit_eol_conversion; 384int inhibit_eol_conversion;
385 385
386/* Flag to inhibit ISO2022 escape sequence detection. */
387int inhibit_iso_escape_detection;
388
386/* Flag to make buffer-file-coding-system inherit from process-coding. */ 389/* Flag to make buffer-file-coding-system inherit from process-coding. */
387int inherit_process_coding_system; 390int inherit_process_coding_system;
388 391
@@ -835,6 +838,8 @@ detect_coding_iso2022 (src, src_end)
835 switch (c) 838 switch (c)
836 { 839 {
837 case ISO_CODE_ESC: 840 case ISO_CODE_ESC:
841 if (inhibit_iso_escape_detection)
842 break;
838 single_shifting = 0; 843 single_shifting = 0;
839 ONE_MORE_BYTE (c); 844 ONE_MORE_BYTE (c);
840 if (c >= '(' && c <= '/') 845 if (c >= '(' && c <= '/')
@@ -904,6 +909,8 @@ detect_coding_iso2022 (src, src_end)
904 break; 909 break;
905 910
906 case ISO_CODE_SO: 911 case ISO_CODE_SO:
912 if (inhibit_iso_escape_detection)
913 break;
907 single_shifting = 0; 914 single_shifting = 0;
908 if (shift_out == 0 915 if (shift_out == 0
909 && (reg[1] >= 0 916 && (reg[1] >= 0
@@ -917,6 +924,8 @@ detect_coding_iso2022 (src, src_end)
917 break; 924 break;
918 925
919 case ISO_CODE_SI: 926 case ISO_CODE_SI:
927 if (inhibit_iso_escape_detection)
928 break;
920 single_shifting = 0; 929 single_shifting = 0;
921 if (shift_out == 1) 930 if (shift_out == 1)
922 { 931 {
@@ -933,6 +942,8 @@ detect_coding_iso2022 (src, src_end)
933 { 942 {
934 int newmask = CODING_CATEGORY_MASK_ISO_8_ELSE; 943 int newmask = CODING_CATEGORY_MASK_ISO_8_ELSE;
935 944
945 if (inhibit_iso_escape_detection)
946 break;
936 if (c != ISO_CODE_CSI) 947 if (c != ISO_CODE_CSI)
937 { 948 {
938 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags 949 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags
@@ -6406,6 +6417,32 @@ coding system used in each operation can't encode the text.\n\
6406The default value is `select-safe-coding-system' (which see)."); 6417The default value is `select-safe-coding-system' (which see).");
6407 Vselect_safe_coding_system_function = Qnil; 6418 Vselect_safe_coding_system_function = Qnil;
6408 6419
6420 DEFVAR_BOOL ("inhibit-iso-eacape-detection",
6421 &inhibit_iso_escape_detection,
6422 "If non-nil, Emacs ignores ISO2022's escape sequence on code detection.\n\
6423\n\
6424By default, on reading a file, Emacs tries to detect how the text is\n\
6425encoded. This code detection is sensitive to escape sequences. If\n\
6426the sequence is valid as ISO2022, the code is detemined as one of\n\
6427ISO2022 encoding, and the file is decoded by the corresponding coding\n\
6428system (e.g. `iso-2022-7bit').\n\
6429\n\
6430However, there may be a case that you want to read escape sequences in\n\
6431a file as is. In such a case, you can set this variable to non-nil.\n\
6432Then, as the code detection ignores any escape sequences, no file is\n\
6433detected as some of ISO2022 encoding. The result is that all escape\n\
6434sequences become visible in a buffer.\n\
6435\n\
6436The default value is nil, and it is strongly recommended not to change\n\
6437it. That is because many Emacs Lisp source files that contain\n\
6438non-ASCII characters are encoded by the coding system `iso-2022-7bit'\n\
6439in Emacs's distribution, and they won't be decoded correctly on\n\
6440reading if you suppress escapse sequence detection.\n\
6441\n\
6442The other way to read escape sequences in a file without decoding is\n\
6443to explicitely specify some coding system that doesn't use ISO2022's\n\
6444escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument].");
6445 inhibit_iso_escape_detection = 0;
6409} 6446}
6410 6447
6411char * 6448char *