diff options
| author | Martin Rudalics | 2012-08-21 11:27:07 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2012-08-21 11:27:07 +0200 |
| commit | 5481664ac42e532f7636941e29cf31b3163587c6 (patch) | |
| tree | 634ff4414fd635d9bb7f7ec988546438092d5eb3 | |
| parent | 9f1ee09efc42e82df21d0697cda35189f0618cd8 (diff) | |
| download | emacs-5481664ac42e532f7636941e29cf31b3163587c6.tar.gz emacs-5481664ac42e532f7636941e29cf31b3163587c6.zip | |
For selected window have (set-)window-point always operate on buffer's point.
* window.c (Fwindow_point): For the selected window always return
the position of its buffer's point.
(Fset_window_point): For the selected window always go in its
buffer to the specified position.
* window.el (window-point-1, set-window-point-1): Remove.
(window-in-direction, record-window-buffer)
(set-window-buffer-start-and-point, split-window-below)
(window--state-get-1, display-buffer-record-window): Replace
calls to window-point-1 and set-window-point-1 by calls to
window-point and set-window-point respectively.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/window.el | 40 | ||||
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/window.c | 52 |
4 files changed, 54 insertions, 54 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 11bdce9a230..3098d1657fc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-08-21 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.el (window-point-1, set-window-point-1): Remove. | ||
| 4 | (window-in-direction, record-window-buffer) | ||
| 5 | (set-window-buffer-start-and-point, split-window-below) | ||
| 6 | (window--state-get-1, display-buffer-record-window): Replace | ||
| 7 | calls to window-point-1 and set-window-point-1 by calls to | ||
| 8 | window-point and set-window-point respectively. | ||
| 9 | |||
| 1 | 2012-08-21 Glenn Morris <rgm@gnu.org> | 10 | 2012-08-21 Glenn Morris <rgm@gnu.org> |
| 2 | 11 | ||
| 3 | * calendar/cal-tex.el (cal-tex-leftday, cal-tex-rightday): | 12 | * calendar/cal-tex.el (cal-tex-leftday, cal-tex-rightday): |
diff --git a/lisp/window.el b/lisp/window.el index 142e80e1666..f6209730a7a 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -1062,32 +1062,6 @@ windows nor the buffer list." | |||
| 1062 | (dolist (walk-windows-window (window-list-1 nil minibuf all-frames)) | 1062 | (dolist (walk-windows-window (window-list-1 nil minibuf all-frames)) |
| 1063 | (funcall fun walk-windows-window)))) | 1063 | (funcall fun walk-windows-window)))) |
| 1064 | 1064 | ||
| 1065 | (defun window-point-1 (&optional window) | ||
| 1066 | "Return value of WINDOW's point. | ||
| 1067 | WINDOW can be any live window and defaults to the selected one. | ||
| 1068 | |||
| 1069 | This function is like `window-point' with one exception: If | ||
| 1070 | WINDOW is selected, it returns the value of `point' of WINDOW's | ||
| 1071 | buffer regardless of whether that buffer is current or not." | ||
| 1072 | (setq window (window-normalize-window window t)) | ||
| 1073 | (if (eq window (selected-window)) | ||
| 1074 | (with-current-buffer (window-buffer window) | ||
| 1075 | (point)) | ||
| 1076 | (window-point window))) | ||
| 1077 | |||
| 1078 | (defun set-window-point-1 (window pos) | ||
| 1079 | "Set value of WINDOW's point to POS. | ||
| 1080 | WINDOW can be any live window and defaults to the selected one. | ||
| 1081 | |||
| 1082 | This function is like `set-window-point' with one exception: If | ||
| 1083 | WINDOW is selected, it moves `point' of WINDOW's buffer to POS | ||
| 1084 | regardless of whether that buffer is current or not." | ||
| 1085 | (setq window (window-normalize-window window t)) | ||
| 1086 | (if (eq window (selected-window)) | ||
| 1087 | (with-current-buffer (window-buffer window) | ||
| 1088 | (goto-char pos)) | ||
| 1089 | (set-window-point window pos))) | ||
| 1090 | |||
| 1091 | (defun window-at-side-p (&optional window side) | 1065 | (defun window-at-side-p (&optional window side) |
| 1092 | "Return t if WINDOW is at SIDE of its containing frame. | 1066 | "Return t if WINDOW is at SIDE of its containing frame. |
| 1093 | WINDOW must be a valid window and defaults to the selected one. | 1067 | WINDOW must be a valid window and defaults to the selected one. |
| @@ -1146,7 +1120,7 @@ IGNORE non-nil means a window can be returned even if its | |||
| 1146 | (last (+ first (if hor | 1120 | (last (+ first (if hor |
| 1147 | (window-total-width window) | 1121 | (window-total-width window) |
| 1148 | (window-total-height window)))) | 1122 | (window-total-height window)))) |
| 1149 | (posn-cons (nth 6 (posn-at-point (window-point-1 window) window))) | 1123 | (posn-cons (nth 6 (posn-at-point (window-point window) window))) |
| 1150 | ;; The column / row value of `posn-at-point' can be nil for the | 1124 | ;; The column / row value of `posn-at-point' can be nil for the |
| 1151 | ;; mini-window, guard against that. | 1125 | ;; mini-window, guard against that. |
| 1152 | (posn (if hor | 1126 | (posn (if hor |
| @@ -2613,7 +2587,7 @@ WINDOW must be a live window and defaults to the selected one." | |||
| 2613 | ;; Add an entry for buffer to WINDOW's previous buffers. | 2587 | ;; Add an entry for buffer to WINDOW's previous buffers. |
| 2614 | (with-current-buffer buffer | 2588 | (with-current-buffer buffer |
| 2615 | (let ((start (window-start window)) | 2589 | (let ((start (window-start window)) |
| 2616 | (point (window-point-1 window))) | 2590 | (point (window-point window))) |
| 2617 | (setq entry | 2591 | (setq entry |
| 2618 | (cons buffer | 2592 | (cons buffer |
| 2619 | (if entry | 2593 | (if entry |
| @@ -2657,7 +2631,7 @@ before was current this also makes BUFFER the current buffer." | |||
| 2657 | ;; Don't force window-start here (even if POINT is nil). | 2631 | ;; Don't force window-start here (even if POINT is nil). |
| 2658 | (set-window-start window start t)) | 2632 | (set-window-start window start t)) |
| 2659 | (when point | 2633 | (when point |
| 2660 | (set-window-point-1 window point)))) | 2634 | (set-window-point window point)))) |
| 2661 | 2635 | ||
| 2662 | (defcustom switch-to-visible-buffer t | 2636 | (defcustom switch-to-visible-buffer t |
| 2663 | "If non-nil, allow switching to an already visible buffer. | 2637 | "If non-nil, allow switching to an already visible buffer. |
| @@ -3393,7 +3367,7 @@ Otherwise, the window starts are chosen so as to minimize the | |||
| 3393 | amount of redisplay; this is convenient on slow terminals." | 3367 | amount of redisplay; this is convenient on slow terminals." |
| 3394 | (interactive "P") | 3368 | (interactive "P") |
| 3395 | (let ((old-window (selected-window)) | 3369 | (let ((old-window (selected-window)) |
| 3396 | (old-point (window-point-1)) | 3370 | (old-point (window-point)) |
| 3397 | (size (and size (prefix-numeric-value size))) | 3371 | (size (and size (prefix-numeric-value size))) |
| 3398 | moved-by-window-height moved new-window bottom) | 3372 | moved-by-window-height moved new-window bottom) |
| 3399 | (when (and size (< size 0) (< (- size) window-min-height)) | 3373 | (when (and size (< size 0) (< (- size) window-min-height)) |
| @@ -3418,7 +3392,7 @@ amount of redisplay; this is convenient on slow terminals." | |||
| 3418 | (setq bottom (point))) | 3392 | (setq bottom (point))) |
| 3419 | (and moved-by-window-height | 3393 | (and moved-by-window-height |
| 3420 | (<= bottom (point)) | 3394 | (<= bottom (point)) |
| 3421 | (set-window-point-1 old-window (1- bottom))) | 3395 | (set-window-point old-window (1- bottom))) |
| 3422 | (and moved-by-window-height | 3396 | (and moved-by-window-height |
| 3423 | (<= (window-start new-window) old-point) | 3397 | (<= (window-start new-window) old-point) |
| 3424 | (set-window-point new-window old-point) | 3398 | (set-window-point new-window old-point) |
| @@ -3727,7 +3701,7 @@ specific buffers." | |||
| 3727 | `((parameters . ,list)))) | 3701 | `((parameters . ,list)))) |
| 3728 | ,@(when buffer | 3702 | ,@(when buffer |
| 3729 | ;; All buffer related things go in here. | 3703 | ;; All buffer related things go in here. |
| 3730 | (let ((point (window-point-1 window)) | 3704 | (let ((point (window-point window)) |
| 3731 | (start (window-start window))) | 3705 | (start (window-start window))) |
| 3732 | `((buffer | 3706 | `((buffer |
| 3733 | ,(buffer-name buffer) | 3707 | ,(buffer-name buffer) |
| @@ -4020,7 +3994,7 @@ element is BUFFER." | |||
| 4020 | (list 'other | 3994 | (list 'other |
| 4021 | ;; A quadruple of WINDOW's buffer, start, point and height. | 3995 | ;; A quadruple of WINDOW's buffer, start, point and height. |
| 4022 | (list (window-buffer window) (window-start window) | 3996 | (list (window-buffer window) (window-start window) |
| 4023 | (window-point-1 window) (window-total-size window)) | 3997 | (window-point window) (window-total-size window)) |
| 4024 | (selected-window) buffer)))) | 3998 | (selected-window) buffer)))) |
| 4025 | ((eq type 'window) | 3999 | ((eq type 'window) |
| 4026 | ;; WINDOW has been created on an existing frame. | 4000 | ;; WINDOW has been created on an existing frame. |
diff --git a/src/ChangeLog b/src/ChangeLog index 5a7c6923029..15eac722f8e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-08-21 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.c (Fwindow_point): For the selected window always return | ||
| 4 | the position of its buffer's point. | ||
| 5 | (Fset_window_point): For the selected window always go in its | ||
| 6 | buffer to the specified position. | ||
| 7 | |||
| 1 | 2012-08-21 Dmitry Antipov <dmantipov@yandex.ru> | 8 | 2012-08-21 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 9 | ||
| 3 | Setter macros for fontsets. | 10 | Setter macros for fontsets. |
diff --git a/src/window.c b/src/window.c index 9045721009d..4d92566b243 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -1407,22 +1407,21 @@ DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, | |||
| 1407 | doc: /* Return current value of point in WINDOW. | 1407 | doc: /* Return current value of point in WINDOW. |
| 1408 | WINDOW must be a live window and defaults to the selected one. | 1408 | WINDOW must be a live window and defaults to the selected one. |
| 1409 | 1409 | ||
| 1410 | For a nonselected window, this is the value point would have | 1410 | For a nonselected window, this is the value point would have if that |
| 1411 | if that window were selected. | 1411 | window were selected. |
| 1412 | 1412 | ||
| 1413 | Note that, when WINDOW is the selected window and its buffer | 1413 | Note that, when WINDOW is selected, the value returned is the same as |
| 1414 | is also currently selected, the value returned is the same as (point). | 1414 | that returned by `point' for WINDOW's buffer. It would be more strictly |
| 1415 | It would be more strictly correct to return the `top-level' value | 1415 | correct to return the `top-level' value of `point', outside of any |
| 1416 | of point, outside of any save-excursion forms. | 1416 | `save-excursion' forms. But that is hard to define. */) |
| 1417 | But that is hard to define. */) | ||
| 1418 | (Lisp_Object window) | 1417 | (Lisp_Object window) |
| 1419 | { | 1418 | { |
| 1420 | register struct window *w = decode_live_window (window); | 1419 | register struct window *w = decode_live_window (window); |
| 1421 | 1420 | ||
| 1422 | if (w == XWINDOW (selected_window) | 1421 | if (w == XWINDOW (selected_window)) |
| 1423 | && current_buffer == XBUFFER (w->buffer)) | 1422 | return make_number (BUF_PT (XBUFFER (w->buffer))); |
| 1424 | return Fpoint (); | 1423 | else |
| 1425 | return Fmarker_position (w->pointm); | 1424 | return Fmarker_position (w->pointm); |
| 1426 | } | 1425 | } |
| 1427 | 1426 | ||
| 1428 | DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, | 1427 | DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, |
| @@ -1532,16 +1531,27 @@ Return POS. */) | |||
| 1532 | register struct window *w = decode_live_window (window); | 1531 | register struct window *w = decode_live_window (window); |
| 1533 | 1532 | ||
| 1534 | CHECK_NUMBER_COERCE_MARKER (pos); | 1533 | CHECK_NUMBER_COERCE_MARKER (pos); |
| 1535 | if (w == XWINDOW (selected_window) | ||
| 1536 | && XBUFFER (w->buffer) == current_buffer) | ||
| 1537 | Fgoto_char (pos); | ||
| 1538 | else | ||
| 1539 | set_marker_restricted (w->pointm, pos, w->buffer); | ||
| 1540 | 1534 | ||
| 1541 | /* We have to make sure that redisplay updates the window to show | 1535 | if (w == XWINDOW (selected_window)) |
| 1542 | the new value of point. */ | 1536 | { |
| 1543 | if (!EQ (window, selected_window)) | 1537 | if (XBUFFER (w->buffer) == current_buffer) |
| 1544 | ++windows_or_buffers_changed; | 1538 | Fgoto_char (pos); |
| 1539 | else | ||
| 1540 | { | ||
| 1541 | struct buffer *old_buffer = current_buffer; | ||
| 1542 | |||
| 1543 | set_buffer_internal (XBUFFER (w->buffer)); | ||
| 1544 | Fgoto_char (pos); | ||
| 1545 | set_buffer_internal (old_buffer); | ||
| 1546 | } | ||
| 1547 | } | ||
| 1548 | else | ||
| 1549 | { | ||
| 1550 | set_marker_restricted (w->pointm, pos, w->buffer); | ||
| 1551 | /* We have to make sure that redisplay updates the window to show | ||
| 1552 | the new value of point. */ | ||
| 1553 | ++windows_or_buffers_changed; | ||
| 1554 | } | ||
| 1545 | 1555 | ||
| 1546 | return pos; | 1556 | return pos; |
| 1547 | } | 1557 | } |