comparison src/indent.c @ 4385:edffa4f0c5d9

(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.
author Richard M. Stallman <rms@gnu.org>
date Sat, 31 Jul 1993 21:59:42 +0000
parents e94a593c3952
children 1fc792473491
comparison
equal deleted inserted replaced
4384:98605d0ea3cf 4385:edffa4f0c5d9
25 #include "frame.h" 25 #include "frame.h"
26 #include "window.h" 26 #include "window.h"
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 */
33 int indent_tabs_mode; 34 int indent_tabs_mode;
34 35
350 del_range (point - 1, point); 351 del_range (point - 1, point);
351 Findent_to (make_number (goal), Qnil); 352 Findent_to (make_number (goal), Qnil);
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. */
358 if (col < goal && !NILP (force)) 361 if (col < goal && !NILP (force))
359 Findent_to (make_number (col = goal), Qnil); 362 Findent_to (make_number (col = goal), Qnil);
434 : !NILP (current_buffer->selective_display) ? -1 : 0; 437 : !NILP (current_buffer->selective_display) ? -1 : 0;
435 int prev_vpos, prev_hpos; 438 int prev_vpos, prev_hpos;
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++)
442 { 450 {
443 /* Stop if past the target screen position. */ 451 /* Stop if past the target screen position. */
446 break; 454 break;
447 455
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))
454 hpos++; 488 hpos++;
455 else if (c == '\t') 489 else if (c == '\t')
608 /* Moving downward is simple, but must calculate from beg of line 642 /* Moving downward is simple, but must calculate from beg of line
609 to determine hpos of starting point */ 643 to determine hpos of starting point */
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),
619 from, 1 << (INTBITS - 2), 0, 660 from, 1 << (INTBITS - 2), 0,
620 width, hscroll, 0); 661 width, hscroll, 0);
639 prevline = from; 680 prevline = from;
640 while (1) 681 while (1)
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,
649 lmargin + (prevline == 1 ? start_hpos : 0), 697 lmargin + (prevline == 1 ? start_hpos : 0),
650 from, 1 << (INTBITS - 2), 0, 698 from, 1 << (INTBITS - 2), 0,