5

How to get a focus for a new Emacs frame when it has been raised from outside of Emacs (for example, from emacsclient or edit-server)? Currently, the new frame get input focus, but not display focus, i.e. you enter text, but it's somewhere behind other windows (in Windows OS terminology). There was a similar question and it's marked as answered, but with no solution, though.

Emacs 23.3.

Community
  • 1
  • 1
Anton Tarasenko
  • 8,099
  • 11
  • 66
  • 91

3 Answers3

4

The function raise-frame can bring a frame to the front.

Tom
  • 7,515
  • 7
  • 38
  • 54
  • 2
    This function gives the same result which I described. The frame gets the input focus, but does not become 'selected' by the Explorer. I guess, `raise-frame` is called already by default on a frame creation. – Anton Tarasenko Sep 26 '11 at 20:28
  • Ask the guys on [emacs devel](http://news.gmane.org/gmane.emacs.devel) if there is some other way to do it or it's a bug. – Tom Sep 27 '11 at 05:36
  • (raise-frame) just helped me on GNU/Linux. I don’t know whether it works on Windows, but it solved my own problem: I now start my emacsclient with `emacsclient -ce \"(raise-frame)\"`. Thanks! – Arne Babenhauserheide Apr 10 '15 at 18:23
1

What version of Emacs are you running? I used put in gnuserv-visit-hook:

(select-frame-set-input-focus (window-frame (selected-window)))

But with Emacs 23, it's the default controlled by server-raise-frame.

event_jr
  • 17,467
  • 4
  • 47
  • 62
  • Emacs 23.3 (it is the same even from a fresh start (OS, empty .emacs)). I tried your solution—the issue persists. `server-raise-frame` is `t`. – Anton Tarasenko Sep 27 '11 at 11:09
-1

See also function select-frame-set-input-focus:

"Select FRAME, raise it, and set input focus, if possible."

Drew
  • 29,895
  • 7
  • 74
  • 104