* lisp/frame.el (frame-maximization-style): New user option.
authorSam Steingold <sds@gnu.org>
Wed, 12 Dec 2012 14:43:45 +0000 (09:43 -0500)
committerSam Steingold <sds@gnu.org>
Wed, 12 Dec 2012 14:43:45 +0000 (09:43 -0500)
(toggle-frame-maximized): Toggle frame maximization according to
`frame-maximization-style', bound to <f11>.
(cycle-frame-maximized): Cycle between all maximization styles and
non-maximized frame, bound to shift-<f11>.

etc/NEWS
lisp/ChangeLog
lisp/frame.el

index 77e7e47..4199bd3 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -35,6 +35,9 @@ simply disabling Transient Mark mode does the same thing.
 
 * Editing Changes in Emacs 24.4
 
+** New commands `toggle-frame-maximized' and `cycle-frame-maximized',
+bound to <f11> and S-<f11>, respectively.
+
 \f
 * Changes in Specialized Modes and Packages in Emacs 24.4
 
index a5fab65..adf8d9f 100644 (file)
@@ -1,3 +1,11 @@
+2012-12-12  Sam Steingold  <sds@gnu.org>
+
+       * frame.el (frame-maximization-style): New user option.
+       (toggle-frame-maximized): Toggle frame maximization according to
+       `frame-maximization-style', bound to <f11>.
+       (cycle-frame-maximized): Cycle between all maximization styles and
+       non-maximized frame, bound to shift-<f11>.
+
 2012-12-12  David Cadé  <codename68@gmail.com>
 
        * mpc.el (mpc-format): Use truncate-string-to-width (bug#13143).
index 7a54efc..559aa35 100644 (file)
@@ -1654,12 +1654,42 @@ terminals, cursor blinking is controlled by the terminal."
                                'blink-cursor-start))))
 
 \f
+;; Frame maximization
+(defcustom frame-maximization-style 'maximized
+  "The maximization style of \\[toggle-frame-maximized]."
+  :version "24.4"
+  :type '(choice
+          (const :tab "Respect window manager screen decorations." maximized)
+          (const :tab "Ignore window manager screen decorations." fullscreen))
+  :group 'frames)
+
+(defun toggle-frame-maximized ()
+  "Maximize/un-maximize Emacs frame according to `frame-maximization-style'.
+See also `cycle-frame-maximized'."
+  (interactive)
+  (modify-frame-parameters
+   nil `((fullscreen . ,(if (frame-parameter nil 'fullscreen)
+                            nil frame-maximization-style)))))
+
+(defun cycle-frame-maximized ()
+  "Cycle Emacs frame between normal, maximized, and fullscreen.
+See also `toggle-frame-maximized'."
+  (interactive)
+  (modify-frame-parameters
+   nil `((fullscreen . ,(cl-case (frame-parameter nil 'fullscreen)
+                                 ((nil) 'maximized)
+                                 ((maximized) 'fullscreen)
+                                 ((fullscreen) nil))))))
+
+\f
 ;;;; Key bindings
 
 (define-key ctl-x-5-map "2" 'make-frame-command)
 (define-key ctl-x-5-map "1" 'delete-other-frames)
 (define-key ctl-x-5-map "0" 'delete-frame)
 (define-key ctl-x-5-map "o" 'other-frame)
+(define-key global-map [f11] 'toggle-frame-maximized)
+(define-key global-map [(shift f11)] 'cycle-frame-maximized)
 
 \f
 ;; Misc.