'emacsclient' ignores the '--frame-parameters' parameter, forgets the previously selected buffer after upgrade to Gnome 44
Note: a simpler explanation of the bug is on https://www.reddit.com/r/gnome/comments/12w7k8r/emacsclient_doesnt_respect_the_frameparameters/. Here I'll be more thorough. Still, I'm simplifying a bit here, too, as my configuration uses a systemd service file, a desktop file and a shell script. I don't want to incur in the X-Y problem, but also I don't want to overcomplicate the bug report. Since the steps described below reproduce the bug for me, I'm omitting the files. If something doesn't work the same for you this may be the reason.
Aside from the details of my personal implementation of an integration between the Emacs client and Gnome, I think the general problem of making this thing work is of quite broad interest (basically it's a matter of having a fast Emacs in Gnome). This is not the only open bug report concerning this issue, there's also #881.
Affected version
- Gnome Shell 44.0 (Wayland session)
- Mutter 44.0
- Emacs 28.2 (the package in Fedora's repos)
- Fedora 38
Bug summary
I have a somewhat complicated configuration whose sole purpose is to make Gnome transparently use emacsclient
as the default text editor. By this I mean that
- Opening a text file in Nautilus opens it in an existing
emacsclient
frame, or it creates a new one if none exist, and gives it the focus. I've set the newly created frames to be 80x40 characters wide. (NB: a frame is a window in Emacs jargon). -
super-<N>
, where N is the place where I've pinned Emacs client in the dash, opens an existingemacsclient
frame on the previously selected buffer (i.e., file) or it creates a new one if none exist, and gives it the focus.
After upgrading to Gnome 44 all these ways of opening a frame make an 16x8 chars frame, except at the first invocation after closing the Emacs session (with Alt-x save-buffers-kill-emacs
), when they make a 80x40 frame as they ought to.
Moreover, if I closed a frame (with Ctrl-x Ctrl-c
; note that this is different from Alt-x save-buffers-kill-emacs
as C-x C-c
doesn't close the underlying Emacs server session) which was displaying some buffer (basically a file, in Emacs lingo), the frame that would open on typing super-<N>
used to display that previously selected buffer, until Gnome 43.
Steps to reproduce
Wrong size frame
-
Save your files if you use Emacs, then run
killall emacs
to ensure there's no Emacs session running. -
Run
emacsclient --create-frame --no-wait --alternate-editor= --frame-parameters="((height . 40) (width . 80))"
A 80x40 chars Emacs frame should open
-
Hit
Ctrl-x Ctrl-c
to close that frame -
Run
emacsclient --create-frame --no-wait --alternate-editor= --frame-parameters="((height . 40) (width . 80))"
again. This time the window is 16x8 chars wide.
Newly created frames always show the startup buffer instead of the previously selected one
-
Save your files if you use Emacs, then run
killall emacs
to ensure there's no Emacs session running. -
Run
emacsclient --create-frame --no-wait --alternate-editor= --frame-parameters="((height . 40) (width . 80))"
-
In Emacs, type
Ctrl-x Ctrl-f
and open some file. -
Hit
Ctrl-x Ctrl-c
to close the frame. -
Run
emacsclient --create-frame --no-wait --alternate-editor= --frame-parameters="((height . 40) (width . 80))"
again. The frame displays the startup buffer (for me it's the **scratch**
buffer but I think that may change based on the Emacs configuration) instead of the file that was previously selected. And the window is too small.