comparison src/coding.c @ 30204:35aec8514228

(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.
author Kenichi Handa <handa@m17n.org>
date Fri, 14 Jul 2000 01:56:14 +0000
parents c17e78d8c720
children b8083f5b4b7c
comparison
equal deleted inserted replaced
30203:34881d6fc1f6 30204:35aec8514228
381 Lisp_Object Vlatin_extra_code_table; 381 Lisp_Object Vlatin_extra_code_table;
382 382
383 /* Flag to inhibit code conversion of end-of-line format. */ 383 /* Flag to inhibit code conversion of end-of-line format. */
384 int inhibit_eol_conversion; 384 int inhibit_eol_conversion;
385 385
386 /* Flag to inhibit ISO2022 escape sequence detection. */
387 int 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. */
387 int inherit_process_coding_system; 390 int inherit_process_coding_system;
388 391
389 /* Coding system to be used to encode text for terminal display. */ 392 /* Coding system to be used to encode text for terminal display. */
390 struct coding_system terminal_coding; 393 struct coding_system terminal_coding;
833 { 836 {
834 ONE_MORE_BYTE (c); 837 ONE_MORE_BYTE (c);
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 <= '/')
841 { 846 {
842 /* Designation sequence for a charset of dimension 1. */ 847 /* Designation sequence for a charset of dimension 1. */
902 else 907 else
903 mask &= ~CODING_CATEGORY_MASK_ISO_8_ELSE; 908 mask &= ~CODING_CATEGORY_MASK_ISO_8_ELSE;
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
910 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_7_ELSE) 917 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_7_ELSE)
911 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_8_ELSE))) 918 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_8_ELSE)))
915 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT; 922 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT;
916 } 923 }
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 {
923 /* Locking shift in. */ 932 /* Locking shift in. */
924 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT; 933 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT;
931 case ISO_CODE_SS2: 940 case ISO_CODE_SS2:
932 case ISO_CODE_SS3: 941 case ISO_CODE_SS3:
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
939 & CODING_FLAG_ISO_SINGLE_SHIFT) 950 & CODING_FLAG_ISO_SINGLE_SHIFT)
940 newmask |= CODING_CATEGORY_MASK_ISO_8_1; 951 newmask |= CODING_CATEGORY_MASK_ISO_8_1;
6404 coding system used in each operation can't encode the text.\n\ 6415 coding system used in each operation can't encode the text.\n\
6405 \n\ 6416 \n\
6406 The default value is `select-safe-coding-system' (which see)."); 6417 The 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\
6424 By default, on reading a file, Emacs tries to detect how the text is\n\
6425 encoded. This code detection is sensitive to escape sequences. If\n\
6426 the sequence is valid as ISO2022, the code is detemined as one of\n\
6427 ISO2022 encoding, and the file is decoded by the corresponding coding\n\
6428 system (e.g. `iso-2022-7bit').\n\
6429 \n\
6430 However, there may be a case that you want to read escape sequences in\n\
6431 a file as is. In such a case, you can set this variable to non-nil.\n\
6432 Then, as the code detection ignores any escape sequences, no file is\n\
6433 detected as some of ISO2022 encoding. The result is that all escape\n\
6434 sequences become visible in a buffer.\n\
6435 \n\
6436 The default value is nil, and it is strongly recommended not to change\n\
6437 it. That is because many Emacs Lisp source files that contain\n\
6438 non-ASCII characters are encoded by the coding system `iso-2022-7bit'\n\
6439 in Emacs's distribution, and they won't be decoded correctly on\n\
6440 reading if you suppress escapse sequence detection.\n\
6441 \n\
6442 The other way to read escape sequences in a file without decoding is\n\
6443 to explicitely specify some coding system that doesn't use ISO2022's\n\
6444 escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument].");
6445 inhibit_iso_escape_detection = 0;
6409 } 6446 }
6410 6447
6411 char * 6448 char *
6412 emacs_strerror (error_number) 6449 emacs_strerror (error_number)
6413 int error_number; 6450 int error_number;