diff options
author | Alan Pearce | 2017-02-06 08:50:15 +0100 |
---|---|---|
committer | Alan Pearce | 2017-02-06 08:50:15 +0100 |
commit | 57d40296cdb4ad759b857b0ea4c396d2ade94b80 (patch) | |
tree | c2034f6764184543641d92295566f7b44e1c8482 | |
parent | a0219037c6eff35b09b0ec4352efff3606b5d140 (diff) | |
download | nixfiles-57d40296cdb4ad759b857b0ea4c396d2ade94b80.tar.lz nixfiles-57d40296cdb4ad759b857b0ea4c396d2ade94b80.tar.zst nixfiles-57d40296cdb4ad759b857b0ea4c396d2ade94b80.zip |
Emacs: Improve hide/show mode line functions
-rw-r--r-- | tag-emacs/emacs.d/init.org | 41 |
1 files changed, 25 insertions, 16 deletions
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 |