From 57d40296cdb4ad759b857b0ea4c396d2ade94b80 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 6 Feb 2017 08:50:15 +0100 Subject: Emacs: Improve hide/show mode line functions --- tag-emacs/emacs.d/init.org | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'tag-emacs') diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index cb47fe61..ad025d5d 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -141,26 +141,25 @@ Let’s try a basic theme. (use-package basic-theme :config (progn (load-theme 'basic t) + + (set-face-background 'mode-line "#a1b56c") + + (defvar mode-line-default-format mode-line-format) + (defcustom mode-line-default-hidden t + "Whether to hide the mode line by default") + (defun show-mode-line () (interactive) - (let ((faces-to-toggle '(mode-line mode-line-inactive))) - (mapcar (lambda (face) - (set-face-background face "#a1b56c") - (set-face-attribute face nil :height (face-attribute 'default :height))) - faces-to-toggle))) + (setq mode-line-format mode-line-default-format) + (when (called-interactively-p) + (setq-default mode-line-format mode-line-default-format) + (setq mode-line-default-hidden nil))) (defun hide-mode-line () (interactive) - (let ((faces-to-toggle '(mode-line mode-line-inactive))) - (mapcar (lambda (face) - (set-face-background face "#e8e8e8") - (set-face-attribute face nil :height 20)) - faces-to-toggle))) - (defun mode-line-visual-toggle () - (interactive) - (cond ((string= "#a1b56c" (face-attribute 'mode-line :background)) - (hide-mode-line)) - (t - (show-mode-line)))) + (setq mode-line-format nil) + (when (called-interactively-p) + (setq-default mode-line-format nil) + (setq mode-line-default-hidden t))) (setq-default cursor-type 'bar) (setq-default cursor-in-non-selected-windows nil) @@ -176,6 +175,16 @@ Let’s try a basic theme. (show-mode-line)) (hide-clutter) + (when mode-line-default-hidden + (call-interactively #'hide-mode-line)) + + (defun hide-mode-line-if-default-hidden () + (if mode-line-default-hidden + (hide-mode-line) + (show-mode-line))) + + (add-hook 'after-change-major-mode-hook #'hide-mode-line-if-default-hidden) + (add-hook 'minibuffer-setup-hook #'show-mode-line) (add-hook 'minibuffer-exit-hook #'hide-mode-line))) #+END_SRC -- cgit 1.4.1