5

I have this notification system in emacs that opens a new buffer with a reminder and relevant info at specified times. However, if I am using my browser I can't see it.

Therefore I am wondering whether it is possible to open a new emacs frame that steals the focus from other apps?

2
  • Is it possible to steal the focus from other apps in general, without creating a new frame? If there was a variable for the current frame, (select-frame-set-input-focus current-frame-variable) could be used. This would be super neat for this package I'm thinking of creating. Commented Feb 28, 2015 at 8:16
  • 1
    There is: (select-frame-set-input-focus (selected-frame)) I love you emacs!!!! Commented Feb 28, 2015 at 8:20

2 Answers 2

1

This should work:

(run-with-timer
 3 nil
 (lambda ()
   (select-frame-set-input-focus (new-frame)))) 
0
1

What @abo-abo says is almost enough to do what you want (since you explicitly ask not only that the frame be shown on top but also that it be focused).

What it leaves out is that raising a frame does not necessarily focus it (select it for input focus). The behavior can depend on your window manager.

On MS Windows, you can set or bind variable w32-grab-focus-on-raise to cause raising to always also focus.

And you can add a call to select-frame-set-input-focus to your code. That explicitly focuses the frame.

3
  • The last line did the trick. UV. Commented Feb 28, 2015 at 8:10
  • I accepted abo-abos answer since he was first, but your help and comments were much appreciated. Is this yours: emacswiki.org/emacs/frame-fns.el ? I leafed through it and it improved my understanding of how frames work greatly. Thanks. Commented Feb 28, 2015 at 8:22
  • You did the right thing - my post was meant to complement @abo-abo's. And yes, hope it helps.
    – Drew
    Commented Feb 28, 2015 at 16:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.