GNU bug report logs - #47300
delete-window to select window with same position

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 21 Mar 2021 21:15:02 UTC

Severity: minor

Tags: fixed, patch

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: martin rudalics <rudalics <at> gmx.at>
To: Juri Linkov <juri <at> linkov.net>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 47300 <at> debbugs.gnu.org
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)))






This bug report was last modified 4 years and 37 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.