diff options
| author | Gerd Moellmann | 2001-03-16 13:33:46 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-03-16 13:33:46 +0000 |
| commit | 88c6e37e858365a22d5094c5333ced37fb2c35ed (patch) | |
| tree | 1498877c903919aeca417ba4d70f651d0521b3dd /src | |
| parent | 940627fe975845ef0627269f4392f8fd9faefb4f (diff) | |
| download | emacs-88c6e37e858365a22d5094c5333ced37fb2c35ed.tar.gz emacs-88c6e37e858365a22d5094c5333ced37fb2c35ed.zip | |
(current_column, current_column_1, Fmove_to_column)
(compute_motion): Handle characters from display vectors
differently.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/indent.c | 467 |
2 files changed, 302 insertions, 171 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index fb9cc99dd55..9253f629de2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2001-03-16 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * indent.c (current_column, current_column_1, Fmove_to_column) | ||
| 4 | (compute_motion): Handle characters from display vectors | ||
| 5 | differently. | ||
| 6 | |||
| 1 | 2001-03-15 Kenichi Handa <handa@etl.go.jp> | 7 | 2001-03-15 Kenichi Handa <handa@etl.go.jp> |
| 2 | 8 | ||
| 3 | * xterm.c (x_draw_glyph_string): Draw relief (if any) before | 9 | * xterm.c (x_draw_glyph_string): Draw relief (if any) before |
diff --git a/src/indent.c b/src/indent.c index 9e187b80d3f..a6c5b046012 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* Indentation functions. | 1 | /* Indentation functions. |
| 2 | Copyright (C) 1985,86,87,88,93,94,95,98 Free Software Foundation, Inc. | 2 | Copyright (C) 1985,86,87,88,93,94,95,98, 2000, 2001 |
| 3 | Free Software Foundation, Inc. | ||
| 3 | 4 | ||
| 4 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 5 | 6 | ||
| @@ -18,7 +19,6 @@ along with GNU Emacs; see the file COPYING. If not, write to | |||
| 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | Boston, MA 02111-1307, USA. */ | 20 | Boston, MA 02111-1307, USA. */ |
| 20 | 21 | ||
| 21 | |||
| 22 | #include <config.h> | 22 | #include <config.h> |
| 23 | #include "lisp.h" | 23 | #include "lisp.h" |
| 24 | #include "buffer.h" | 24 | #include "buffer.h" |
| @@ -35,7 +35,8 @@ Boston, MA 02111-1307, USA. */ | |||
| 35 | #include "region-cache.h" | 35 | #include "region-cache.h" |
| 36 | 36 | ||
| 37 | /* Indentation can insert tabs if this is non-zero; | 37 | /* Indentation can insert tabs if this is non-zero; |
| 38 | otherwise always uses spaces */ | 38 | otherwise always uses spaces. */ |
| 39 | |||
| 39 | int indent_tabs_mode; | 40 | int indent_tabs_mode; |
| 40 | 41 | ||
| 41 | #define min(a, b) ((a) < (b) ? (a) : (b)) | 42 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
| @@ -43,21 +44,28 @@ int indent_tabs_mode; | |||
| 43 | 44 | ||
| 44 | #define CR 015 | 45 | #define CR 015 |
| 45 | 46 | ||
| 46 | /* These three values memoize the current column to avoid recalculation */ | 47 | /* These three values memoize the current column to avoid recalculation. */ |
| 47 | /* Some things in set last_known_column_point to -1 | 48 | |
| 48 | to mark the memoized value as invalid */ | 49 | /* Last value returned by current_column. |
| 49 | /* Last value returned by current_column */ | 50 | Some things in set last_known_column_point to -1 |
| 51 | to mark the memoized value as invalid. */ | ||
| 52 | |||
| 50 | int last_known_column; | 53 | int last_known_column; |
| 51 | /* Value of point when current_column was called */ | 54 | |
| 55 | /* Value of point when current_column was called. */ | ||
| 56 | |||
| 52 | int last_known_column_point; | 57 | int last_known_column_point; |
| 53 | /* Value of MODIFF when current_column was called */ | 58 | |
| 59 | /* Value of MODIFF when current_column was called. */ | ||
| 60 | |||
| 54 | int last_known_column_modified; | 61 | int last_known_column_modified; |
| 55 | 62 | ||
| 56 | static int current_column_1 (); | 63 | static int current_column_1 P_ ((void)); |
| 57 | static int position_indentation (); | 64 | static int position_indentation P_ ((int)); |
| 58 | 65 | ||
| 59 | /* Cache of beginning of line found by the last call of | 66 | /* Cache of beginning of line found by the last call of |
| 60 | current_column. */ | 67 | current_column. */ |
| 68 | |||
| 61 | int current_column_bol_cache; | 69 | int current_column_bol_cache; |
| 62 | 70 | ||
| 63 | /* Get the display table to use for the current buffer. */ | 71 | /* Get the display table to use for the current buffer. */ |
| @@ -114,6 +122,7 @@ character_width (c, dp) | |||
| 114 | /* Return true iff the display table DISPTAB specifies the same widths | 122 | /* Return true iff the display table DISPTAB specifies the same widths |
| 115 | for characters as WIDTHTAB. We use this to decide when to | 123 | for characters as WIDTHTAB. We use this to decide when to |
| 116 | invalidate the buffer's width_run_cache. */ | 124 | invalidate the buffer's width_run_cache. */ |
| 125 | |||
| 117 | int | 126 | int |
| 118 | disptab_matches_widthtab (disptab, widthtab) | 127 | disptab_matches_widthtab (disptab, widthtab) |
| 119 | struct Lisp_Char_Table *disptab; | 128 | struct Lisp_Char_Table *disptab; |
| @@ -133,6 +142,7 @@ disptab_matches_widthtab (disptab, widthtab) | |||
| 133 | } | 142 | } |
| 134 | 143 | ||
| 135 | /* Recompute BUF's width table, using the display table DISPTAB. */ | 144 | /* Recompute BUF's width table, using the display table DISPTAB. */ |
| 145 | |||
| 136 | void | 146 | void |
| 137 | recompute_width_table (buf, disptab) | 147 | recompute_width_table (buf, disptab) |
| 138 | struct buffer *buf; | 148 | struct buffer *buf; |
| @@ -153,6 +163,7 @@ recompute_width_table (buf, disptab) | |||
| 153 | 163 | ||
| 154 | /* Allocate or free the width run cache, as requested by the current | 164 | /* Allocate or free the width run cache, as requested by the current |
| 155 | state of current_buffer's cache_long_line_scans variable. */ | 165 | state of current_buffer's cache_long_line_scans variable. */ |
| 166 | |||
| 156 | static void | 167 | static void |
| 157 | width_run_cache_on_off () | 168 | width_run_cache_on_off () |
| 158 | { | 169 | { |
| @@ -382,49 +393,85 @@ current_column () | |||
| 382 | else | 393 | else |
| 383 | stop = GAP_END_ADDR; | 394 | stop = GAP_END_ADDR; |
| 384 | 395 | ||
| 385 | if (tab_width <= 0 || tab_width > 1000) tab_width = 8; | 396 | if (tab_width <= 0 || tab_width > 1000) |
| 397 | tab_width = 8; | ||
| 386 | 398 | ||
| 387 | col = 0, tab_seen = 0, post_tab = 0; | 399 | col = 0, tab_seen = 0, post_tab = 0; |
| 388 | 400 | ||
| 389 | while (1) | 401 | while (1) |
| 390 | { | 402 | { |
| 403 | EMACS_INT i, n; | ||
| 404 | Lisp_Object charvec; | ||
| 405 | |||
| 391 | if (ptr == stop) | 406 | if (ptr == stop) |
| 392 | { | 407 | { |
| 393 | /* We stopped either for the beginning of the buffer | 408 | /* We stopped either for the beginning of the buffer |
| 394 | or for the gap. */ | 409 | or for the gap. */ |
| 395 | if (ptr == BEGV_ADDR) | 410 | if (ptr == BEGV_ADDR) |
| 396 | break; | 411 | break; |
| 412 | |||
| 397 | /* It was the gap. Jump back over it. */ | 413 | /* It was the gap. Jump back over it. */ |
| 398 | stop = BEGV_ADDR; | 414 | stop = BEGV_ADDR; |
| 399 | ptr = GPT_ADDR; | 415 | ptr = GPT_ADDR; |
| 416 | |||
| 400 | /* Check whether that brings us to beginning of buffer. */ | 417 | /* Check whether that brings us to beginning of buffer. */ |
| 401 | if (BEGV >= GPT) break; | 418 | if (BEGV >= GPT) |
| 419 | break; | ||
| 402 | } | 420 | } |
| 403 | 421 | ||
| 404 | c = *--ptr; | 422 | c = *--ptr; |
| 405 | if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) | 423 | |
| 406 | col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; | 424 | if (dp && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
| 407 | else if (c >= 040 && c < 0177) | ||
| 408 | col++; | ||
| 409 | else if (c == '\n' | ||
| 410 | || (c == '\r' && EQ (current_buffer->selective_display, Qt))) | ||
| 411 | { | 425 | { |
| 412 | ptr++; | 426 | charvec = DISP_CHAR_VECTOR (dp, c); |
| 413 | break; | 427 | n = ASIZE (charvec); |
| 414 | } | 428 | } |
| 415 | else if (c == '\t') | 429 | else |
| 416 | { | 430 | { |
| 417 | if (tab_seen) | 431 | charvec = Qnil; |
| 418 | col = ((col + tab_width) / tab_width) * tab_width; | 432 | n = 1; |
| 419 | 433 | } | |
| 420 | post_tab += col; | 434 | |
| 421 | col = 0; | 435 | for (i = n - 1; i >= 0; --i) |
| 422 | tab_seen = 1; | 436 | { |
| 437 | if (VECTORP (charvec)) | ||
| 438 | { | ||
| 439 | /* This should be handled the same as | ||
| 440 | next_element_from_display_vector does it. */ | ||
| 441 | Lisp_Object entry = AREF (charvec, i); | ||
| 442 | |||
| 443 | if (INTEGERP (entry) | ||
| 444 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) | ||
| 445 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); | ||
| 446 | else | ||
| 447 | c = ' '; | ||
| 448 | } | ||
| 449 | |||
| 450 | if (c >= 040 && c < 0177) | ||
| 451 | col++; | ||
| 452 | else if (c == '\n' | ||
| 453 | || (c == '\r' | ||
| 454 | && EQ (current_buffer->selective_display, Qt))) | ||
| 455 | { | ||
| 456 | ptr++; | ||
| 457 | goto start_of_line_found; | ||
| 458 | } | ||
| 459 | else if (c == '\t') | ||
| 460 | { | ||
| 461 | if (tab_seen) | ||
| 462 | col = ((col + tab_width) / tab_width) * tab_width; | ||
| 463 | |||
| 464 | post_tab += col; | ||
| 465 | col = 0; | ||
| 466 | tab_seen = 1; | ||
| 467 | } | ||
| 468 | else | ||
| 469 | col += (ctl_arrow && c < 0200) ? 2 : 4; | ||
| 423 | } | 470 | } |
| 424 | else | ||
| 425 | col += (ctl_arrow && c < 0200) ? 2 : 4; | ||
| 426 | } | 471 | } |
| 427 | 472 | ||
| 473 | start_of_line_found: | ||
| 474 | |||
| 428 | if (tab_seen) | 475 | if (tab_seen) |
| 429 | { | 476 | { |
| 430 | col = ((col + tab_width) / tab_width) * tab_width; | 477 | col = ((col + tab_width) / tab_width) * tab_width; |
| @@ -475,6 +522,8 @@ current_column_1 () | |||
| 475 | while (scan < opoint) | 522 | while (scan < opoint) |
| 476 | { | 523 | { |
| 477 | int c; | 524 | int c; |
| 525 | EMACS_INT i, n; | ||
| 526 | Lisp_Object charvec; | ||
| 478 | 527 | ||
| 479 | /* Occasionally we may need to skip invisible text. */ | 528 | /* Occasionally we may need to skip invisible text. */ |
| 480 | while (scan == next_boundary) | 529 | while (scan == next_boundary) |
| @@ -506,44 +555,65 @@ current_column_1 () | |||
| 506 | } | 555 | } |
| 507 | 556 | ||
| 508 | c = FETCH_BYTE (scan_byte); | 557 | c = FETCH_BYTE (scan_byte); |
| 558 | |||
| 509 | if (dp != 0 | 559 | if (dp != 0 |
| 510 | && ! (multibyte && BASE_LEADING_CODE_P (c)) | 560 | && ! (multibyte && BASE_LEADING_CODE_P (c)) |
| 511 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) | 561 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
| 512 | { | 562 | { |
| 513 | col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; | 563 | charvec = DISP_CHAR_VECTOR (dp, c); |
| 514 | scan++; | 564 | n = ASIZE (charvec); |
| 515 | scan_byte++; | ||
| 516 | continue; | ||
| 517 | } | 565 | } |
| 518 | if (c == '\n') | 566 | else |
| 519 | break; | ||
| 520 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | ||
| 521 | break; | ||
| 522 | scan++; | ||
| 523 | scan_byte++; | ||
| 524 | if (c == '\t') | ||
| 525 | { | 567 | { |
| 526 | int prev_col = col; | 568 | charvec = Qnil; |
| 527 | col += tab_width; | 569 | n = 1; |
| 528 | col = col / tab_width * tab_width; | ||
| 529 | } | 570 | } |
| 530 | else if (multibyte && BASE_LEADING_CODE_P (c)) | 571 | |
| 572 | for (i = n - 1; i >= 0; --i) | ||
| 531 | { | 573 | { |
| 532 | unsigned char *ptr; | 574 | if (VECTORP (charvec)) |
| 533 | int bytes, width, wide_column; | 575 | { |
| 534 | 576 | /* This should be handled the same as | |
| 535 | scan_byte--; | 577 | next_element_from_display_vector does it. */ |
| 536 | ptr = BYTE_POS_ADDR (scan_byte); | 578 | Lisp_Object entry = AREF (charvec, i); |
| 537 | MULTIBYTE_BYTES_WIDTH (ptr, dp); | 579 | |
| 538 | scan_byte += bytes; | 580 | if (INTEGERP (entry) |
| 539 | col += width; | 581 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) |
| 582 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); | ||
| 583 | else | ||
| 584 | c = ' '; | ||
| 585 | } | ||
| 586 | |||
| 587 | if (c == '\n') | ||
| 588 | goto endloop; | ||
| 589 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | ||
| 590 | goto endloop; | ||
| 591 | scan++; | ||
| 592 | scan_byte++; | ||
| 593 | if (c == '\t') | ||
| 594 | { | ||
| 595 | int prev_col = col; | ||
| 596 | col += tab_width; | ||
| 597 | col = col / tab_width * tab_width; | ||
| 598 | } | ||
| 599 | else if (multibyte && BASE_LEADING_CODE_P (c)) | ||
| 600 | { | ||
| 601 | unsigned char *ptr; | ||
| 602 | int bytes, width, wide_column; | ||
| 603 | |||
| 604 | scan_byte--; | ||
| 605 | ptr = BYTE_POS_ADDR (scan_byte); | ||
| 606 | MULTIBYTE_BYTES_WIDTH (ptr, dp); | ||
| 607 | scan_byte += bytes; | ||
| 608 | col += width; | ||
| 609 | } | ||
| 610 | else if (ctl_arrow && (c < 040 || c == 0177)) | ||
| 611 | col += 2; | ||
| 612 | else if (c < 040 || c >= 0177) | ||
| 613 | col += 4; | ||
| 614 | else | ||
| 615 | col++; | ||
| 540 | } | 616 | } |
| 541 | else if (ctl_arrow && (c < 040 || c == 0177)) | ||
| 542 | col += 2; | ||
| 543 | else if (c < 040 || c >= 0177) | ||
| 544 | col += 4; | ||
| 545 | else | ||
| 546 | col++; | ||
| 547 | } | 617 | } |
| 548 | endloop: | 618 | endloop: |
| 549 | 619 | ||
| @@ -864,6 +934,9 @@ The return value is the current column.") | |||
| 864 | 934 | ||
| 865 | while (pos < end) | 935 | while (pos < end) |
| 866 | { | 936 | { |
| 937 | Lisp_Object charvec; | ||
| 938 | EMACS_INT i, n; | ||
| 939 | |||
| 867 | while (pos == next_boundary) | 940 | while (pos == next_boundary) |
| 868 | { | 941 | { |
| 869 | int prev = pos; | 942 | int prev = pos; |
| @@ -895,47 +968,69 @@ The return value is the current column.") | |||
| 895 | } | 968 | } |
| 896 | 969 | ||
| 897 | c = FETCH_BYTE (pos_byte); | 970 | c = FETCH_BYTE (pos_byte); |
| 971 | |||
| 898 | if (dp != 0 | 972 | if (dp != 0 |
| 899 | && ! (multibyte && BASE_LEADING_CODE_P (c)) | 973 | && ! (multibyte && BASE_LEADING_CODE_P (c)) |
| 900 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) | 974 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
| 901 | { | 975 | { |
| 902 | col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; | 976 | charvec = DISP_CHAR_VECTOR (dp, c); |
| 903 | pos_byte++; | 977 | n = ASIZE (charvec); |
| 904 | pos++; | ||
| 905 | continue; | ||
| 906 | } | 978 | } |
| 907 | if (c == '\n') | 979 | else |
| 908 | break; | ||
| 909 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | ||
| 910 | break; | ||
| 911 | pos++; | ||
| 912 | pos_byte++; | ||
| 913 | if (c == '\t') | ||
| 914 | { | 980 | { |
| 915 | prev_col = col; | 981 | charvec = Qnil; |
| 916 | col += tab_width; | 982 | n = 1; |
| 917 | col = col / tab_width * tab_width; | ||
| 918 | } | 983 | } |
| 919 | else if (ctl_arrow && (c < 040 || c == 0177)) | 984 | |
| 920 | col += 2; | 985 | for (i = n - 1; i >= 0; --i) |
| 921 | else if (c < 040 || c == 0177) | ||
| 922 | col += 4; | ||
| 923 | else if (c < 0177) | ||
| 924 | col++; | ||
| 925 | else if (multibyte && BASE_LEADING_CODE_P (c)) | ||
| 926 | { | 986 | { |
| 927 | /* Start of multi-byte form. */ | 987 | if (VECTORP (charvec)) |
| 928 | unsigned char *ptr; | 988 | { |
| 929 | int bytes, width, wide_column; | 989 | /* This should be handled the same as |
| 930 | 990 | next_element_from_display_vector does it. */ | |
| 931 | pos_byte--; | 991 | Lisp_Object entry = AREF (charvec, i); |
| 932 | ptr = BYTE_POS_ADDR (pos_byte); | 992 | |
| 933 | MULTIBYTE_BYTES_WIDTH (ptr, dp); | 993 | if (INTEGERP (entry) |
| 934 | pos_byte += bytes; | 994 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) |
| 935 | col += width; | 995 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); |
| 996 | else | ||
| 997 | c = ' '; | ||
| 998 | } | ||
| 999 | |||
| 1000 | |||
| 1001 | if (c == '\n') | ||
| 1002 | goto endloop; | ||
| 1003 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | ||
| 1004 | goto endloop; | ||
| 1005 | pos++; | ||
| 1006 | pos_byte++; | ||
| 1007 | if (c == '\t') | ||
| 1008 | { | ||
| 1009 | prev_col = col; | ||
| 1010 | col += tab_width; | ||
| 1011 | col = col / tab_width * tab_width; | ||
| 1012 | } | ||
| 1013 | else if (ctl_arrow && (c < 040 || c == 0177)) | ||
| 1014 | col += 2; | ||
| 1015 | else if (c < 040 || c == 0177) | ||
| 1016 | col += 4; | ||
| 1017 | else if (c < 0177) | ||
| 1018 | col++; | ||
| 1019 | else if (multibyte && BASE_LEADING_CODE_P (c)) | ||
| 1020 | { | ||
| 1021 | /* Start of multi-byte form. */ | ||
| 1022 | unsigned char *ptr; | ||
| 1023 | int bytes, width, wide_column; | ||
| 1024 | |||
| 1025 | pos_byte--; | ||
| 1026 | ptr = BYTE_POS_ADDR (pos_byte); | ||
| 1027 | MULTIBYTE_BYTES_WIDTH (ptr, dp); | ||
| 1028 | pos_byte += bytes; | ||
| 1029 | col += width; | ||
| 1030 | } | ||
| 1031 | else | ||
| 1032 | col += 4; | ||
| 936 | } | 1033 | } |
| 937 | else | ||
| 938 | col += 4; | ||
| 939 | } | 1034 | } |
| 940 | endloop: | 1035 | endloop: |
| 941 | 1036 | ||
| @@ -1386,6 +1481,9 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1386 | /* We have to scan the text character-by-character. */ | 1481 | /* We have to scan the text character-by-character. */ |
| 1387 | else | 1482 | else |
| 1388 | { | 1483 | { |
| 1484 | EMACS_INT i, n; | ||
| 1485 | Lisp_Object charvec; | ||
| 1486 | |||
| 1389 | c = FETCH_BYTE (pos_byte); | 1487 | c = FETCH_BYTE (pos_byte); |
| 1390 | 1488 | ||
| 1391 | /* Check composition sequence. */ | 1489 | /* Check composition sequence. */ |
| @@ -1434,99 +1532,125 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1434 | if (dp != 0 | 1532 | if (dp != 0 |
| 1435 | && ! (multibyte && BASE_LEADING_CODE_P (c)) | 1533 | && ! (multibyte && BASE_LEADING_CODE_P (c)) |
| 1436 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) | 1534 | && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
| 1437 | hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; | ||
| 1438 | else if (c >= 040 && c < 0177) | ||
| 1439 | hpos++; | ||
| 1440 | else if (c == '\t') | ||
| 1441 | { | 1535 | { |
| 1442 | int tem = (hpos + tab_offset + hscroll - (hscroll > 0)) % tab_width; | 1536 | charvec = DISP_CHAR_VECTOR (dp, c); |
| 1443 | if (tem < 0) | 1537 | n = ASIZE (charvec); |
| 1444 | tem += tab_width; | ||
| 1445 | hpos += tab_width - tem; | ||
| 1446 | } | 1538 | } |
| 1447 | else if (c == '\n') | 1539 | else |
| 1448 | { | 1540 | { |
| 1449 | if (selective > 0 | 1541 | charvec = Qnil; |
| 1450 | && indented_beyond_p (pos, pos_byte, selective)) | 1542 | n = 1; |
| 1543 | } | ||
| 1544 | |||
| 1545 | for (i = n - 1; i >= 0; --i) | ||
| 1546 | { | ||
| 1547 | if (VECTORP (charvec)) | ||
| 1451 | { | 1548 | { |
| 1452 | /* If (pos == to), we don't have to take care of | 1549 | /* This should be handled the same as |
| 1453 | selective display. */ | 1550 | next_element_from_display_vector does it. */ |
| 1454 | if (pos < to) | 1551 | Lisp_Object entry = AREF (charvec, i); |
| 1552 | |||
| 1553 | if (INTEGERP (entry) | ||
| 1554 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) | ||
| 1555 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); | ||
| 1556 | else | ||
| 1557 | c = ' '; | ||
| 1558 | } | ||
| 1559 | |||
| 1560 | if (c >= 040 && c < 0177) | ||
| 1561 | hpos++; | ||
| 1562 | else if (c == '\t') | ||
| 1563 | { | ||
| 1564 | int tem = ((hpos + tab_offset + hscroll - (hscroll > 0)) | ||
| 1565 | % tab_width); | ||
| 1566 | if (tem < 0) | ||
| 1567 | tem += tab_width; | ||
| 1568 | hpos += tab_width - tem; | ||
| 1569 | } | ||
| 1570 | else if (c == '\n') | ||
| 1571 | { | ||
| 1572 | if (selective > 0 | ||
| 1573 | && indented_beyond_p (pos, pos_byte, selective)) | ||
| 1455 | { | 1574 | { |
| 1456 | /* Skip any number of invisible lines all at once */ | 1575 | /* If (pos == to), we don't have to take care of |
| 1457 | do | 1576 | selective display. */ |
| 1577 | if (pos < to) | ||
| 1458 | { | 1578 | { |
| 1459 | pos = find_before_next_newline (pos, to, 1); | 1579 | /* Skip any number of invisible lines all at once */ |
| 1460 | if (pos < to) | 1580 | do |
| 1461 | pos++; | 1581 | { |
| 1462 | pos_byte = CHAR_TO_BYTE (pos); | 1582 | pos = find_before_next_newline (pos, to, 1); |
| 1583 | if (pos < to) | ||
| 1584 | pos++; | ||
| 1585 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1586 | } | ||
| 1587 | while (pos < to | ||
| 1588 | && indented_beyond_p (pos, pos_byte, selective)); | ||
| 1589 | /* Allow for the " ..." that is displayed for them. */ | ||
| 1590 | if (selective_rlen) | ||
| 1591 | { | ||
| 1592 | hpos += selective_rlen; | ||
| 1593 | if (hpos >= width) | ||
| 1594 | hpos = width; | ||
| 1595 | } | ||
| 1596 | DEC_BOTH (pos, pos_byte); | ||
| 1597 | /* We have skipped the invis text, but not the | ||
| 1598 | newline after. */ | ||
| 1463 | } | 1599 | } |
| 1464 | while (pos < to | ||
| 1465 | && indented_beyond_p (pos, pos_byte, selective)); | ||
| 1466 | /* Allow for the " ..." that is displayed for them. */ | ||
| 1467 | if (selective_rlen) | ||
| 1468 | { | ||
| 1469 | hpos += selective_rlen; | ||
| 1470 | if (hpos >= width) | ||
| 1471 | hpos = width; | ||
| 1472 | } | ||
| 1473 | DEC_BOTH (pos, pos_byte); | ||
| 1474 | /* We have skipped the invis text, but not the | ||
| 1475 | newline after. */ | ||
| 1476 | } | 1600 | } |
| 1601 | else | ||
| 1602 | { | ||
| 1603 | /* A visible line. */ | ||
| 1604 | vpos++; | ||
| 1605 | hpos = 0; | ||
| 1606 | hpos -= hscroll; | ||
| 1607 | /* Count the truncation glyph on column 0 */ | ||
| 1608 | if (hscroll > 0) | ||
| 1609 | hpos++; | ||
| 1610 | tab_offset = 0; | ||
| 1611 | } | ||
| 1612 | contin_hpos = 0; | ||
| 1477 | } | 1613 | } |
| 1478 | else | 1614 | else if (c == CR && selective < 0) |
| 1479 | { | ||
| 1480 | /* A visible line. */ | ||
| 1481 | vpos++; | ||
| 1482 | hpos = 0; | ||
| 1483 | hpos -= hscroll; | ||
| 1484 | /* Count the truncation glyph on column 0 */ | ||
| 1485 | if (hscroll > 0) | ||
| 1486 | hpos++; | ||
| 1487 | tab_offset = 0; | ||
| 1488 | } | ||
| 1489 | contin_hpos = 0; | ||
| 1490 | } | ||
| 1491 | else if (c == CR && selective < 0) | ||
| 1492 | { | ||
| 1493 | /* In selective display mode, | ||
| 1494 | everything from a ^M to the end of the line is invisible. | ||
| 1495 | Stop *before* the real newline. */ | ||
| 1496 | if (pos < to) | ||
| 1497 | { | 1615 | { |
| 1498 | pos = find_before_next_newline (pos, to, 1); | 1616 | /* In selective display mode, |
| 1499 | pos_byte = CHAR_TO_BYTE (pos); | 1617 | everything from a ^M to the end of the line is invisible. |
| 1618 | Stop *before* the real newline. */ | ||
| 1619 | if (pos < to) | ||
| 1620 | { | ||
| 1621 | pos = find_before_next_newline (pos, to, 1); | ||
| 1622 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1623 | } | ||
| 1624 | /* If we just skipped next_boundary, | ||
| 1625 | loop around in the main while | ||
| 1626 | and handle it. */ | ||
| 1627 | if (pos > next_boundary) | ||
| 1628 | next_boundary = pos; | ||
| 1629 | /* Allow for the " ..." that is displayed for them. */ | ||
| 1630 | if (selective_rlen) | ||
| 1631 | { | ||
| 1632 | hpos += selective_rlen; | ||
| 1633 | if (hpos >= width) | ||
| 1634 | hpos = width; | ||
| 1635 | } | ||
| 1500 | } | 1636 | } |
| 1501 | /* If we just skipped next_boundary, | 1637 | else if (multibyte && BASE_LEADING_CODE_P (c)) |
| 1502 | loop around in the main while | ||
| 1503 | and handle it. */ | ||
| 1504 | if (pos > next_boundary) | ||
| 1505 | next_boundary = pos; | ||
| 1506 | /* Allow for the " ..." that is displayed for them. */ | ||
| 1507 | if (selective_rlen) | ||
| 1508 | { | 1638 | { |
| 1509 | hpos += selective_rlen; | 1639 | /* Start of multi-byte form. */ |
| 1510 | if (hpos >= width) | 1640 | unsigned char *ptr; |
| 1511 | hpos = width; | 1641 | int bytes, width, wide_column; |
| 1642 | |||
| 1643 | pos_byte--; /* rewind POS_BYTE */ | ||
| 1644 | ptr = BYTE_POS_ADDR (pos_byte); | ||
| 1645 | MULTIBYTE_BYTES_WIDTH (ptr, dp); | ||
| 1646 | pos_byte += bytes; | ||
| 1647 | if (wide_column) | ||
| 1648 | wide_column_end_hpos = hpos + wide_column; | ||
| 1649 | hpos += width; | ||
| 1512 | } | 1650 | } |
| 1651 | else | ||
| 1652 | hpos += (ctl_arrow && c < 0200) ? 2 : 4; | ||
| 1513 | } | 1653 | } |
| 1514 | else if (multibyte && BASE_LEADING_CODE_P (c)) | ||
| 1515 | { | ||
| 1516 | /* Start of multi-byte form. */ | ||
| 1517 | unsigned char *ptr; | ||
| 1518 | int bytes, width, wide_column; | ||
| 1519 | |||
| 1520 | pos_byte--; /* rewind POS_BYTE */ | ||
| 1521 | ptr = BYTE_POS_ADDR (pos_byte); | ||
| 1522 | MULTIBYTE_BYTES_WIDTH (ptr, dp); | ||
| 1523 | pos_byte += bytes; | ||
| 1524 | if (wide_column) | ||
| 1525 | wide_column_end_hpos = hpos + wide_column; | ||
| 1526 | hpos += width; | ||
| 1527 | } | ||
| 1528 | else | ||
| 1529 | hpos += (ctl_arrow && c < 0200) ? 2 : 4; | ||
| 1530 | } | 1654 | } |
| 1531 | } | 1655 | } |
| 1532 | 1656 | ||
| @@ -1664,6 +1788,7 @@ DEFUN ("compute-motion", Fcompute_motion, Scompute_motion, 7, 7, 0, | |||
| 1664 | } | 1788 | } |
| 1665 | 1789 | ||
| 1666 | /* Fvertical_motion and vmotion */ | 1790 | /* Fvertical_motion and vmotion */ |
| 1791 | |||
| 1667 | struct position val_vmotion; | 1792 | struct position val_vmotion; |
| 1668 | 1793 | ||
| 1669 | struct position * | 1794 | struct position * |
| @@ -1870,7 +1995,7 @@ whether or not it is currently displayed in some window.") | |||
| 1870 | 1995 | ||
| 1871 | 1996 | ||
| 1872 | 1997 | ||
| 1873 | /* file's initialization. */ | 1998 | /* File's initialization. */ |
| 1874 | 1999 | ||
| 1875 | void | 2000 | void |
| 1876 | syms_of_indent () | 2001 | syms_of_indent () |