It's common for me to press alt-f10 (in GNU/Linux) after Emacs start up for maximizing window (in the Emacs terminology, it's actually a frame). Most of the time I press thrice because I was too early to press first alt-f10 which makes some garbage appear around the minibuffer (Emacs display bug?)
How can I automate this one? (Maybe with Gnome settings or with elisp?)
I am using emacs24 (from bzr repo).
Note that it's not the regular fullscreen I want which you would get by pressing f11.
(defun fullscreen (&optional f) (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
might work. (Taken from here.)
;; Next code works with Emacs 21.4, 22.3, 23.1, 24.3. (when window-system (let ( (px (display-pixel-width)) (py (display-pixel-height)) (fx (frame-char-width)) (fy (frame-char-height)) tx ty ) ;; Next formulas discovered empiric on Windows host with default font. (setq tx (- (/ px fx) 7)) (setq ty (- (/ py fy) 4)) (setq initial-frame-alist '((top . 2) (left . 2))) (add-to-list 'initial-frame-alist (cons 'width tx)) (add-to-list 'initial-frame-alist (cons 'height ty)) ) )
This code preserv some place for task bar on the bottom under Windows/Gnome/KDE
But instead of asking try read: http://www.emacswiki.org/emacs/FullScreen
OSX:
The developer build of Emacs Trunk has a function called toggle-frame-maximized
, which is included within .../lisp/frame.el
. That function can be added to the after-init-hook
or emacs-startup-hook
, or simply included in the .emacs
file that gets loaded on startup. On OSX, it increases both width and height in one-fell-swoop.
Windows XP:
The following command can be used after a make-frame
command, or after Emacs generates the initial frame.
(w32-send-sys-command 61488)
OSX and Windows
Here is an example for setting the initial frame size and location -- I have it near the beginning of my .emacs
file:
(let ((frame (selected-frame)))
(cond
((eq system-type 'darwin)
(setq ns-auto-hide-menu-bar t)
(set-frame-position frame 0 0) ;; must come after `ns-auto-hide-menu-bar`
(cond
((and
(= 1920 (display-pixel-width))
(= 1080 (display-pixel-height)))
(set-frame-size frame 1895 1054 t))
((and
(= 1920 (display-pixel-width))
(= 1200 (display-pixel-height)))
(set-frame-size frame 1895 1174 t))
((and
(= 1280 (display-pixel-width))
(= 800 (display-pixel-height)))
(set-frame-size frame 1265 774 t))) )
((and
(eq system-type 'windows-nt)
(equal (w32-version) '(5 1 2600)))
;; (w32-send-sys-command #xf030)
(set-frame-position frame 0 0)
(cond
((and
(= 1920 (display-pixel-width))
(= 1003 (display-pixel-height)))
(set-frame-size frame 1898 924 t))
((and
(= 1920 (display-pixel-width))
(= 1123 (display-pixel-height)))
(set-frame-size frame 1876 1052 t))
((and
(= 1280 (display-pixel-width))
(= 723 (display-pixel-height)))
(set-frame-size frame 1250 670 t))))
((and
(eq system-type 'windows-nt)
(equal (w32-version) '(6 1 7601)))
(set-frame-position frame 0 0)
(cond
((and
(= 1920 (display-pixel-width))
(= 1080 (display-pixel-height)))
(set-frame-size frame 1890 1003 t))
(t
(message "Not yet contemplated.")))) ))
Here is an example of what I use to create new frames -- controling the exact size and location:
(defun lawlist-make-frame (&optional alist)
(let ((frame (make-frame alist)))
(set-frame-position frame 0 0)
(cond
((eq system-type 'darwin)
(cond
((and
(= 1920 (display-pixel-width))
(= 1080 (display-pixel-height)))
(set-frame-size frame 1895 1054 t))
((and
(= 1920 (display-pixel-width))
(= 1200 (display-pixel-height)))
(set-frame-size frame 1895 1174 t))
((and
(= 1280 (display-pixel-width))
(= 800 (display-pixel-height)))
(set-frame-size frame 1265 774 t))))
((and
(eq system-type 'windows-nt)
(equal (w32-version) '(5 1 2600)))
(select-frame frame)
(cond
((and
(= 1920 (display-pixel-width))
(= 1003 (display-pixel-height)))
(set-frame-size frame 1898 924 t))
((and
(= 1920 (display-pixel-width))
(= 1123 (display-pixel-height)))
(set-frame-size frame 1876 1052 t))
((and
(= 1280 (display-pixel-width))
(= 723 (display-pixel-height)))
(set-frame-size frame 1250 670 t))))
((and
(eq system-type 'windows-nt)
(equal (w32-version) '(6 1 7601)))
(select-frame frame)
(cond
((and
(= 1920 (display-pixel-width))
(= 1080 (display-pixel-height)))
(set-frame-size frame 1890 1003 t))
(t
(message "Not yet contemplated.")))) )))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With