bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#47300: delete-window to select window with same position


From: martin rudalics
Subject: bug#47300: delete-window to select window with same position
Date: Tue, 25 May 2021 08:50:23 +0200

> I don't know why, but sometimes `window-at' returns 'nil'.

`window-at' is pretty useless anyway.  Try the below instead.

martin

(defun window-at-pos (x y &optional frame)
  "Return live window at position X, Y on specified FRAME.
X and Y are counted in pixels from the origin at 0, 0 of FRAME's
native frame.  FRAME must specify a live frame and defaults to
the selected one.  Return nil if no such window can be found."
  (setq frame (window-normalize-frame frame))
  (catch 'window
    (walk-window-tree
     (lambda (window)
       (let ((edges (window-edges window nil nil t)))
         (when (and (>= x (nth 0 edges)) (<= x (nth 2 edges))
                    (>= y (nth 1 edges)) (<= y (nth 3 edges)))
           (throw 'window window))))
     frame nil nil)))







reply via email to

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