(defvar my-mh-screen-saved nil "Set to non-nil when mh-e window configuration shown.") (defvar my-normal-screen nil "Normal window configuration.") (defvar my-mh-screen nil "mh-e window configuration.") (defun my-mh-rmail (&optional arg) "Toggle between mh-e and normal screen configurations. With non-nil or prefix argument, inc mailbox as well when going into mail." (interactive "P") ; user callable function, P=prefix arg (setq my-mh-screen-saved ; save state (cond ;; Bring up mh-e screen if arg or normal window configuration. ;; If arg or +inbox buffer doesn't exist, run mh-rmail. ((or arg (null my-mh-screen-saved)) (setq my-normal-screen (current-window-configuration)) (if (or arg (null (get-buffer "+inbox"))) (mh-rmail) (set-window-configuration my-mh-screen)) t) ; set my-mh-screen-saved to t ;; Otherwise, save mh-e screen and restore normal screen. (t (setq my-mh-screen (current-window-configuration)) (set-window-configuration my-normal-screen) nil)))) ; set my-mh-screen-saved to nil (global-set-key "\C-x\r" 'my-mh-rmail) ; call with C-x RET