Tim Retout's www presence

Fri, 09 Jul 2010

Toggle fullscreen in Emacs

Today I improved the function I was using to toggle full screen in GNU Emacs.

(defun toggle-fullscreen (&optional f)
  (interactive)
  (let ((current-value (frame-parameter nil 'fullscreen)))
       (set-frame-parameter nil 'fullscreen
                            (if (equal 'fullboth current-value)
                                (if (boundp 'old-fullscreen) old-fullscreen nil)
                                (progn (setq old-fullscreen current-value)
                                       'fullboth)))))

(global-set-key [f11] 'toggle-fullscreen)

The previous function would always restore the frame to "normal" state, even if Emacs was previously maximized. This one makes it behave more like, say, Epiphany or Totem.

Apparently using GNOME Keyboard Shortcuts to set this to F11 globally would override custom behaviour from some programs. I've not found any examples of this, though. This would be easily extensible to disable the Emacs toolbar when fullscreen, for instance.

Posted: 09 Jul 2010 18:45 | Tags: | Comments (2)

Comments

Posted by Andreas Marschke at Sat Jul 10 02:20:10 2010
;;For added free breathing space in your emacs :)
(dolist (m '(menu-bar-mode tool-bar-mode scroll-bar-mode blink-cursor-mode))
  (if (boundp m)
  (funcall m -1)))

Posted by Screwtape at Sat Jul 10 05:04:58 2010
For one commonly-visible example: Firefox. When told to go full-screen by View -> Full Screen or by hitting F11, it hides the menu bar, status bar, and the toolbars are set to auto-hide. When forced to go full-screen by hitting the GNOME Toggle Full Screen shortcut key, it... just goes full screen, and none of the special handling occurs.

Granted, most GNOME apps do detect when they've been forced into full-screen mode, and automatically apply whatever adjustments they normally use, but not all of them... and if you've overridden the F11 keybinding, there might not be an easy way to make an app go full-screen properly.

Name:


E-mail:


URL:


Comment:


Anti-spam question: What is the colour of both (hydrated) copper sulphate and (anhydrous) cobalt chloride?

< July 2010 >
SuMoTuWeThFrSa
     1 2 3
4 5 6 7 8 910
11121314151617
18192021222324
25262728293031

Contact

Tim Retout tim@retout.co.uk
JabberID: tim@retout.co.uk

List of non-fail

Copyright © 2007, 2008, 2009 Tim Retout