powerline does not detect the "active" modeline correctly
The modeline colors are not changed correctly when I switch windows, at least for me and my colleagues. The predicate powerline-selected-window-active always returns the same value for active and inactive window. Only the parts that have the face property 'nil switch color. I solved this issue in my config long time ago but forgot to share, here is my (brute force) solution:
(add-hook 'post-command-hook (lambda ()
(when (not (minibuffer-selected-window))
(setq powerline-selected-window (selected-window)))))
my modeline-format is looks like this:
'("%e"
(:eval
(let* ((active (eq powerline-selected-window (selected-window)))
This way, active actually holds the correct value.
what system?
On Wed, Jun 5, 2013 at 2:16 PM, Alessandro Piras [email protected]:
The modeline colors are not changed correctly when I switch windows, at least for me and my colleagues. The predicate powerline-selected-window-active always returns the same value for active and inactive window. Only the parts that have the face property 'nil switch color. I solved this issue in my config long time ago but forgot to share, here is my (brute force) solution:
(add-hook 'post-command-hook (lambda () (setq powerline-selected-window (selected-window))))
my modeline-format is looks like this:
'("%e" (:eval (let* ((active (eq powerline-selected-window (selected-window)))
This way, active actually holds the correct value.
— Reply to this email directly or view it on GitHubhttps://github.com/milkypostman/powerline/issues/37 .
Arch linux 64, emacs compiled from source from AUR, bzr version info:
revision-id: [email protected]
date: 2013-06-01 20:35:14 +0800
build-date: 2013-06-08 11:13:25 +0200
revno: 112809
branch-nick: trunk
ok, installing bzr version now to test.
I had a same problem with emacs compiled from sources. The described fix worked for me. Thanks.
The suggested fix worked for me as well. Thanks!
This bug is still present, the culprit is indeed powerline-selected-window-active which seems very broken.
(defun powerline-selected-window-active ()
"Return whether the current window is active."
(or (eq (frame-selected-window)
(selected-window))
(and (minibuffer-window-active-p
(frame-selected-window))
(eq (pl/minibuffer-selected-window)
(selected-window)))))
The first part of the or is always t and the second part is always nil.
Besides, I don't understand how each window could be checked when they're not given as parameter.
@milkypostman could you please explain your intent with this function?
Also, for anyone unaware, the suggested fix runs its lambda every time you press a key/command. It is far from ideal.
When I wrote the function emacs would select each window as it updated each mode line. So (selected-window) would be the window whose mode line was being updated and (frame-selected-window) would be three truly selected window.
What version of emacs is this? Likely something has changed but I don't think the proposed solution is the correct one. Because post-command-hook seems too often.
Or frame selected window is misbehaving. I will install on 24.3 and see if I can reproduce. I'm also curious if there is another extension causing this problem. On Feb 11, 2014 6:36 AM, "Baboon" [email protected] wrote:
This bug is still present, the culprit is indeed powerline-selected-window-active which seems very broken.
(defun powerline-selected-window-active () "Return whether the current window is active." (or (eq (frame-selected-window) (selected-window)) (and (minibuffer-window-active-p (frame-selected-window)) (eq (pl/minibuffer-selected-window) (selected-window)))))
The first part of the or is always t and the second part is always nil. Besides, I don't understand how each window could be checked when they're not given as parameters.
@milkypostman https://github.com/milkypostman could you please explain your intent with this function?
— Reply to this email directly or view it on GitHubhttps://github.com/milkypostman/powerline/issues/37#issuecomment-34759602 .
That's the kind of voodoo I was fearing, my emacs version is:
GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.6) of 2014-01-02 on alphard, modified by Debian
I got it from ppa:cassou/emacs
This fix should be lighter:
(defun baboon-set-powerline-selected-window ()
"sets the variable `powerline-selected-window` appropriately"
(when (not (minibuffer-window-active-p (frame-selected-window)))
(setq powerline-selected-window (frame-selected-window))))
(add-hook 'window-configuration-change-hook 'baboon-set-powerline-selected-window)
(add-hook 'focus-in-hook 'baboon-set-powerline-selected-window)
(add-hook 'focus-out-hook 'baboon-set-powerline-selected-window)
(defadvice select-window (after baboon-select-window activate)
"makes powerline aware of window changes"
(baboon-set-powerline-selected-window))
And in the modeline:
'("%e"
(:eval
(let* ((active (eq powerline-selected-window (selected-window)))
;; ...
I've had good results with it today, even across frames
@milkypostman if you find no better way, I can make a it a pull request
Cool, will take a look. I am talking to jonathanchu about his port and seeing if maybe we will deprecate my version and move to his.
On Tue Feb 11 2014 at 8:39:32 AM, Baboon [email protected] wrote:
This fix should be lighter:
(defun baboon-set-powerline-selected-window ()
"sets the variable powerline-selected-window"
(when (not (minibuffer-window-active-p (frame-selected-window)))
(setq powerline-selected-window (frame-selected-window))))
(add-hook 'window-configuration-change-hook
'baboon-set-powerline-selected-window)(add-hook 'focus-in-hook
'baboon-set-powerline-selected-window)(add-hook 'focus-out-hook
'baboon-set-powerline-selected-window)
(defadvice select-window (after baboon-select-window activate)
"makes powerline aware of window changes"
(baboon-set-powerline-selected-window))
And in the modeline:
'("%e" (:eval (let* ((active (eq powerline-selected-window (selected-window)))
;; ...
I've had good results with it today, even across frames
— Reply to this email directly or view it on GitHubhttps://github.com/milkypostman/powerline/issues/37#issuecomment-34772940 .
I confirm the problem on emacs-snapshot. Works well in emacs 24.3.
Sounds to me like this should be a bug we file w/ gnu emacs instead of here? I mean, it's a regression in how the active window is being processed.
On Mon, Feb 24, 2014 at 12:57 AM, Damien Cassou [email protected]:
I confirm the problem on emacs-snapshot. Works well in emacs 24.3.
— Reply to this email directly or view it on GitHubhttps://github.com/milkypostman/powerline/issues/37#issuecomment-35867593 .
Sounds to me like this should be a bug we file w/ gnu emacs instead of here?
done: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16874
Can you link to the bug here? On Feb 25, 2014 1:07 AM, "Damien Cassou" [email protected] wrote:
Sounds to me like this should be a bug we file w/ gnu emacs instead of here?
done
— Reply to this email directly or view it on GitHubhttps://github.com/milkypostman/powerline/issues/37#issuecomment-35987968 .
I don't understand. The 2 issues are cross-linked.
Hrm, Github email didn't show the link! On Feb 25, 2014 7:05 AM, "Damien Cassou" [email protected] wrote:
I don't understand. The 2 issues are cross-linked.
— Reply to this email directly or view it on GitHubhttps://github.com/milkypostman/powerline/issues/37#issuecomment-36016370 .
@milkypostman Could you please answer the questions on the emacs mailing list?
does anyone want to volunteer to add in @LouisKottmann 's in a patch?
@milkypostman I'll make a pull request today
I managed to workaround this issue with https://github.com/yewton/.emacs.d/commit/574d30a7367b35466190250a2c0dccd5fdfd1147 .
It seems to work reasonably in Emacs 27.1 on macOS Mojave built with https://github.com/d12frosted/homebrew-emacs-plus .