-
-;; `windmove-coordinates-of-position' is stolen and modified from the
-;; Emacs Lisp Reference Manual, section 27.2.5. It seems to work
-;; okay, although I am bothered by the fact that tab-offset (the cdr
-;; of the next-to- last argument) is set to 0. On the other hand, I
-;; can't find a single usage of `compute-motion' anywhere that doesn't
-;; set this component to zero, and I'm too lazy to grovel through the
-;; C source to figure out what's happening in the background. there
-;; also seems to be a good deal of fun in calculating the correct
-;; width of lines for telling `compute-motion' about; in particular,
-;; it seems we need to subtract 1 (for the continuation column) from
-;; the number that `window-width' gives, or continuation lines aren't
-;; counted correctly. I haven't seen anyone doing this before,
-;; though.
-(defun windmove-coordinates-of-position (pos &optional window)
- "Return the coordinates of position POS in window WINDOW.
-Return the window-based coodinates in a cons pair: (HPOS . VPOS),
-where HPOS and VPOS are the zero-based x and y components of the
-screen location of POS. If WINDOW is nil, return the coordinates in
-the currently selected window.
-As an example, if point is in the top left corner of a window, then
-the return value from `windmove-coordinates-of-position' is (0 . 0)
-regardless of the where point is in the buffer and where the window
-is placed in the frame."
- (let* ((wind (if (null window) (selected-window) window))
- (usable-width (1- (window-width wind))) ; 1- for cont. column
- (usable-height (1- (window-height wind))) ; 1- for mode line
- (big-hairy-result (compute-motion
- (window-start)
- '(0 . 0)
- pos
- (cons usable-width usable-height)
- usable-width
- (cons (window-hscroll)
- 0) ; why zero?
- wind)))
- (cons (nth 1 big-hairy-result) ; hpos, not vpos as documented
- (nth 2 big-hairy-result)))) ; vpos, not hpos as documented
-