RealityMonster
RealityMonster

Reputation: 1881

How can I write a hook to activate when any emacs frame is raised/focused?

Under Win32, each emacs frame shows up as a different window when Alt-tabbing, which makes sense. However, when I select my main editing window, I'd also like my speedbar frame to auto-raise along with it.

Writing a function to raise all frames (or even all currently NOT visible frames) is relatively trivial, but I can't figure out hook to use, or indeed if there's even a hook that's possible to use at all.

So, if I click or alt-tab to any of my emacs frames, a hook should be run to call my function that raises ALL frames. Any help?

Upvotes: 2

Views: 852

Answers (3)

zw963
zw963

Reputation: 1249

I found a hook you can use with.

server-visit-hook is a variable defined in `server.el'.
Original value was nil

Documentation:
Hook run when visiting a file for the Emacs server.

You can customize this variable.

When you find a file with Emacs server or emacsclient, this hook will invoked. you can use this hook to do something need.

Upvotes: 0

The closest I can find in GNU Emacs is the switch-frame event, but it's only generated when a different Emacs frame is focused, not when you switch to a non-Emacs window and then back to the same frame.

This is the sort of things that a good enough window manager should do, with a bit of cooperation from Emacs (for example using window titles to figure out what the speedbar frame is).

Under Windows, you should be able to use AutoHotKey's WinWaitActive command.

Upvotes: 1

Burton Samograd
Burton Samograd

Reputation: 3638

It doesn't seem that GNU emacs has any such functionality.

Xemacs has select-frame-hook and map-frame-hook. There is also the variable auto-raise-frame, but, not in GNU emacs.

See http://www.xemacs.org/Documentation/beta/html/lispref_40.html#SEC526 for some ideas if you feel like improving emacs.

Upvotes: 1

Related Questions