(progn (sleep-for 5) (x-focus-frame nil))

focuses the Emacs frame, but also makes it the "key window" (ie, when you type, the keypresses gets sent to this window, which may or may not be the frontmost window).

since "x-focus-frame is a built-in function in C source d", I don't know where to look for related functionality.

The motivation is that I want one of my Emacs frames to always be on top, so I can keep an eye on the terminal output, while still being able to type into whatever application I'm currently using (e.g. the browser).

Objective-C's orderFront would work, if this behavior were exposed (https://stackoverflow.com/questions/4859974/make-nswindow-front-but-not-in-focus)

also, if this is impossible, how hard you think it would be to expose this functionality for the next release? For portability, I think (some?) Linux have the same concept ("key window" versus "frontmost window"); I don't know about MS Windows.

  • 1
    I might suggest an applescript, but I don't know what a "key window" is so I can't help any further, sorry. I do use OSX 10.6.8, but have never encountered that terminology.
    – lawlist
    Commented Aug 23, 2015 at 16:57
  • 1
    I'm also not 100% clear on what you're trying to do, but it sounds like something that would be handled at the OS level rather than by Emacs itself.
    – Dan
    Commented Aug 23, 2015 at 17:09
  • edited, but as I said, I want to be able to type into a different application, while Emacs is still on top in the corner Commented Aug 23, 2015 at 18:16
  • What do you mean by OS level? I was googling around about how to get access to window objects in whatever framework, but it doesn't seem very clear. Commented Aug 23, 2015 at 18:19
  • 1
    A note on terminology: I think the correct term for “key window” is “window with keyboard focus”. OS X does not really like to have that window not being the top one, but an exception is known as floating windows, which appear in front of all non-floating windows even if they do not have keyboard focus. You see them in the UI of various applications, notably in the bundled “Stickies” app. Commented Aug 24, 2015 at 12:50


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.