From 37f38bca1dbcce25b4f41928a249ecf937d795ff Mon Sep 17 00:00:00 2001 From: Sam Steingold Date: Wed, 12 Dec 2012 09:43:45 -0500 Subject: [PATCH] * lisp/frame.el (frame-maximization-style): New user option. (toggle-frame-maximized): Toggle frame maximization according to `frame-maximization-style', bound to . (cycle-frame-maximized): Cycle between all maximization styles and non-maximized frame, bound to shift-. --- etc/NEWS | 3 +++ lisp/ChangeLog | 8 ++++++++ lisp/frame.el | 30 ++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 77e7e47b8a3..4199bd302a9 100644 --- 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 and S-, respectively. + * Changes in Specialized Modes and Packages in Emacs 24.4 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a5fab65b34f..adf8d9f88f0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2012-12-12 Sam Steingold + + * frame.el (frame-maximization-style): New user option. + (toggle-frame-maximized): Toggle frame maximization according to + `frame-maximization-style', bound to . + (cycle-frame-maximized): Cycle between all maximization styles and + non-maximized frame, bound to shift-. + 2012-12-12 David Cadé * mpc.el (mpc-format): Use truncate-string-to-width (bug#13143). diff --git a/lisp/frame.el b/lisp/frame.el index 7a54efc23e7..559aa35242d 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1653,6 +1653,34 @@ terminals, cursor blinking is controlled by the terminal." blink-cursor-delay 'blink-cursor-start)))) + +;; 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)))))) + ;;;; Key bindings @@ -1660,6 +1688,8 @@ terminals, cursor blinking is controlled by the terminal." (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) ;; Misc. -- 2.39.5