GNU bug report logs - #14604
24.3.50.1; Possibly incorrect behaviour of frame-selected-window

Previous Next

Package: emacs;

Reported by: E Sabof <esabof <at> gmail.com>

Date: Thu, 13 Jun 2013 11:47:02 UTC

Severity: normal

Found in version 24.3.50.1

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 14604 <at> debbugs.gnu.org (full text, mbox):

From: E Sabof <esabof <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 14604 <at> debbugs.gnu.org
Subject: Re: bug#14604: 24.3.50.1;
 Possibly incorrect behaviour of frame-selected-window
Date: Thu, 13 Jun 2013 15:59:11 +0100
[Message part 1 (text/plain, inline)]
On Thu, Jun 13, 2013 at 3:35 PM, Stefan Monnier <monnier <at> iro.umontreal.ca>wrote:

> > This works on 24.3, but on trunk all windows will be shown as "selected".
> > (setq-default
> >  mode-line-format
> >  '(:eval (if (eq (frame-selected-window)
> >                  (selected-window))
> >              "selected"
> >              "not-selected")))
>
> Indeed this doesn't work any more.  This was one of the very few places
> where (eq (frame-selected-window) (selected-window)) was nil, and this
> "invariant" is presumed at various places in the C code, so it was
> a bug.
>
> BTW, this worked in Emacs<24.3 if you wanted to highlight every frame's
> selected-window, but not if you wanted to highlight "the one and only
> selected-window".  For single-frame settings, there's no difference,
> of course.
>
> There is no alternative, yet.  We should probably provide some ad-hoc
> primitives (call them maybe display-selected-window and
> display-frame-selected-window) which return something like "the window
> that was selected when we entered redisplay".
>
>
>         Stefan
>

FWIW, the below seems to be working, although it still feels like an
omission.

Evgeni

(defvar user-selected-window nil)
(defun register-user-location ()
  (setq user-selected-window (selected-window)))
(add-hook 'post-command-hook 'register-user-location)

(setq-default
  mode-line-format
  '(:eval (if (eq user-selected-window (selected-window))
              "selected"
              "not-selected")))
[Message part 2 (text/html, inline)]

This bug report was last modified 3 years and 100 days ago.

Previous Next


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