How to maximize Emacs on Windows at startup?

后端 未结 15 1256
天命终不由人
天命终不由人 2020-12-13 03:45

This is driving me crazy: I simply want Emacs to maximize to whatever screen resolution I have at startup. Ideally I like a cross-platform (Windows & Linux) solution tha

相关标签:
15条回答
  • 2020-12-13 04:24

    I found an answer a year-or-so back that explains you have to manipulate the registry to do things right:

    To start Emacs maximized put this line at the end of your ~/.emacs file:

    (w32-send-sys-command 61488)
    

    If you don't want the Emacs tool bar you can add the line (tool-bar-mode -1) [NOTE: value is 0 on original page] to your ~/.emacs file but Emacs won't fully maximize in this case - the real estate occupied by the tool bar is lost. You have to disable the tool bar in the registry to get it back:

    [HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs\Emacs.Toolbar]
    @="0"
    

    If you look in the EmacsWiki under W32SendSys command-codes you'll find that 61488 is maximize current frame

    0 讨论(0)
  • 2020-12-13 04:24

    Hey - nice function! Thanks for posting

    I think it may not be working for you because you have code that looks like the following somewhere else in your init file. The default-frame-alist is being applied after the frame is created. I removed the size and position elements and you function works great on bootup of emacs.

       (setq default-frame-alist
         (list
          (cons 'left                 350)
          (cons 'top                  0)
          (cons 'width                80)
          (cons 'height               45)
         ......
    
    0 讨论(0)
  • 2020-12-13 04:27

    Another way to resolve such problem is put delay between

    (menu-bar-mode -1)
    (tool-bar-mode -1)
    (tooltip-mode -1)
    (scroll-bar-mode 1)
    

    and set-frame-* functions. For example:

     (tool-bar-mode -1)
     (when window-system
      (run-at-time (format "%d sec" 1) nil '(lambda () (set-frame-position (selected-frame) 1 1)))
      (run-at-time (format "%d sec" 2) nil '(lambda () (set-frame-width (selected-frame) 150 t)))
      (run-at-time (format "%d sec" 3) nil '(lambda () (set-frame-height (selected-frame) 60 t)))
      )
    

    It is essential to put delay between set-frame-* functions also!

    0 讨论(0)
  • 2020-12-13 04:31

    every one. emacs 23.3.1,blow code is invalid. because (menu-bar-mode -1) can cause windows not full-screen too.

    (w32-send-sys-command #xf030)
    (add-hook 'window-setup-hook (lambda () (tool-bar-mode -1)))
    

    I search Eamcs wiki,find a useable method.

    http://www.emacswiki.org/emacs/FullScreen#toc3

    MS Windows

    If you’re using MS Windows, and want to use “real fullscreen”, i.e, getting rid of the top titlebar and all, see w32-fullscreen at the site for darkroom-mode

    Alternatively, a patch is available here that makes the fullscreen frame parameter really fullscreen on Windows.

    To get a maximized window you can use: (w32-send-sys-command #xf030)

    Attention! If you want that emacs starts maximized, you have to put this code into your .emacs file:

    (defun jbr-init ()
      "Called from term-setup-hook after the default
    terminal setup is
    done or directly from startup if term-setup-hook not
    used.  The value
    0xF030 is the command for maximizing a window."
      (interactive)
      (w32-send-sys-command #xf030)
      (ecb-redraw-layout)
      (calendar)
    )
    (setq term-setup-hook 'jbr-init)
    (setq window-setup-hook 'jbr-init)
    
    0 讨论(0)
  • 2020-12-13 04:32

    First, thanks for the tip on the bug with (tool-bar-mode -1); saved me a lot of trouble! I'd rather keep everything within the .emacs file (no registry mods for me), so if you turn on the toolbar before maximizing, and then turn it off again, you'll can maximize nicely:

    (defun maximize-current-frame () "Resizes the current frame to fill the screen"
        (interactive)
        ;; There is a bug in tool-bar-mode that prevents it from being
        ;; maximized, so turn it on before maximizing.
        ;; See http://stackoverflow.com/questions/815239/how-to-maximize-emacs-on-windows-at-startup)
        (tool-bar-mode 1)
        (w32-send-sys-command 61488)
        (tool-bar-mode -1)
    )
    
    0 讨论(0)
  • 2020-12-13 04:36

    I encountered one command that seems to work (toggle-frame-maximized), which works on both Linux & Windows.

    I just put that near the end of my init file after setting up everything, making the assumption that by the end of the setup everything won't be maximized, and voila, it works.

    0 讨论(0)
提交回复
热议问题