Function: set-window-point

set-window-point is a function defined in window.c.

Signature

(set-window-point WINDOW POS)

Documentation

Make point value in WINDOW be at position POS in WINDOW's buffer.

WINDOW must be a live window and defaults to the selected one. Return POS.

Probably introduced at or before Emacs version 17.

Source Code

// Defined in /usr/src/emacs/src/window.c
{
  register struct window *w = decode_live_window (window);

  /* Type of POS is checked by Fgoto_char or set_marker_restricted ...  */

  if (w == XWINDOW (selected_window))
    {
      if (XBUFFER (w->contents) == current_buffer)
	Fgoto_char (pos);
      else
	{
	  struct buffer *old_buffer = current_buffer;

	  /* ... but here we want to catch type error before buffer change.  */
	  CHECK_FIXNUM_COERCE_MARKER (pos);
	  set_buffer_internal (XBUFFER (w->contents));
	  Fgoto_char (pos);
	  set_buffer_internal (old_buffer);
	}
    }
  else
    {
      set_marker_restricted (w->pointm, pos, w->contents);
      /* We have to make sure that redisplay updates the window to show
	 the new value of point.  */
      wset_redisplay (w);
    }

  return pos;
}