From: Stefan Monnier Date: Wed, 14 Apr 2004 17:28:33 +0000 (+0000) Subject: (posn-set-point): New function. X-Git-Tag: ttn-vms-21-2-B4~6838 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=17f53ffa0f03149217fb382bbadf8ffd917008bb;p=emacs.git (posn-set-point): New function. --- diff --git a/lisp/subr.el b/lisp/subr.el index 74809c678eb..d93ffa7150b 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -678,7 +678,7 @@ The value is a printing character (not upper case) or a symbol." (defsubst event-start (event) "Return the starting position of EVENT. -If EVENT is a mouse press or a mouse click, this returns the location +If EVENT is a mouse or key press or a mouse click, this returns the location of the event. If EVENT is a drag, this returns the drag's starting position. The return value is of the form @@ -689,7 +689,8 @@ The `posn-' functions access elements of such lists." (list (selected-window) (point) '(0 . 0) 0))) (defsubst event-end (event) - "Return the ending location of EVENT. EVENT should be a click or drag event. + "Return the ending location of EVENT. +EVENT should be a click, drag, or key press event. If EVENT is a click event, this function is the same as `event-start'. The return value is of the form (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) @@ -727,6 +728,15 @@ and `event-end' functions." (car (nth 1 position)) (nth 1 position)))) +(defun posn-set-point (position) + "Move point to POSITION. +Select the corresponding window as well." + (if (not (windowp (posn-window posn))) + (error "Position not in text area of window")) + (select-window (posn-window posn)) + (if (numberp (posn-point posn)) + (goto-char (posn-point posn)))) + (defsubst posn-x-y (position) "Return the x and y coordinates in POSITION. POSITION should be a list of the form returned by the `event-start'