aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorTom Tromey2013-01-05 19:36:45 -0700
committerTom Tromey2013-01-05 19:36:45 -0700
commite078a23febca14bc919c5806670479c395e3253e (patch)
treee9e4ed91feef744d525264c31974c3ed00146bcd /src/window.c
parent63d535c829a930207b64fe733228f15a554644b1 (diff)
parent7a2657fa3bedbd977f4e11fe030cb4a210c04ab4 (diff)
downloademacs-e078a23febca14bc919c5806670479c395e3253e.tar.gz
emacs-e078a23febca14bc919c5806670479c395e3253e.zip
merge from trunk
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/window.c b/src/window.c
index 7fa55df3c5e..71d8eb7f778 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,7 +1,7 @@
1/* Window creation, deletion and examination for GNU Emacs. 1/* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay. 2 Does not include redisplay.
3 Copyright (C) 1985-1987, 1993-1998, 2000-2012 3 Copyright (C) 1985-1987, 1993-1998, 2000-2013 Free Software
4 Free Software Foundation, Inc. 4 Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -87,6 +87,7 @@ static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object);
87static int window_resize_check (struct window *, int); 87static int window_resize_check (struct window *, int);
88static void window_resize_apply (struct window *, int); 88static void window_resize_apply (struct window *, int);
89static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); 89static Lisp_Object select_window (Lisp_Object, Lisp_Object, int);
90static void select_window_1 (Lisp_Object, bool);
90 91
91/* This is the window in which the terminal's cursor should 92/* This is the window in which the terminal's cursor should
92 be left when nothing is being done with it. This must 93 be left when nothing is being done with it. This must
@@ -280,7 +281,7 @@ adjust_window_count (struct window *w, int arg)
280 if (BUFFERP (w->buffer)) 281 if (BUFFERP (w->buffer))
281 { 282 {
282 struct buffer *b = XBUFFER (w->buffer); 283 struct buffer *b = XBUFFER (w->buffer);
283 284
284 if (b->base_buffer) 285 if (b->base_buffer)
285 b = b->base_buffer; 286 b = b->base_buffer;
286 b->window_count += arg; 287 b->window_count += arg;
@@ -487,7 +488,6 @@ static Lisp_Object
487select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) 488select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
488{ 489{
489 register struct window *w; 490 register struct window *w;
490 register struct window *ow;
491 struct frame *sf; 491 struct frame *sf;
492 492
493 CHECK_LIVE_WINDOW (window); 493 CHECK_LIVE_WINDOW (window);
@@ -523,12 +523,25 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
523 else 523 else
524 fset_selected_window (sf, window); 524 fset_selected_window (sf, window);
525 525
526 select_window_1 (window, inhibit_point_swap);
527
528 bset_last_selected_window (XBUFFER (w->buffer), window);
529 windows_or_buffers_changed++;
530 return window;
531}
532
533/* Select window with a minimum of fuss, i.e. don't record the change anywhere
534 (not even for redisplay's benefit), and assume that the window's frame is
535 already selected. */
536static void
537select_window_1 (Lisp_Object window, bool inhibit_point_swap)
538{
526 /* Store the old selected window's buffer's point in pointm of the old 539 /* Store the old selected window's buffer's point in pointm of the old
527 selected window. It belongs to that window, and when the window is 540 selected window. It belongs to that window, and when the window is
528 not selected, must be in the window. */ 541 not selected, must be in the window. */
529 if (!inhibit_point_swap) 542 if (!inhibit_point_swap)
530 { 543 {
531 ow = XWINDOW (selected_window); 544 struct window *ow = XWINDOW (selected_window);
532 if (! NILP (ow->buffer)) 545 if (! NILP (ow->buffer))
533 set_marker_both (ow->pointm, ow->buffer, 546 set_marker_both (ow->pointm, ow->buffer,
534 BUF_PT (XBUFFER (ow->buffer)), 547 BUF_PT (XBUFFER (ow->buffer)),
@@ -536,7 +549,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
536 } 549 }
537 550
538 selected_window = window; 551 selected_window = window;
539 bset_last_selected_window (XBUFFER (w->buffer), window);
540 552
541 /* Go to the point recorded in the window. 553 /* Go to the point recorded in the window.
542 This is important when the buffer is in more 554 This is important when the buffer is in more
@@ -544,7 +556,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
544 redisplay_window has altered point after scrolling, 556 redisplay_window has altered point after scrolling,
545 because it makes the change only in the window. */ 557 because it makes the change only in the window. */
546 { 558 {
547 register ptrdiff_t new_point = marker_position (w->pointm); 559 register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm);
548 if (new_point < BEGV) 560 if (new_point < BEGV)
549 SET_PT (BEGV); 561 SET_PT (BEGV);
550 else if (new_point > ZV) 562 else if (new_point > ZV)
@@ -552,15 +564,14 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
552 else 564 else
553 SET_PT (new_point); 565 SET_PT (new_point);
554 } 566 }
555
556 windows_or_buffers_changed++;
557 return window;
558} 567}
559 568
560DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, 569DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
561 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. 570 doc: /* Select WINDOW which must be a live window.
562Also make WINDOW's buffer current and make WINDOW the frame's selected 571Also make WINDOW's frame the selected frame and WINDOW that frame's
563window. Return WINDOW. 572selected window. In addition, make WINDOW's buffer current and set that
573buffer's value of `point' to the value of WINDOW's `window-point'.
574Return WINDOW.
564 575
565Optional second arg NORECORD non-nil means do not put this buffer at the 576Optional second arg NORECORD non-nil means do not put this buffer at the
566front of the buffer list and do not make this window the most recently 577front of the buffer list and do not make this window the most recently
@@ -791,12 +802,12 @@ window_body_cols (struct window *w)
791 occupies one column only. */ 802 occupies one column only. */
792 width -= 1; 803 width -= 1;
793 804
805 /* Display margins cannot be used for normal text. */
806 width -= WINDOW_LEFT_MARGIN_COLS (w) + WINDOW_RIGHT_MARGIN_COLS (w);
807
794 if (FRAME_WINDOW_P (f)) 808 if (FRAME_WINDOW_P (f))
795 /* On window-systems, fringes and display margins cannot be 809 /* On window-systems, fringes cannot be used for normal text. */
796 used for normal text. */ 810 width -= WINDOW_FRINGE_COLS (w);
797 width -= (WINDOW_FRINGE_COLS (w)
798 + WINDOW_LEFT_MARGIN_COLS (w)
799 + WINDOW_RIGHT_MARGIN_COLS (w));
800 811
801 return width; 812 return width;
802} 813}