4

Emacs has been starting up in an extremely small window for some reason. The text size is normal, but the window is something like 3 lines tall x 10 chars wide. Of course I can use my mouse and just resize the window, after which it works totally fine.

I'm using Fedora 38 with Emacs 28.2 installed from dnf (Fedora's package manager). Desktop environment is "Gnome (not classic) with X11". I have nearly zero customizations, except I've hidden the scroll bar, tool bar, and menu bar using the M-` menu. Both my default-frame-alist and initial-frame-alist just has a single vertical-scroll-bars = nil, though there's a second line that says "CHANGED outside Customize", but I think that refers to the M-` menu being not part of the "customize" feature?

Fedora comes with Gnome with Wayland by default, but I switched it to X11 using the "cog" menu in login, and I think but am not 100% that this issue only started happening to me after the switch (on Wayland, I think it was not happening). When I do ls ~ -a I don't see any .Xresources or .Xdefaults.

What's going on?

edit: I tried opening emacs multiple times in a row, and sometimes it opens in a normal-sized window. Maybe half the time. I also tried doing emacs -Q and emacs -q and the issue does not happen: I just get an ordinary-sized window.

for reference, here is my ~/.emacs file (comments omitted for brevity):

(custom-set-variables
 '(custom-enabled-themes '(wheatgrass))
 '(make-backup-files nil)
 '(menu-bar-mode nil)
 '(ring-bell-function 'ignore)
 '(scroll-bar-mode nil)
 '(tool-bar-mode nil))
(custom-set-faces
 '(default ((t (:family "Noto Sans Mono" :foundry "GOOG" :slant normal :weight normal :height 139 :width normal)))))
9
  • Maybe check site-lisp.el? Do you see the frame-size problem if you start Emacs using emacs -Q (no init file), and you then evaluate your customizations?
    – Drew
    Jun 18, 2023 at 14:03
  • I updated the question. I'm not sure where site-lisp.el is
    – xdavidliu
    Jun 19, 2023 at 8:20
  • emacs -Q starts Emacs without site-lisp.el or your init file. emacs -q starts Emacs without (only) your init file.
    – Drew
    Jun 19, 2023 at 14:33
  • 1
    Have you seen this? emacswiki.org/emacs/FrameSize
    – g-gundam
    Jun 21, 2023 at 3:10
  • 1
    I've reported this as an Emacs bug at debbugs.gnu.org/cgi/bugreport.cgi?bug=67654. I found that I could trigger it consistently from emacs -Q if menu-bar-mode is disabled. Maybe you could see if the reproduction steps work for you too? Dec 6, 2023 at 8:06

4 Answers 4

2

Add this line to your Emacs' configuration file (located at ~/.emacs.d/init.el), it should maximize any new frame open :

(add-to-list 'default-frame-alist '(fullscreen . maximized))

Or if you want any new frame to be a specific size, you can add this to your Emacs' configuration file :

(add-to-list 'default-frame-alist '(width . 80))  ; Width set to 80 characters
(add-to-list 'default-frame-alist '(height . 24)) ; Height set to 24 lines

Bonus : you can replace "width" by "pixel-witdh" and "height" by "pixel-height" in the two previous lines to give the width and height in pixels instead of number of characters and lines.

2
  • This does work for me, but can it be modified to make it nice sized rather than maximised? It seems the tiny-window behaviour goes away, so I can just Super-downarrow after its maximised and I get an okay outcome.
    – CPBL
    Apr 1 at 20:45
  • I have edited my answer to adapt to your comment. Apr 3 at 9:42
1

I faced similar problem with emacsclient. I have Gnome keyboard shortcuts to open certain buffers, and after some upgrade Emacs was opening in a tiny window. To workaround it I'm calling emacsclient with the following argument:

emacsclient -c --eval "(set-frame-size (selected-frame) 106 41)"

Thanks g-gundam for pointing: https://www.emacswiki.org/emacs/FrameSize

Hope it helps.

1

I'm facing similar problems and posted my experience on https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67654 but no progress on this, it's frustrating. the workaround that works for me is (add-to-list 'default-frame-alist '(fullscreen . maximized)) but I'm not happy with it since I don't want my window maximized, just regular sized. also, just like OP, this bug occurs roughly half the time; does everyone see these error messages when it does occur:

(emacs:5868): Gtk-CRITICAL **: 11:15:55.869: gtk_distribute_natural_allocation: assertion 'extra_space >= 0' failed

(repeated twice)?

1
  • Yes! Wow, I hadn't realized how random it is. I just launched 3 times from the command line. First two were well sized. The third was tiny and I got that error message 5 times.
    – CPBL
    Apr 1 at 19:59
1

Started happening to me recently as well (recent debian, wayland, gnome). Super annoying.

I added this to .emacs to fix it:

(add-hook 'after-make-frame-functions
          (lambda (frame)
            (run-with-timer 0.3 nil
                            (lambda (frame) (set-frame-size frame 80 100))
                            frame
                            )
            ))

This will also maximize the frame vertically, while keeping the width to 80.

2
  • This didn't make any difference in my init.el. I'm on Ubuntu 23.10.
    – CPBL
    Apr 1 at 20:42
  • Yeah I found that I needed to add a timer to perform this action a bit later. I updated the answer. Apr 7 at 4:25

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.