comparison lisp/subr.el @ 54866:47cdc4f7ee17

(posn-set-point): New function.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 14 Apr 2004 17:28:33 +0000
parents 8bcf0c459630
children a19fbbfac280
comparison
equal deleted inserted replaced
54865:50d070a98492 54866:47cdc4f7ee17
676 (and (consp object) 676 (and (consp object)
677 (eq (car object) 'mouse-movement))) 677 (eq (car object) 'mouse-movement)))
678 678
679 (defsubst event-start (event) 679 (defsubst event-start (event)
680 "Return the starting position of EVENT. 680 "Return the starting position of EVENT.
681 If EVENT is a mouse press or a mouse click, this returns the location 681 If EVENT is a mouse or key press or a mouse click, this returns the location
682 of the event. 682 of the event.
683 If EVENT is a drag, this returns the drag's starting position. 683 If EVENT is a drag, this returns the drag's starting position.
684 The return value is of the form 684 The return value is of the form
685 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) 685 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW)
686 IMAGE (DX . DY) (WIDTH . HEIGHT)) 686 IMAGE (DX . DY) (WIDTH . HEIGHT))
687 The `posn-' functions access elements of such lists." 687 The `posn-' functions access elements of such lists."
688 (if (consp event) (nth 1 event) 688 (if (consp event) (nth 1 event)
689 (list (selected-window) (point) '(0 . 0) 0))) 689 (list (selected-window) (point) '(0 . 0) 0)))
690 690
691 (defsubst event-end (event) 691 (defsubst event-end (event)
692 "Return the ending location of EVENT. EVENT should be a click or drag event. 692 "Return the ending location of EVENT.
693 EVENT should be a click, drag, or key press event.
693 If EVENT is a click event, this function is the same as `event-start'. 694 If EVENT is a click event, this function is the same as `event-start'.
694 The return value is of the form 695 The return value is of the form
695 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) 696 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW)
696 IMAGE (DX . DY) (WIDTH . HEIGHT)) 697 IMAGE (DX . DY) (WIDTH . HEIGHT))
697 The `posn-' functions access elements of such lists." 698 The `posn-' functions access elements of such lists."
724 and `event-end' functions." 725 and `event-end' functions."
725 (or (nth 5 position) 726 (or (nth 5 position)
726 (if (consp (nth 1 position)) 727 (if (consp (nth 1 position))
727 (car (nth 1 position)) 728 (car (nth 1 position))
728 (nth 1 position)))) 729 (nth 1 position))))
730
731 (defun posn-set-point (position)
732 "Move point to POSITION.
733 Select the corresponding window as well."
734 (if (not (windowp (posn-window posn)))
735 (error "Position not in text area of window"))
736 (select-window (posn-window posn))
737 (if (numberp (posn-point posn))
738 (goto-char (posn-point posn))))
729 739
730 (defsubst posn-x-y (position) 740 (defsubst posn-x-y (position)
731 "Return the x and y coordinates in POSITION. 741 "Return the x and y coordinates in POSITION.
732 POSITION should be a list of the form returned by the `event-start' 742 POSITION should be a list of the form returned by the `event-start'
733 and `event-end' functions." 743 and `event-end' functions."