Mercurial > emacs
diff lisp/windmove.el @ 89978:566253900690
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-40
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-535
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-536
sync-tree with gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-537
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-538
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-539
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-540
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-541
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-542
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-545
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-546
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-547
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-548
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-549
Use symbol-matching for generic-mode keywords
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-550
Update from CVS
* miles@gnu.org--gnu-2004/gnus--devo--0--patch-2
Add {arch}/=cvs-sync-make-log
* miles@gnu.org--gnu-2004/gnus--rel--5.8--base-0
Import from Gnus CVS branch V5-8
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-1
{arch}/=tagging-method: Add CVS and autoconf grot to junk regexp
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-2
Use explicit tags for autoconf input files
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-3
Remove RCS keywords
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-4
Fix copied explicit id-tags
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-5
Add {arch}/=cvs-sync-make-log
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-6
configure.in: Use ifelse instead of m4_if for arch-tag: comment
* miles@gnu.org--gnu-2004/gnus--rel--5.10--base-0
tag of miles@gnu.org--gnu-2004/gnus--rel--5.8--base-0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-1
Gnus 5.10, from CVS branch v5-10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-2
Merge from gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-3
Use explicit tags for autoconf input files
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-4
sync-tree with gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-5
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-6
Merge from gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-7
Remove RCS keywords
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-8
Merge from gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-9
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-10
Add {arch}/=cvs-sync-make-log
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-11
Merge from gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-12
Update from CVS: make.bat: Fix line endings around arch-tag.
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-13
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-17
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-21
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-22
Update from CVS: lisp/nndb.el (require): Remove tcp and duplicate cl.
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-23
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-24
lisp/nnimap.el (nnimap-open-connection): Remove extraneous end-paren
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-25
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-26
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 15 Sep 2004 09:00:10 +0000 |
parents | 0bdb5a16ae51 5f904f95d7fd |
children | f9a65d7ebd29 |
line wrap: on
line diff
--- a/lisp/windmove.el Tue Sep 14 07:55:38 2004 +0000 +++ b/lisp/windmove.el Wed Sep 15 09:00:10 2004 +0000 @@ -324,11 +324,11 @@ (let* ((frame (if window (window-frame window) (selected-frame))) - (top-left (window-inside-edges (frame-first-window frame))) + (top-left (window-edges (frame-first-window frame))) (x-min (nth 0 top-left)) (y-min (nth 1 top-left)) - (x-max (+ x-min (frame-width frame) -1)) ; 1- for last row & col - (y-max (+ x-max (frame-height frame) -1))) + (x-max (1- (frame-width frame))) ; 1- for last row & col + (y-max (1- (frame-height frame)))) (list x-min y-min x-max y-max))) ;; it turns out that constraining is always a good thing, even when @@ -406,7 +406,7 @@ ;; `windmove-coordinates-of-position' is stolen and modified from the -;; Emacs Lisp Reference Manual, section 27.2.5. It seems to work +;; Emacs 20 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 @@ -418,28 +418,43 @@ ;; 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. +;; +;; Now updated for Emacs 21, based on the Emacs 21 Lisp Reference +;; Manual, section 30.2.5. It is no longer necessary to subtract +;; 1 for the usable width of the window. +;; TODO: also handle minibuffer case, w/ `minibuffer-prompt-width'. +(defun windmove-coordinates-of-position (pos) + "Return the coordinates of position POS in the current 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. +screen location of POS. 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)) - (big-hairy-result (compute-motion - (window-start) - '(0 . 0) - pos - nil ; (window-width window-height) - nil ; window-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 + (let ((big-hairy-result (compute-motion + (window-start) + '(0 . 0) + pos + nil ; (window-width window-height) + nil ; window-width + (cons (window-hscroll) + 0) ; why zero? + (selected-window)))) + (cons (nth 1 big-hairy-result) ; hpos, not vpos as documented + (nth 2 big-hairy-result)))) ; vpos, not hpos as documented + +(defun windmove-coordinates-of-window-position (pos &optional window) + "Return the coordinates of position POS in 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." + (if (null window) + (windmove-coordinates-of-position pos) + (save-selected-window + (select-window window) + (windmove-coordinates-of-position pos)))) ;; This calculates the reference location in the current window: the ;; frame-based (x . y) of either point, the top-left, or the @@ -467,8 +482,9 @@ ((= effective-arg 0) (windmove-coord-add top-left - (windmove-coordinates-of-position (window-point window) - window))))))) + (windmove-coordinates-of-window-position + (window-point window) + window))))))) ;; This uses the reference location in the current window (calculated ;; by `windmove-reference-loc' above) to find a reference location @@ -491,13 +507,13 @@ (- (nth 1 edges) windmove-window-distance-delta))) ; (x, y0-d) ((eq dir 'right) - (cons (+ (nth 2 edges) + (cons (+ (1- (nth 2 edges)) ; -1 to get actual max x windmove-window-distance-delta) - (cdr refpoint))) ; (x1+d, y) - ((eq dir 'down) + (cdr refpoint))) ; (x1+d-1, y) + ((eq dir 'down) ; -1 to get actual max y (cons (car refpoint) - (+ (nth 3 edges) - windmove-window-distance-delta))) ; (x, y1+d) + (+ (1- (nth 3 edges)) + windmove-window-distance-delta))) ; (x, y1+d-1) (t (error "Invalid direction of movement: %s" dir))))) (defun windmove-find-other-window (dir &optional arg window)