diff options
| author | Kim F. Storm | 2005-08-17 15:03:00 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-08-17 15:03:00 +0000 |
| commit | acf681d713f3b42bce29cd910911ef805e059472 (patch) | |
| tree | 01c456cd7c671faeb07b4d77834dc2baaa9f762c | |
| parent | 0eefa6fbb54b3f1ca937ca7db3ccc06967c4e656 (diff) | |
| download | emacs-acf681d713f3b42bce29cd910911ef805e059472.tar.gz emacs-acf681d713f3b42bce29cd910911ef805e059472.zip | |
(windmove-coordinates-of-position): Remove.
(windmove-coordinates-of-window-position): Remove.
(windmove-reference-loc): Use posn-at-point instead.
| -rw-r--r-- | lisp/windmove.el | 67 |
1 files changed, 7 insertions, 60 deletions
diff --git a/lisp/windmove.el b/lisp/windmove.el index dabaeb9ebc3..b3aacf62d51 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el | |||
| @@ -207,11 +207,8 @@ placement bugs in old versions of Emacs." | |||
| 207 | ;; rest. | 207 | ;; rest. |
| 208 | ;; | 208 | ;; |
| 209 | ;; This work is done by `windmove-reference-loc'. It can figure out | 209 | ;; This work is done by `windmove-reference-loc'. It can figure out |
| 210 | ;; the locations of the corners by calling `window-edges', but to | 210 | ;; the locations of the corners by calling `window-edges' combined |
| 211 | ;; calculate the frame-based location of point, it calls the workhorse | 211 | ;; with the result of `posn-at-point'. |
| 212 | ;; function `windmove-coordinates-of-position', which itself calls the | ||
| 213 | ;; incredibly hairy builtin `compute-motion'. There is a good deal of | ||
| 214 | ;; black magic in getting all the arguments to this function just right. | ||
| 215 | ;; | 212 | ;; |
| 216 | ;; The second step is more messy. Conceptually, it is fairly simple: | 213 | ;; The second step is more messy. Conceptually, it is fairly simple: |
| 217 | ;; if we know the reference location, and the coordinates of the | 214 | ;; if we know the reference location, and the coordinates of the |
| @@ -405,58 +402,6 @@ Returns the wrapped coordinate." | |||
| 405 | (windmove-constrain-around-range (cdr coord) min-y max-y))))) | 402 | (windmove-constrain-around-range (cdr coord) min-y max-y))))) |
| 406 | 403 | ||
| 407 | 404 | ||
| 408 | |||
| 409 | ;; `windmove-coordinates-of-position' is stolen and modified from the | ||
| 410 | ;; Emacs 20 Lisp Reference Manual, section 27.2.5. It seems to work | ||
| 411 | ;; okay, although I am bothered by the fact that tab-offset (the cdr | ||
| 412 | ;; of the next-to- last argument) is set to 0. On the other hand, I | ||
| 413 | ;; can't find a single usage of `compute-motion' anywhere that doesn't | ||
| 414 | ;; set this component to zero, and I'm too lazy to grovel through the | ||
| 415 | ;; C source to figure out what's happening in the background. there | ||
| 416 | ;; also seems to be a good deal of fun in calculating the correct | ||
| 417 | ;; width of lines for telling `compute-motion' about; in particular, | ||
| 418 | ;; it seems we need to subtract 1 (for the continuation column) from | ||
| 419 | ;; the number that `window-width' gives, or continuation lines aren't | ||
| 420 | ;; counted correctly. I haven't seen anyone doing this before, | ||
| 421 | ;; though. | ||
| 422 | ;; | ||
| 423 | ;; Now updated for Emacs 21, based on the Emacs 21 Lisp Reference | ||
| 424 | ;; Manual, section 30.2.5. It is no longer necessary to subtract | ||
| 425 | ;; 1 for the usable width of the window. | ||
| 426 | ;; TODO: also handle minibuffer case, w/ `minibuffer-prompt-width'. | ||
| 427 | (defun windmove-coordinates-of-position (pos) | ||
| 428 | "Return the coordinates of position POS in the current window. | ||
| 429 | Return the window-based coodinates in a cons pair: (HPOS . VPOS), | ||
| 430 | where HPOS and VPOS are the zero-based x and y components of the | ||
| 431 | screen location of POS. | ||
| 432 | As an example, if point is in the top left corner of a window, then | ||
| 433 | the return value from `windmove-coordinates-of-position' is (0 . 0) | ||
| 434 | regardless of the where point is in the buffer and where the window | ||
| 435 | is placed in the frame." | ||
| 436 | (let ((big-hairy-result (compute-motion | ||
| 437 | (window-start) | ||
| 438 | '(0 . 0) | ||
| 439 | pos | ||
| 440 | nil ; (window-width window-height) | ||
| 441 | nil ; window-width | ||
| 442 | (cons (window-hscroll) | ||
| 443 | 0) ; why zero? | ||
| 444 | (selected-window)))) | ||
| 445 | (cons (nth 1 big-hairy-result) ; hpos, not vpos as documented | ||
| 446 | (nth 2 big-hairy-result)))) ; vpos, not hpos as documented | ||
| 447 | |||
| 448 | (defun windmove-coordinates-of-window-position (pos &optional window) | ||
| 449 | "Return the coordinates of position POS in WINDOW. | ||
| 450 | Return the window-based coodinates in a cons pair: (HPOS . VPOS), | ||
| 451 | where HPOS and VPOS are the zero-based x and y components of the | ||
| 452 | screen location of POS. If WINDOW is nil, return the coordinates in | ||
| 453 | the currently selected window." | ||
| 454 | (if (null window) | ||
| 455 | (windmove-coordinates-of-position pos) | ||
| 456 | (save-selected-window | ||
| 457 | (select-window window) | ||
| 458 | (windmove-coordinates-of-position pos)))) | ||
| 459 | |||
| 460 | ;; This calculates the reference location in the current window: the | 405 | ;; This calculates the reference location in the current window: the |
| 461 | ;; frame-based (x . y) of either point, the top-left, or the | 406 | ;; frame-based (x . y) of either point, the top-left, or the |
| 462 | ;; bottom-right of the window, depending on ARG. | 407 | ;; bottom-right of the window, depending on ARG. |
| @@ -483,9 +428,11 @@ supplied, if ARG is greater or smaller than zero, respectively." | |||
| 483 | ((= effective-arg 0) | 428 | ((= effective-arg 0) |
| 484 | (windmove-coord-add | 429 | (windmove-coord-add |
| 485 | top-left | 430 | top-left |
| 486 | (windmove-coordinates-of-window-position | 431 | (let ((col-row |
| 487 | (window-point window) | 432 | (posn-col-row |
| 488 | window))))))) | 433 | (posn-at-point (window-point window) window)))) |
| 434 | (cons (- (car col-row) (window-hscroll window)) | ||
| 435 | (cdr col-row))))))))) | ||
| 489 | 436 | ||
| 490 | ;; This uses the reference location in the current window (calculated | 437 | ;; This uses the reference location in the current window (calculated |
| 491 | ;; by `windmove-reference-loc' above) to find a reference location | 438 | ;; by `windmove-reference-loc' above) to find a reference location |