summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--init.org67
-rw-r--r--lib/eos/jao-mode-line.el (renamed from lib/eos/jao-minibuffer-mode-line.el)89
2 files changed, 85 insertions, 71 deletions
diff --git a/init.org b/init.org
index acf6601..c310be0 100644
--- a/init.org
+++ b/init.org
@@ -693,7 +693,7 @@
#+end_src
*** Minibuffer
#+begin_src emacs-lisp
- (defvar jao-modeline-in-minibuffer-p (and window-system t))
+ (defvar jao-modeline-in-minibuffer (and window-system t))
(use-package jao-minibuffer
:init
@@ -706,9 +706,9 @@
jao-minibuffer-refresh
jao-minibuffer-mode))
- (use-package jao-minibuffer-mode-line
- :commands (jao-minibuffer-add-mode-line
- jao-minibuffer-remove-mode-line))
+ (use-package jao-mode-line
+ :commands (jao-mode-line-add-to-minibuffer
+ jao-mode-line-remove-from-minibuffer))
(setq enable-recursive-minibuffers t)
(require 'mb-depth)
@@ -719,10 +719,10 @@
(jao-minibuffer-mode 1)
- (when jao-modeline-in-minibuffer-p
+ (when jao-modeline-in-minibuffer
(add-hook 'display-time-hook #'jao-minibuffer-refresh)
(add-hook 'after-init-hook
- (lambda () (jao-minibuffer-add-mode-line 90))))
+ (lambda () (jao-mode-line-add-to-minibuffer 90))))
#+end_src
*** Mode line format
#+begin_src emacs-lisp
@@ -736,41 +736,14 @@
#+end_src
*** Mode line toggle
#+begin_src emacs-lisp
- (defun jao-toggle--face-height (face &optional all)
- (let* ((h (face-attribute face :height (window-frame)))
- (nh (if (eq 'unspecified h) 1 'unspecified)))
- (set-face-attribute face (when (not all) (window-frame)) :height nh)))
-
- (defun jao-toggle-mode-line (&optional all)
- (interactive "P")
- (jao-toggle--face-height 'mode-line all))
-
- (defun jao-toggle-inactive-mode-line (&optional all)
- (interactive "P")
- (jao-toggle--face-height 'mode-line-inactive all))
-
- (defun jao-echo-mode-line ()
- (interactive)
- (message "%s" (format-mode-line mode-line-format)))
-
- (defun jao--set-inactive-face (x frame)
- (unless (eq x (face-attribute 'mode-line-inactive :height frame))
- (set-face-attribute 'mode-line-inactive frame :height x)))
-
- (defun jao--hide-inactive-mode-line (frame)
- (jao--set-inactive-face 1 frame))
-
- (defun jao--show-inactive-mode-line (frame)
- (jao--set-inactive-face 'unspecified frame))
-
- (when (and window-system (not jao-modeline-in-minibuffer-p))
- (add-hook 'after-init-hook #'jao-toggle-inactive-mode-line)
- (add-to-list 'after-make-frame-functions #'jao--hide-inactive-mode-line))
-
- (global-set-key (kbd "<home>") #'jao-toggle-inactive-mode-line)
- (global-set-key (kbd "<end>") #'jao-toggle-mode-line)
- (global-set-key (kbd "<insert>") #'jao-echo-mode-line)
-
+ (use-package jao-mode-line
+ :init
+ (when (and window-system (not jao-modeline-in-minibuffer))
+ (add-to-list 'after-make-frame-functions #'jao-mode-line-hide-inactive)
+ (add-hook 'after-init-hook #'jao-toggle-inactive-mode-line))
+ :bind (("<home>" . jao-mode-line-toggle-inactive)
+ ("<end>" . jao-mode-line-toggle)
+ ("<insert>" . jao-mode-line-echo)))
#+end_src
*** Diminish
#+BEGIN_SRC emacs-lisp
@@ -790,7 +763,7 @@
battery-mode-line-format " %b%p ")) ;; " ๐Ÿ”‹%b%p "
(display-battery-mode 1)
(with-eval-after-load "jao-minibuffer"
- (unless jao-modeline-in-minibuffer-p
+ (unless jao-modeline-in-minibuffer
(jao-minibuffer-add-variable 'battery-mode-line-string 80)))
#+end_src
* Notifications
@@ -1283,10 +1256,10 @@
(defun jao-afio--set-mode-line ()
(if (string= "Docs" (jao-afio-current-frame))
- (jao--show-inactive-mode-line nil)
- (jao--hide-inactive-mode-line nil)))
+ (jao-mode-line-show-inactive nil)
+ (jao-mode-line-hide-inactive nil)))
- (unless jao-modeline-in-minibuffer-p
+ (unless jao-modeline-in-minibuffer
(add-hook 'jao-afio-switch-hook #'jao-afio--set-mode-line))
#+end_src
* Writing and writing modes
@@ -2981,7 +2954,7 @@
(defalias 'jao-streaming-volume-down #'jao-mpris-vol-down)
(jao-mpris-register "playerctld"
- :session (if jao-modeline-in-minibuffer-p -10 70))
+ :session (if jao-modeline-in-minibuffer -10 70))
#+end_src
*** mpc
@@ -2992,7 +2965,7 @@
;; (defvar jao-mopidy-port 6669)
(defvar jao-mopidy-port nil)
- (jao-mpc-setup jao-mopidy-port (if jao-modeline-in-minibuffer-p -10 70))
+ (jao-mpc-setup jao-mopidy-port (if jao-modeline-in-minibuffer -10 70))
(defun jao-mpc-pport ()
(when (jao-mpc--playing-p jao-mopidy-port) jao-mopidy-port))
diff --git a/lib/eos/jao-minibuffer-mode-line.el b/lib/eos/jao-mode-line.el
index 6f69630..566fdf1 100644
--- a/lib/eos/jao-minibuffer-mode-line.el
+++ b/lib/eos/jao-mode-line.el
@@ -1,4 +1,4 @@
-;;; jao-minibuffer-mode-line.el --- mode-line info in the minibuffer -*- lexical-binding: t; -*-
+;;; jao-mode-line.el --- mode-line info -*- lexical-binding: t; -*-
;; Copyright (C) 2022 jao
@@ -20,20 +20,58 @@
;;; Commentary:
-;; Using jao-minibuffer to display mode-line info in the minibuffer.
+;; Using jao-minibuffer to display mode-line info in the minibuffer,
+;; or toggle it off in non-active windows.
;;; Code:
(require 'jao-minibuffer)
+
+;;;; mode line toggle
+(defun jao-mode-line--face-height (face &optional all)
+ (let* ((h (face-attribute face :height (window-frame)))
+ (nh (if (eq 'unspecified h) 1 'unspecified)))
+ (set-face-attribute face (when (not all) (window-frame)) :height nh)))
+
+(defun jao-mode-line--set-inactive-face (x frame)
+ (unless (eq x (face-attribute 'mode-line-inactive :height frame))
+ (set-face-attribute 'mode-line-inactive frame :height x)))
+
+;;;###autoload
+(defun jao-mode-line-toggle (&optional all)
+ (interactive "P")
+ (jao-mode-line--face-height 'mode-line all))
+
+;;;###autoload
+(defun jao-mode-line-toggle-inactive (&optional all)
+ (interactive "P")
+ (jao-mode-line--face-height 'mode-line-inactive all))
+
+;;;###autoload
+(defun jao-mode-line-echo ()
+ (interactive)
+ (message "%s" (format-mode-line mode-line-format)))
+
+;;;###autoload
+(defun jao-mode-line-hide-inactive (frame)
+ (jao-mode-line--set-inactive-face 1 frame))
+
+;;;###autoload
+(defun jao-mode-line-show-inactive (frame)
+ (jao-mode-line--set-inactive-face 'unspecified frame))
+
+
+;;;; mode line format
+
(defvar exwm-class-name nil)
-(defvar jao-minibuffer--mode-line-position
+(defvar jao-mode-line--position
'(exwm-class-name
("")
("%n %2c %l " (:eval (format "%d" (line-number-at-pos (point-max)))))))
-(defvar jao-minibuffer--mode-line-bid
+(defvar jao-mode-line--bid
'(:eval (cond ((derived-mode-p 'gnus-group-mode
'gnus-article-mode
'gnus-summary-mode)
@@ -43,7 +81,7 @@
(t "%b"))))
(defvar jao-minibuffer--mode-line-format
- `("%[" (:propertize ,jao-minibuffer--mode-line-bid face jao-themes-f00) "%]"
+ `("%[" (:propertize ,jao-mode-line--bid face jao-themes-f00) "%]"
(:propertize " (" face jao-themes-dimm)
(:propertize mode-name face jao-themes-f00)
(:propertize ("" minor-mode-alist) face jao-themes-f11)
@@ -56,11 +94,14 @@
face jao-themes-warning)
(:propertize "ยท" display "")))
-(defvar jao-minibuffer--original-modeline nil)
-(defvar jao-minibuffer--original-line-face nil)
-(defvar jao-minibuffer--original-line-inactive-face nil)
+
+;;;; mode line in minibuffer
+
+(defvar jao-mode-line--original-modeline nil)
+(defvar jao-mode-line--original-line-face nil)
+(defvar jao-mode-line--original-line-inactive-face nil)
-(defun jao-minibuffer-mode-line-adjust-faces ()
+(defun jao-mode-line-adjust-faces ()
(let ((bg (frame-parameter nil 'background-color)))
(set-face-attribute 'mode-line nil :box nil :height 1
:background bg :foreground bg
@@ -74,33 +115,33 @@
:extend t)))
;;;###autoload
-(defun jao-minibuffer-add-mode-line (&optional order)
+(defun jao-mode-line-add-to-minibuffer (&optional order)
(interactive)
- (setq jao-minibuffer--original-line-face
+ (setq jao-mode-line--original-line-face
(get 'mode-line 'saved-face))
- (setq jao-minibuffer--original-line-inactive-face
+ (setq jao-mode-line--original-line-inactive-face
(get 'mode-line-inactive 'saved-face))
- (setq jao-minibuffer--original-modeline mode-line-format)
+ (setq jao-mode-line--original-modeline mode-line-format)
(setq-default mode-line-format '(" "))
- (setq-default mode-line-position jao-minibuffer--mode-line-position)
+ (setq-default mode-line-position jao-mode-line--position)
(dolist (b (buffer-list))
(with-current-buffer b (setq-local mode-line-format '(" "))))
- (jao-minibuffer-add-variable 'jao-minibuffer--mode-line-format (or order 90))
- (jao-minibuffer-mode-line-adjust-faces))
+ (jao-minibuffer-add-variable 'jao-mode-line--mode-line-format (or order 90))
+ (jao-mode-line-adjust-faces))
;;;###autoload
-(defun jao-minibuffer-remove-mode-line ()
+(defun jao-mode-line-remove-from-minibuffer ()
(interactive)
- (face-spec-set 'mode-line jao-minibuffer--original-line-face)
- (face-spec-set 'mode-line-inactive jao-minibuffer--original-line-inactive-face)
- (setq-default mode-line-format jao-minibuffer--original-modeline)
+ (face-spec-set 'mode-line jao-mode-line--original-line-face)
+ (face-spec-set 'mode-line-inactive jao-mode-line--original-line-inactive-face)
+ (setq-default mode-line-format jao-mode-line--original-modeline)
(dolist (b (buffer-list))
(with-current-buffer b (setq-local mode-line-format
- jao-minibuffer--original-modeline)))
+ jao-mode-line--original-modeline)))
(setq jao-minibuffer-info
- (remove '(:eval jao-minibuffer--mode-line-format)
+ (remove '(:eval jao-mode-line--mode-line-format)
jao-minibuffer-info)))
-(provide 'jao-minibuffer-mode-line)
-;;; jao-minibuffer-mode-line.el ends here
+(provide 'jao-mode-line)
+;;; jao-mode-line.el ends here