unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* emacsclient always raise frame (possible regression)
@ 2013-07-25 18:29 Jon Dufresne
  2013-07-29  8:42 ` Michael Heerdegen
  2013-07-29 11:56 ` chad
  0 siblings, 2 replies; 6+ messages in thread
From: Jon Dufresne @ 2013-07-25 18:29 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 892 bytes --]

Hi,

I recently updated my system to Fedora 19. Fedora 19 packages Gnome 3.8 and
Emacs 24.2.1.

I run Emacs in daemon mode. When using tools such as mercurial or git from
the command line, an editor is invoked with the command "emacsclient -c
FILENAME". When this editor is invoked I want the newly created frame
immediately raised to the top of Gnome's window stack so I may interact
with it.

In previous Fedora/Emacs versions I achieved this with the following in my
init.el

(add-hook 'after-make-frame-functions
          (lambda (frame)
            (raise-frame frame)))

This no longer works. Now whenever mercurial invokes the editor the frame
remains at the bottom of the stack of windows.

First off, should this elisp do what I'm trying to do? Is this a regression
in Emacs or an issue with Gnome? If this is wrong, what is the correct way
to always raise new frames?

Thanks,
Jon

[-- Attachment #2: Type: text/html, Size: 1028 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacsclient always raise frame (possible regression)
  2013-07-25 18:29 emacsclient always raise frame (possible regression) Jon Dufresne
@ 2013-07-29  8:42 ` Michael Heerdegen
  2013-07-29 11:56 ` chad
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2013-07-29  8:42 UTC (permalink / raw)
  To: emacs-devel; +Cc: Jon Dufresne

Hi Jon,

> I recently updated my system to Fedora 19. Fedora 19 packages Gnome
> 3.8 and Emacs 24.2.1.
>
> I run Emacs in daemon mode. When using tools such as mercurial or git
> from the command line, an editor is invoked with the command
> "emacsclient -c FILENAME". When this editor is invoked I want the
> newly created frame immediately raised to the top of Gnome's window
> stack so I may interact with it.
>
> In previous Fedora/Emacs versions I achieved this with the following
> in my init.el
>
> (add-hook 'after-make-frame-functions
>           (lambda (frame)
>             (raise-frame frame)))
>
> This no longer works. Now whenever mercurial invokes the editor the
> frame remains at the bottom of the stack of windows.
>
> First off, should this elisp do what I'm trying to do?

Dunno.  AFAIK, it can happen that the newly created frame is not yet
displayed (i.e., created by X) when `after-make-frame-functions' are
called.

Try to use a delay, like this:

(add-hook 'after-make-frame-functions
	  (lambda (frame)
	    (run-with-idle-timer 1. nil 'raise-frame frame)))

> Is this a regression in Emacs or an issue with Gnome?  If this is
> wrong, what is the correct way to always raise new frames?

Note that `raise-frame' doesn't make the frame "current".  Maybe Gnome
raises the frame that has focus automatically?  Then you want
`select-frame-set-input-focus' instead of `raise-frame'.

If your problem is specific to emacsclient invocations, it is probably
better to configure `server-window' instead of
`after-make-frame-functions'.  This is what I do:

(setq server-window
      (lambda (buf)
	(let ((win (display-buffer-pop-up-frame buf ())))
	  (select-frame-set-input-focus (window-frame win)))))

Hope one of the above proposals helps.


Regards,

Michael.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacsclient always raise frame (possible regression)
  2013-07-25 18:29 emacsclient always raise frame (possible regression) Jon Dufresne
  2013-07-29  8:42 ` Michael Heerdegen
@ 2013-07-29 11:56 ` chad
  2013-07-29 15:20   ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: chad @ 2013-07-29 11:56 UTC (permalink / raw)
  To: Jon Dufresne; +Cc: emacs-devel

On 25 Jul 2013, at 13:29, Jon Dufresne <jon.dufresne@gmail.com> wrote:

> I run Emacs in daemon mode. When using tools such as mercurial or git from the command line, an editor is invoked with the command "emacsclient -c FILENAME". When this editor is invoked I want the newly created frame immediately raised to the top of Gnome's window stack so I may interact with it.
> 
> In previous Fedora/Emacs versions I achieved this with the following in my init.el
> 
> (add-hook 'after-make-frame-functions
>           (lambda (frame)
>             (raise-frame frame)))
> 
> This no longer works. Now whenever mercurial invokes the editor the frame remains at the bottom of the stack of windows.

I used to use:

 (setq server-visit-hook (append server-visit-hook '(raise-frame)))

I'm not in a position to test it right now, but you might give it a try.

Hope that helps,
~Chad




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacsclient always raise frame (possible regression)
  2013-07-29 11:56 ` chad
@ 2013-07-29 15:20   ` Stefan Monnier
  2013-07-29 15:44     ` chad
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2013-07-29 15:20 UTC (permalink / raw)
  To: chad; +Cc: Jon Dufresne, emacs-devel

>  (setq server-visit-hook (append server-visit-hook '(raise-frame)))

I strongly recommend you use `add-hook' to manipulate hooks.


        Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacsclient always raise frame (possible regression)
  2013-07-29 15:20   ` Stefan Monnier
@ 2013-07-29 15:44     ` chad
  2013-07-29 16:41       ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: chad @ 2013-07-29 15:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Jon Dufresne, emacs-devel


On 29 Jul 2013, at 10:20, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> (setq server-visit-hook (append server-visit-hook '(raise-frame)))
> 
> I strongly recommend you use `add-hook' to manipulate hooks.

Good point! That particular snippet might actually pre-date add-hook;
it's from somewhere around emacs 21, maybe 22. Sorry for not fixing
it up before sending it.

~Chad




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacsclient always raise frame (possible regression)
  2013-07-29 15:44     ` chad
@ 2013-07-29 16:41       ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2013-07-29 16:41 UTC (permalink / raw)
  To: chad; +Cc: Jon Dufresne, emacs-devel

>>> (setq server-visit-hook (append server-visit-hook '(raise-frame)))
>> I strongly recommend you use `add-hook' to manipulate hooks.
> Good point! That particular snippet might actually pre-date add-hook;

Of course, such things happen.

> it's from somewhere around emacs 21, maybe 22.

Note that add-hook was added long before Emacs-21.


        Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-07-29 16:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-25 18:29 emacsclient always raise frame (possible regression) Jon Dufresne
2013-07-29  8:42 ` Michael Heerdegen
2013-07-29 11:56 ` chad
2013-07-29 15:20   ` Stefan Monnier
2013-07-29 15:44     ` chad
2013-07-29 16:41       ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).