diff options
author | Martin Rudalics <[email protected]> | 2012-08-21 11:27:07 +0200 |
---|---|---|
committer | Martin Rudalics <[email protected]> | 2012-08-21 11:27:07 +0200 |
commit | 5481664ac42e532f7636941e29cf31b3163587c6 (patch) | |
tree | 634ff4414fd635d9bb7f7ec988546438092d5eb3 /src | |
parent | 9f1ee09efc42e82df21d0697cda35189f0618cd8 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 7 | ||||
-rw-r--r-- | src/window.c | 52 |
2 files changed, 38 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5a7c692302..15eac722f8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-08-21 Martin Rudalics <[email protected]> + + * 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. + 2012-08-21 Dmitry Antipov <[email protected]> Setter macros for fontsets. diff --git a/src/window.c b/src/window.c index 9045721009..4d92566b24 100644 --- a/src/window.c +++ b/src/window.c @@ -1407,22 +1407,21 @@ DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, doc: /* Return current value of point in WINDOW. WINDOW must be a live window and defaults to the selected one. -For a nonselected window, this is the value point would have -if that window were selected. - -Note that, when WINDOW is the selected window and its buffer -is also currently selected, the value returned is the same as (point). -It would be more strictly correct to return the `top-level' value -of point, outside of any save-excursion forms. -But that is hard to define. */) +For a nonselected window, this is the value point would have if that +window were selected. + +Note that, when WINDOW is selected, the value returned is the same as +that returned by `point' for WINDOW's buffer. It would be more strictly +correct to return the `top-level' value of `point', outside of any +`save-excursion' forms. But that is hard to define. */) (Lisp_Object window) { register struct window *w = decode_live_window (window); - if (w == XWINDOW (selected_window) - && current_buffer == XBUFFER (w->buffer)) - return Fpoint (); - return Fmarker_position (w->pointm); + if (w == XWINDOW (selected_window)) + return make_number (BUF_PT (XBUFFER (w->buffer))); + else + return Fmarker_position (w->pointm); } DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, @@ -1532,16 +1531,27 @@ Return POS. */) register struct window *w = decode_live_window (window); CHECK_NUMBER_COERCE_MARKER (pos); - if (w == XWINDOW (selected_window) - && XBUFFER (w->buffer) == current_buffer) - Fgoto_char (pos); - else - set_marker_restricted (w->pointm, pos, w->buffer); - /* We have to make sure that redisplay updates the window to show - the new value of point. */ - if (!EQ (window, selected_window)) - ++windows_or_buffers_changed; + if (w == XWINDOW (selected_window)) + { + if (XBUFFER (w->buffer) == current_buffer) + Fgoto_char (pos); + else + { + struct buffer *old_buffer = current_buffer; + + set_buffer_internal (XBUFFER (w->buffer)); + Fgoto_char (pos); + set_buffer_internal (old_buffer); + } + } + else + { + set_marker_restricted (w->pointm, pos, w->buffer); + /* We have to make sure that redisplay updates the window to show + the new value of point. */ + ++windows_or_buffers_changed; + } return pos; } |