diff options
| author | Richard M. Stallman | 2001-11-04 23:26:52 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-11-04 23:26:52 +0000 |
| commit | d6e483a4dac328f388baec4bd1e795a921907230 (patch) | |
| tree | 6650871e38b847fb0e6f020023ffc57c4b197633 /src | |
| parent | e4a9694a892bffcef261fe8db3abd04ed145314d (diff) | |
| download | emacs-d6e483a4dac328f388baec4bd1e795a921907230.tar.gz emacs-d6e483a4dac328f388baec4bd1e795a921907230.zip | |
(current_column_1, Fmove_to_column): Separate the code
for display-table glyphs from the code buffer text, to fix
bugs in the former.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 107 |
1 files changed, 68 insertions, 39 deletions
diff --git a/src/indent.c b/src/indent.c index c0220c34b89..2a62ab6feda 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -526,8 +526,6 @@ current_column_1 () | |||
| 526 | while (scan < opoint) | 526 | while (scan < opoint) |
| 527 | { | 527 | { |
| 528 | int c; | 528 | int c; |
| 529 | EMACS_INT i, n; | ||
| 530 | Lisp_Object charvec; | ||
| 531 | 529 | ||
| 532 | /* Occasionally we may need to skip invisible text. */ | 530 | /* Occasionally we may need to skip invisible text. */ |
| 533 | while (scan == next_boundary) | 531 | while (scan == next_boundary) |
| @@ -564,36 +562,51 @@ current_column_1 () | |||
| 564 | && ! (multibyte && BASE_LEADING_CODE_P (c)) | 562 | && ! (multibyte && BASE_LEADING_CODE_P (c)) |
| 565 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) | 563 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
| 566 | { | 564 | { |
| 565 | Lisp_Object charvec; | ||
| 566 | EMACS_INT i, n; | ||
| 567 | |||
| 568 | /* This character is displayed using a vector of glyphs. | ||
| 569 | Update the column based on those glyphs. */ | ||
| 570 | |||
| 567 | charvec = DISP_CHAR_VECTOR (dp, c); | 571 | charvec = DISP_CHAR_VECTOR (dp, c); |
| 568 | n = ASIZE (charvec); | 572 | n = ASIZE (charvec); |
| 569 | } | ||
| 570 | else | ||
| 571 | { | ||
| 572 | charvec = Qnil; | ||
| 573 | n = 1; | ||
| 574 | } | ||
| 575 | 573 | ||
| 576 | for (i = n - 1; i >= 0; --i) | 574 | for (i = 0; i < n; i++) |
| 577 | { | ||
| 578 | if (VECTORP (charvec)) | ||
| 579 | { | 575 | { |
| 580 | /* This should be handled the same as | 576 | /* This should be handled the same as |
| 581 | next_element_from_display_vector does it. */ | 577 | next_element_from_display_vector does it. */ |
| 582 | Lisp_Object entry = AREF (charvec, i); | 578 | Lisp_Object entry; |
| 583 | 579 | entry = AREF (charvec, i); | |
| 580 | |||
| 584 | if (INTEGERP (entry) | 581 | if (INTEGERP (entry) |
| 585 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) | 582 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) |
| 586 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); | 583 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); |
| 587 | else | 584 | else |
| 588 | c = ' '; | 585 | c = ' '; |
| 586 | |||
| 587 | if (c == '\n') | ||
| 588 | goto endloop; | ||
| 589 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | ||
| 590 | goto endloop; | ||
| 591 | if (c == '\t') | ||
| 592 | { | ||
| 593 | int prev_col = col; | ||
| 594 | col += tab_width; | ||
| 595 | col = col / tab_width * tab_width; | ||
| 596 | } | ||
| 597 | else | ||
| 598 | ++col; | ||
| 589 | } | 599 | } |
| 590 | 600 | } | |
| 601 | else | ||
| 602 | { | ||
| 603 | /* The display table says nothing for this character. | ||
| 604 | Display it as itself. */ | ||
| 605 | |||
| 591 | if (c == '\n') | 606 | if (c == '\n') |
| 592 | goto endloop; | 607 | goto endloop; |
| 593 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | 608 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) |
| 594 | goto endloop; | 609 | goto endloop; |
| 595 | scan++; | ||
| 596 | scan_byte++; | ||
| 597 | if (c == '\t') | 610 | if (c == '\t') |
| 598 | { | 611 | { |
| 599 | int prev_col = col; | 612 | int prev_col = col; |
| @@ -611,8 +624,6 @@ current_column_1 () | |||
| 611 | scan_byte += bytes; | 624 | scan_byte += bytes; |
| 612 | col += width; | 625 | col += width; |
| 613 | } | 626 | } |
| 614 | else if (VECTORP (charvec)) | ||
| 615 | ++col; | ||
| 616 | else if (ctl_arrow && (c < 040 || c == 0177)) | 627 | else if (ctl_arrow && (c < 040 || c == 0177)) |
| 617 | col += 2; | 628 | col += 2; |
| 618 | else if (c < 040 || c >= 0177) | 629 | else if (c < 040 || c >= 0177) |
| @@ -620,6 +631,9 @@ current_column_1 () | |||
| 620 | else | 631 | else |
| 621 | col++; | 632 | col++; |
| 622 | } | 633 | } |
| 634 | scan++; | ||
| 635 | scan_byte++; | ||
| 636 | |||
| 623 | } | 637 | } |
| 624 | endloop: | 638 | endloop: |
| 625 | 639 | ||
| @@ -947,9 +961,6 @@ The return value is the current column. */) | |||
| 947 | 961 | ||
| 948 | while (pos < end) | 962 | while (pos < end) |
| 949 | { | 963 | { |
| 950 | Lisp_Object charvec; | ||
| 951 | EMACS_INT i, n; | ||
| 952 | |||
| 953 | while (pos == next_boundary) | 964 | while (pos == next_boundary) |
| 954 | { | 965 | { |
| 955 | int prev = pos; | 966 | int prev = pos; |
| @@ -982,49 +993,65 @@ The return value is the current column. */) | |||
| 982 | 993 | ||
| 983 | c = FETCH_BYTE (pos_byte); | 994 | c = FETCH_BYTE (pos_byte); |
| 984 | 995 | ||
| 996 | /* See if there is a display table and it relates | ||
| 997 | to this character. */ | ||
| 998 | |||
| 985 | if (dp != 0 | 999 | if (dp != 0 |
| 986 | && ! (multibyte && BASE_LEADING_CODE_P (c)) | 1000 | && ! (multibyte && BASE_LEADING_CODE_P (c)) |
| 987 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) | 1001 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
| 988 | { | 1002 | { |
| 1003 | Lisp_Object charvec; | ||
| 1004 | EMACS_INT i, n; | ||
| 1005 | |||
| 1006 | /* This character is displayed using a vector of glyphs. | ||
| 1007 | Update the position based on those glyphs. */ | ||
| 1008 | |||
| 989 | charvec = DISP_CHAR_VECTOR (dp, c); | 1009 | charvec = DISP_CHAR_VECTOR (dp, c); |
| 990 | n = ASIZE (charvec); | 1010 | n = ASIZE (charvec); |
| 991 | } | ||
| 992 | else | ||
| 993 | { | ||
| 994 | charvec = Qnil; | ||
| 995 | n = 1; | ||
| 996 | } | ||
| 997 | 1011 | ||
| 998 | for (i = n - 1; i >= 0; --i) | 1012 | for (i = 0; i < n; i++) |
| 999 | { | ||
| 1000 | if (VECTORP (charvec)) | ||
| 1001 | { | 1013 | { |
| 1002 | /* This should be handled the same as | 1014 | /* This should be handled the same as |
| 1003 | next_element_from_display_vector does it. */ | 1015 | next_element_from_display_vector does it. */ |
| 1004 | Lisp_Object entry = AREF (charvec, i); | 1016 | |
| 1005 | 1017 | Lisp_Object entry; | |
| 1018 | entry = AREF (charvec, i); | ||
| 1019 | |||
| 1006 | if (INTEGERP (entry) | 1020 | if (INTEGERP (entry) |
| 1007 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) | 1021 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) |
| 1008 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); | 1022 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); |
| 1009 | else | 1023 | else |
| 1010 | c = ' '; | 1024 | c = ' '; |
| 1025 | |||
| 1026 | if (c == '\n') | ||
| 1027 | goto endloop; | ||
| 1028 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | ||
| 1029 | goto endloop; | ||
| 1030 | if (c == '\t') | ||
| 1031 | { | ||
| 1032 | prev_col = col; | ||
| 1033 | col += tab_width; | ||
| 1034 | col = col / tab_width * tab_width; | ||
| 1035 | } | ||
| 1036 | else | ||
| 1037 | ++col; | ||
| 1011 | } | 1038 | } |
| 1039 | } | ||
| 1040 | else | ||
| 1041 | { | ||
| 1042 | /* The display table doesn't affect this character; | ||
| 1043 | it displays as itself. */ | ||
| 1012 | 1044 | ||
| 1013 | |||
| 1014 | if (c == '\n') | 1045 | if (c == '\n') |
| 1015 | goto endloop; | 1046 | goto endloop; |
| 1016 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | 1047 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) |
| 1017 | goto endloop; | 1048 | goto endloop; |
| 1018 | pos++; | ||
| 1019 | pos_byte++; | ||
| 1020 | if (c == '\t') | 1049 | if (c == '\t') |
| 1021 | { | 1050 | { |
| 1022 | prev_col = col; | 1051 | prev_col = col; |
| 1023 | col += tab_width; | 1052 | col += tab_width; |
| 1024 | col = col / tab_width * tab_width; | 1053 | col = col / tab_width * tab_width; |
| 1025 | } | 1054 | } |
| 1026 | else if (VECTORP (charvec)) | ||
| 1027 | ++col; | ||
| 1028 | else if (ctl_arrow && (c < 040 || c == 0177)) | 1055 | else if (ctl_arrow && (c < 040 || c == 0177)) |
| 1029 | col += 2; | 1056 | col += 2; |
| 1030 | else if (c < 040 || c == 0177) | 1057 | else if (c < 040 || c == 0177) |
| @@ -1037,15 +1064,17 @@ The return value is the current column. */) | |||
| 1037 | unsigned char *ptr; | 1064 | unsigned char *ptr; |
| 1038 | int bytes, width, wide_column; | 1065 | int bytes, width, wide_column; |
| 1039 | 1066 | ||
| 1040 | pos_byte--; | ||
| 1041 | ptr = BYTE_POS_ADDR (pos_byte); | 1067 | ptr = BYTE_POS_ADDR (pos_byte); |
| 1042 | MULTIBYTE_BYTES_WIDTH (ptr, dp); | 1068 | MULTIBYTE_BYTES_WIDTH (ptr, dp); |
| 1043 | pos_byte += bytes; | 1069 | pos_byte += bytes - 1; |
| 1044 | col += width; | 1070 | col += width; |
| 1045 | } | 1071 | } |
| 1046 | else | 1072 | else |
| 1047 | col += 4; | 1073 | col += 4; |
| 1048 | } | 1074 | } |
| 1075 | |||
| 1076 | pos++; | ||
| 1077 | pos_byte++; | ||
| 1049 | } | 1078 | } |
| 1050 | endloop: | 1079 | endloop: |
| 1051 | 1080 | ||