Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

focus-out-hook is obsolete variable as of 27.1 #8

Open
choffee opened this issue Feb 21, 2022 · 1 comment
Open

focus-out-hook is obsolete variable as of 27.1 #8

choffee opened this issue Feb 21, 2022 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@choffee
Copy link

choffee commented Feb 21, 2022

Hi,

Just to note that the focus in and out hooks seem to be depreciated in 27.1. I think that the after-focus-change-function was only introduced in 27.1 so might need an if on version number to support that.

Note that it still seems to work on 28 but just throws a warning.

New frame focus state inspection interface.
The hooks 'focus-in-hook' and 'focus-out-hook' are now obsolete.
Instead, attach to 'after-focus-change-function' using 'add-function'
and inspect the focus state of each frame using 'frame-focus-state'.
https://www.masteringemacs.org/article/whats-new-in-emacs-27-1

@slotThe
Copy link
Member

slotThe commented Feb 21, 2022

Indeed, after-focus-change is supposed to be "more accurate" in terms of when it fires (apparently, focus-{in,out}-hook had some problems where it would trigger in situations where no obvious user-facing focus action had taken place). It is, however, much more manual to use; we'd have to check each individual frame for its focus state and then decide what to do based on that.

It's still not removed in Emacs 29 yet (last compiled approximately a week ago) and with Emacs generally having quite a long "grace period" for these kinds of things, I think the current solution will continue to "work" for quite a while. Still, if someone wanted to convert it to use the new interface I would certainly not object!

@slotThe slotThe added the help wanted Extra attention is needed label Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants