diff options
| author | Richard M. Stallman | 1993-07-31 21:59:42 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-07-31 21:59:42 +0000 |
| commit | 5a05d3d2974885408f0235c40a98b7fd046cbd7f (patch) | |
| tree | 4c918a4cc7833cbab345339316066bc5429b41fd /src | |
| parent | d169fe39daaaba7d8e433404a75075384a3f44f8 (diff) | |
| download | emacs-5a05d3d2974885408f0235c40a98b7fd046cbd7f.tar.gz emacs-5a05d3d2974885408f0235c40a98b7fd046cbd7f.zip | |
(compute_motion): Compute correctly for invisible text.
(vmotion): Take care of invisible newlines.
(Fmove_to_column): After we split a tab, make sure
to set last_known... consistently.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/src/indent.c b/src/indent.c index f54bf87e940..5e9209621a7 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -27,6 +27,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 27 | #include "termchar.h" | 27 | #include "termchar.h" |
| 28 | #include "termopts.h" | 28 | #include "termopts.h" |
| 29 | #include "disptab.h" | 29 | #include "disptab.h" |
| 30 | #include "intervals.h" | ||
| 30 | 31 | ||
| 31 | /* Indentation can insert tabs if this is non-zero; | 32 | /* Indentation can insert tabs if this is non-zero; |
| 32 | otherwise always uses spaces */ | 33 | otherwise always uses spaces */ |
| @@ -352,6 +353,8 @@ and if COLUMN is in the middle of a tab character, change it to spaces.") | |||
| 352 | old_point = point; | 353 | old_point = point; |
| 353 | Findent_to (make_number (col), Qnil); | 354 | Findent_to (make_number (col), Qnil); |
| 354 | SET_PT (old_point); | 355 | SET_PT (old_point); |
| 356 | /* Set the last_known... vars consistently. */ | ||
| 357 | col = goal; | ||
| 355 | } | 358 | } |
| 356 | 359 | ||
| 357 | /* If line ends prematurely, add space to the end. */ | 360 | /* If line ends prematurely, add space to the end. */ |
| @@ -436,6 +439,11 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta | |||
| 436 | int selective_rlen | 439 | int selective_rlen |
| 437 | = (selective && dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector | 440 | = (selective && dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector |
| 438 | ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0); | 441 | ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0); |
| 442 | #ifdef USE_TEXT_PROPERTIES | ||
| 443 | /* The next location where the `invisible' property changes */ | ||
| 444 | int next_invisible = from; | ||
| 445 | Lisp_Object prop, position; | ||
| 446 | #endif | ||
| 439 | 447 | ||
| 440 | if (tab_width <= 0 || tab_width > 1000) tab_width = 8; | 448 | if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
| 441 | for (pos = from; pos < to; pos++) | 449 | for (pos = from; pos < to; pos++) |
| @@ -448,6 +456,32 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta | |||
| 448 | prev_vpos = vpos; | 456 | prev_vpos = vpos; |
| 449 | prev_hpos = hpos; | 457 | prev_hpos = hpos; |
| 450 | 458 | ||
| 459 | #ifdef USE_TEXT_PROPERTIES | ||
| 460 | /* if the `invisible' property is set, we can skip to | ||
| 461 | the next property change */ | ||
| 462 | while (pos == next_invisible && pos < to) | ||
| 463 | { | ||
| 464 | XFASTINT (position) = pos; | ||
| 465 | prop = Fget_text_property (position, | ||
| 466 | Qinvisible, | ||
| 467 | Fcurrent_buffer ()); | ||
| 468 | { | ||
| 469 | Lisp_Object end; | ||
| 470 | |||
| 471 | end = Fnext_single_property_change (position, | ||
| 472 | Qinvisible, | ||
| 473 | Fcurrent_buffer ()); | ||
| 474 | if (INTEGERP (end)) | ||
| 475 | next_invisible = XINT (end); | ||
| 476 | else | ||
| 477 | next_invisible = to; | ||
| 478 | if (! NILP (prop)) | ||
| 479 | pos = next_invisible; | ||
| 480 | } | ||
| 481 | } | ||
| 482 | if (pos >= to) | ||
| 483 | break; | ||
| 484 | #endif | ||
| 451 | c = FETCH_CHAR (pos); | 485 | c = FETCH_CHAR (pos); |
| 452 | if (c >= 040 && c < 0177 | 486 | if (c >= 040 && c < 0177 |
| 453 | && (dp == 0 || XTYPE (DISP_CHAR_VECTOR (dp, c)) != Lisp_Vector)) | 487 | && (dp == 0 || XTYPE (DISP_CHAR_VECTOR (dp, c)) != Lisp_Vector)) |
| @@ -610,9 +644,16 @@ vmotion (from, vtarget, width, hscroll, window) | |||
| 610 | if (from > BEGV && FETCH_CHAR (from - 1) != '\n') | 644 | if (from > BEGV && FETCH_CHAR (from - 1) != '\n') |
| 611 | { | 645 | { |
| 612 | prevline = find_next_newline (from, -1); | 646 | prevline = find_next_newline (from, -1); |
| 613 | while (selective > 0 | 647 | while (prevline > BEGV |
| 614 | && prevline > BEGV | 648 | && ((selective > 0 |
| 615 | && position_indentation (prevline) >= selective) | 649 | && position_indentation (prevline) >= selective) |
| 650 | #ifdef USE_TEXT_PROPERTIES | ||
| 651 | /* watch out for newlines with `invisible' property */ | ||
| 652 | || ! NILP (Fget_text_property (XFASTINT (prevline), | ||
| 653 | Qinvisible, | ||
| 654 | Fcurrent_buffer ())) | ||
| 655 | #endif | ||
| 656 | )) | ||
| 616 | prevline = find_next_newline (prevline - 1, -1); | 657 | prevline = find_next_newline (prevline - 1, -1); |
| 617 | pos = *compute_motion (prevline, 0, | 658 | pos = *compute_motion (prevline, 0, |
| 618 | lmargin + (prevline == 1 ? start_hpos : 0), | 659 | lmargin + (prevline == 1 ? start_hpos : 0), |
| @@ -641,8 +682,15 @@ vmotion (from, vtarget, width, hscroll, window) | |||
| 641 | { | 682 | { |
| 642 | prevline = find_next_newline (prevline - 1, -1); | 683 | prevline = find_next_newline (prevline - 1, -1); |
| 643 | if (prevline == BEGV | 684 | if (prevline == BEGV |
| 644 | || selective <= 0 | 685 | || ((selective <= 0 |
| 645 | || position_indentation (prevline) < selective) | 686 | || position_indentation (prevline) < selective) |
| 687 | #ifdef USE_TEXT_PROPERTIES | ||
| 688 | /* watch out for newlines with `invisible' property */ | ||
| 689 | && NILP (Fget_text_property (XFASTINT (prevline), | ||
| 690 | Qinvisible, | ||
| 691 | Fcurrent_buffer ())) | ||
| 692 | #endif | ||
| 693 | )) | ||
| 646 | break; | 694 | break; |
| 647 | } | 695 | } |
| 648 | pos = *compute_motion (prevline, 0, | 696 | pos = *compute_motion (prevline, 0, |