comparison src/indent.c @ 6846:a6803ff29cca

(compute_motion): Do not abort if window shows some other buffer. (Fcompute_motion): Use whatever buffer is current.
author Richard M. Stallman <rms@gnu.org>
date Wed, 13 Apr 1994 06:24:06 +0000
parents d84152a9b7e5
children cd81dba38a49
comparison
equal deleted inserted replaced
6845:e1420213cfdb 6846:a6803ff29cca
448 register int c; 448 register int c;
449 register int tab_width = XFASTINT (current_buffer->tab_width); 449 register int tab_width = XFASTINT (current_buffer->tab_width);
450 register int ctl_arrow = !NILP (current_buffer->ctl_arrow); 450 register int ctl_arrow = !NILP (current_buffer->ctl_arrow);
451 register struct Lisp_Vector *dp = window_display_table (win); 451 register struct Lisp_Vector *dp = window_display_table (win);
452 int selective 452 int selective
453 = XTYPE (current_buffer->selective_display) == Lisp_Int 453 = (XTYPE (current_buffer->selective_display) == Lisp_Int
454 ? XINT (current_buffer->selective_display) 454 ? XINT (current_buffer->selective_display)
455 : !NILP (current_buffer->selective_display) ? -1 : 0; 455 : !NILP (current_buffer->selective_display) ? -1 : 0);
456 int prev_vpos, prev_hpos = 0; 456 int prev_vpos, prev_hpos = 0;
457 int selective_rlen 457 int selective_rlen
458 = (selective && dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector 458 = (selective && dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector
459 ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0); 459 ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0);
460 #ifdef USE_TEXT_PROPERTIES 460 #ifdef USE_TEXT_PROPERTIES
461 /* The next location where the `invisible' property changes */ 461 /* The next location where the `invisible' property changes */
462 int next_invisible = from; 462 int next_invisible = from;
463 Lisp_Object prop, position; 463 Lisp_Object prop, position;
464 #endif 464 #endif
465
466 if (! BUFFERP (win->buffer) || XBUFFER (win->buffer) != current_buffer)
467 abort ();
468 465
469 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; 466 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
470 for (pos = from; pos < to; pos++) 467 for (pos = from; pos < to; pos++)
471 { 468 {
472 /* Stop if past the target screen position. */ 469 /* Stop if past the target screen position. */
634 HSCROLL is the number of columns not being displayed at the left\n\ 631 HSCROLL is the number of columns not being displayed at the left\n\
635 margin; this is usually taken from a window's hscroll member.\n\ 632 margin; this is usually taken from a window's hscroll member.\n\
636 TAB-OFFSET is the number of columns of the first tab that aren't\n\ 633 TAB-OFFSET is the number of columns of the first tab that aren't\n\
637 being displayed, perhaps because the line was continued within it.\n\ 634 being displayed, perhaps because the line was continued within it.\n\
638 If OFFSETS is nil, HSCROLL and TAB-OFFSET are assumed to be zero.\n\ 635 If OFFSETS is nil, HSCROLL and TAB-OFFSET are assumed to be zero.\n\
636 \n\
639 WINDOW is the window to operate on. Currently this is used only to\n\ 637 WINDOW is the window to operate on. Currently this is used only to\n\
640 find the buffer and the display table.\n\ 638 find the display table. It does not matter what buffer WINDOW displays;\n\
639 `compute-motion' always operates on the current buffer.\n\
641 \n\ 640 \n\
642 The value is a list of five elements:\n\ 641 The value is a list of five elements:\n\
643 (POS HPOS VPOS PREVHPOS CONTIN)\n\ 642 (POS HPOS VPOS PREVHPOS CONTIN)\n\
644 POS is the buffer position where the scan stopped.\n\ 643 POS is the buffer position where the scan stopped.\n\
645 VPOS is the vertical position where the scan stopped.\n\ 644 VPOS is the vertical position where the scan stopped.\n\
662 Lisp_Object width, offsets, window; 661 Lisp_Object width, offsets, window;
663 { 662 {
664 Lisp_Object bufpos, hpos, vpos, prevhpos, contin; 663 Lisp_Object bufpos, hpos, vpos, prevhpos, contin;
665 struct position *pos; 664 struct position *pos;
666 int hscroll, tab_offset; 665 int hscroll, tab_offset;
667 struct buffer *old_buffer;
668 666
669 CHECK_NUMBER_COERCE_MARKER (from, 0); 667 CHECK_NUMBER_COERCE_MARKER (from, 0);
670 CHECK_CONS (frompos, 0); 668 CHECK_CONS (frompos, 0);
671 CHECK_NUMBER (XCONS (frompos)->car, 0); 669 CHECK_NUMBER (XCONS (frompos)->car, 0);
672 CHECK_NUMBER (XCONS (frompos)->cdr, 0); 670 CHECK_NUMBER (XCONS (frompos)->cdr, 0);
689 if (NILP (window)) 687 if (NILP (window))
690 window = Fselected_window (); 688 window = Fselected_window ();
691 else 689 else
692 CHECK_LIVE_WINDOW (window, 0); 690 CHECK_LIVE_WINDOW (window, 0);
693 691
694 /* Might as well use the buffer on the specified window, rather than
695 generating an error. */
696 old_buffer = current_buffer;
697 current_buffer = XBUFFER (XWINDOW (window)->buffer);
698 pos = compute_motion (XINT (from), XINT (XCONS (frompos)->cdr), 692 pos = compute_motion (XINT (from), XINT (XCONS (frompos)->cdr),
699 XINT (XCONS (frompos)->car), 693 XINT (XCONS (frompos)->car),
700 XINT (to), XINT (XCONS (topos)->cdr), 694 XINT (to), XINT (XCONS (topos)->cdr),
701 XINT (XCONS (topos)->car), 695 XINT (XCONS (topos)->car),
702 XINT (width), hscroll, tab_offset, 696 XINT (width), hscroll, tab_offset,
703 XWINDOW (window)); 697 XWINDOW (window));
704 current_buffer = old_buffer;
705 698
706 XFASTINT (bufpos) = pos->bufpos; 699 XFASTINT (bufpos) = pos->bufpos;
707 XSET (hpos, Lisp_Int, pos->hpos); 700 XSET (hpos, Lisp_Int, pos->hpos);
708 XSET (vpos, Lisp_Int, pos->vpos); 701 XSET (vpos, Lisp_Int, pos->vpos);
709 XSET (prevhpos, Lisp_Int, pos->prevhpos); 702 XSET (prevhpos, Lisp_Int, pos->prevhpos);
851 } 844 }
852 845
853 DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 2, 0, 846 DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 2, 0,
854 "Move to start of screen line LINES lines down.\n\ 847 "Move to start of screen line LINES lines down.\n\
855 If LINES is negative, this is moving up.\n\ 848 If LINES is negative, this is moving up.\n\
856 The optional second argument WINDOW specifies the window\n\ 849 \n\
857 to use for computations.\n\ 850 The optional second argument WINDOW specifies the window to use for\n\
851 parameters such as width, horizontal scrolling, and so on.\n\
852 the default is the selected window.\n\
853 It does not matter what buffer is displayed in WINDOW.\n\
854 `vertical-motion' always uses the current buffer.\n\
855 \n\
858 Sets point to position found; this may be start of line\n\ 856 Sets point to position found; this may be start of line\n\
859 or just the start of a continuation line.\n\ 857 or just the start of a continuation line.\n\
860 Returns number of lines moved; may be closer to zero than LINES\n\ 858 Returns number of lines moved; may be closer to zero than LINES\n\
861 if beginning or end of buffer was reached.") 859 if beginning or end of buffer was reached.")
862 (lines, window) 860 (lines, window)
863 Lisp_Object lines, window; 861 Lisp_Object lines, window;
864 { 862 {
865 struct position pos; 863 struct position pos;
866 register struct window *w; 864 register struct window *w;
870 CHECK_WINDOW (window, 0); 868 CHECK_WINDOW (window, 0);
871 else 869 else
872 XSET (window, Lisp_Window, selected_window); 870 XSET (window, Lisp_Window, selected_window);
873 871
874 w = XWINDOW (window); 872 w = XWINDOW (window);
873
875 pos = *vmotion (point, XINT (lines), window_internal_width (w) - 1, 874 pos = *vmotion (point, XINT (lines), window_internal_width (w) - 1,
876 /* Not XFASTINT since perhaps could be negative */ 875 /* Not XFASTINT since perhaps could be negative */
877 XINT (w->hscroll), window); 876 XINT (w->hscroll), window);
878 877
879 SET_PT (pos.bufpos); 878 SET_PT (pos.bufpos);