emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

simplifying windmove-frame-edges


From: Juanma Barranquero
Subject: simplifying windmove-frame-edges
Date: Wed, 23 Oct 2019 13:54:14 +0200


A few years ago (well, fifteen, really), `windmove-frame-edges' was changed with this commit

commit 82ae2f3f78fca3b1932e60fbb4bb1fa050cea6db
 Author: Eli Zaretskii <address@hidden>
 Date:   2004-09-13 20:08:44 +0000

     (windmove-frame-edges): Report coordinates of
     outside edges of frame, not inside edges.
     (windmove-coordinates-of-position): Convert into wrapper to new
     function `windmove-coordinates-of-window-position';
     `compute-motion' always applies to selected window.
     (windmove-coordinates-of-position): Update documentation to refer
     to Emacs 21 Lisp Reference Manual.
     (windmove-find-other-window): Fix off-by-one errors for max x,y.

The relevant change to `windmove-frame-edges' is this:

 --- a/lisp/windmove.el
 +++ b/lisp/windmove.el
 @@ -324,11 +324,11 @@ windmove-frame-edges
    (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


But, as it is now,  I don't see the difference between

(defun windmove-frame-edges (window)
  "Return (X-MIN Y-MIN X-MAX Y-MAX) for the frame containing WINDOW.
If WINDOW is nil, return the edges for the selected frame.
\(X-MIN, Y-MIN) is the zero-based coordinate of the top-left corner
of the frame; (X-MAX, Y-MAX) is the zero-based coordinate of the
bottom-right corner of the frame.
For example, if a frame has 76 rows and 181 columns, the return value
from `windmove-frame-edges' will be the list (0 0 180 75)."
  (let* ((frame (if window
                    (window-frame window)
                  (selected-frame)))
         (top-left (window-edges (frame-first-window frame)))
         (x-min (nth 0 top-left))
         (y-min (nth 1 top-left))
         (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)))

and just defining it as

(defun windmove-frame-edges (window)
  "..."
  (window-edges (frame-root-window window)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]