X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=emacs.d%2Fmy-mode-line.el;h=c303cfc4166178b6f0f6277009a593dc744e3cbb;hb=5990d9dc09fc4cd3745adb3113146eaee4e9c468;hp=639fe0e19119f30e8f4f8cc938adcdf8e5acd6a4;hpb=96b6a5757af85d659a53eb30f33929ba371fcae5;p=dotfiles.git diff --git a/emacs.d/my-mode-line.el b/emacs.d/my-mode-line.el index 639fe0e..c303cfc 100644 --- a/emacs.d/my-mode-line.el +++ b/emacs.d/my-mode-line.el @@ -30,34 +30,41 @@ ;; |>>> O <<<| ;; ----------------------------- +(defun my-below-winow-has-effect-window () + "Return true when its below has no active window or +its below window is minibuffer window. " + (let ((window (window-in-direction 'below nil nil 1))) + (and window + (not (window-minibuffer-p window))))) + (defun my-get-window-type () "According to the window layout, separate the windows as six types. Each type will have different mode line. This function return the defined window type." - (cond ((and (not (window-in-direction 'right nil t -1)) - (not (window-in-direction 'left nil t -1)) - (not (window-in-direction 'below nil t 1))) + (cond ((and (not (window-in-direction 'right nil nil -1)) + (not (window-in-direction 'left nil nil -1)) + (not (my-below-winow-has-effect-window))) 1) ((and (window-in-direction 'right nil t -1) - (not (window-in-direction 'left nil t -1)) - (not (window-in-direction 'below nil t 1))) + (not (window-in-direction 'left nil nil -1)) + (not (my-below-winow-has-effect-window))) 2) - ((and (not (window-in-direction 'right nil t -1)) - (window-in-direction 'left nil t -1) - (not (window-in-direction 'below nil t 1))) + ((and (not (window-in-direction 'right nil nil -1)) + (window-in-direction 'left nil nil -1) + (not (my-below-winow-has-effect-window))) 3) - ((and (window-in-direction 'right nil t -1) - (not (window-in-direction 'left nil t -1)) - (window-in-direction 'below nil t 1)) + ((and (window-in-direction 'right nil nil -1) + (not (window-in-direction 'left nil nil -1)) + (my-below-winow-has-effect-window)) 5) - ((and (not (window-in-direction 'right nil t -1)) - (window-in-direction 'left nil t -1) - (window-in-direction 'below nil t 1)) + ((and (not (window-in-direction 'right nil nil -1)) + (window-in-direction 'left nil nil -1) + (my-below-winow-has-effect-window)) 6) (t 4))) -(my-get-window-type) + (defun sd/powerline-center-theme_revised-2 () "Setup a mode-line with major and minor modes centered." (interactive) @@ -66,8 +73,6 @@ window type." (:eval (let* ((window-type (my-get-window-type)) (active (powerline-selected-window-active)) - ;; (active t) - ;; (my-face1 (if active 'sd/powerline-active1 'powerline-inactive1)) (my-face1 'sd/powerline-active1 ) ;; (my-face-buffer-modified (if (and (sd/buffer-is-eshel-or-scratch) (buffer-modified-p) (not buffer-read-only)) ;; 'sd/buffer-modified-active1 @@ -81,41 +86,41 @@ window type." (separator-right (intern (format "powerline-%s-%s" (powerline-current-separator) (cdr powerline-default-separator-dir)))) - (lhs (if (or (= window-type 1) (= window-type 2) (= window-type 3) (= window-type 6)) - (let ((lface)) - (if (or (= window-type 1) (= window-type 2)) - (setq lface my-face1) - (if active - (setq lface my-face1) - (setq lface face2))) - (list (powerline-raw "%* " lface 'l) - ;; (powerline-raw "%* " my-face-buffer-modified 'l) - (powerline-raw " " lface) - (funcall separator-left lface face1) - (powerline-narrow face1 'l) - ;; (sd/powerline-simpler-vc (powerline-vc face1)) - )) - nil)) + (lface (if (and (not active) + (or (= window-type 3) (= window-type 6))) + face2 + my-face1)) + (cface (if active my-face1 face2)) + (rface (if (and (not active) + (or (= window-type 2) (= window-type 5))) + face2 + my-face1)) + (lhs (cond ((or (= window-type 1) (= window-type 2)) + (list (powerline-raw " = ws1 = " lface) + (funcall separator-left lface face1 ))) + ((or (= window-type 3) (= window-type 6)) + (list (powerline-buffer-id lface 'l) + (powerline-raw "%* " lface) + (funcall separator-left lface face1 ))) + (t + nil))) (center (if (or (= window-type 1) (= window-type 4)) - (let ((cface)) - (if active - (setq cface my-face1) - (setq cface face2)) - (list (powerline-raw " " face1) - (funcall separator-right face1 cface) - (powerline-raw (concat " ==" (number-to-string (my-get-window-type)) "== ") cface) - (funcall separator-left cface face1))) + (list (powerline-raw " " face1) + (funcall separator-right face1 cface) + (powerline-raw "%*" cface) + (powerline-buffer-id cface 'r) + (funcall separator-left cface face1)) nil)) - (rhs (if (or (= window-type 1) (= window-type 3) (= window-type 2) (= window-type 5)) - (let ((rface)) - (if (or (= window-type 1) (= window-type 3)) - (setq rface my-face1) - (if active - (setq rface my-face1) - (setq rface face2))) - (list (funcall separator-right face1 rface) - (powerline-raw (format-time-string " %I:%M %p ") rface 'r))) - nil))) + (rhs (cond ((or (= window-type 1) (= window-type 3)) + (list (funcall separator-right face1 rface) + (powerline-raw (format-time-string " %I:%M %p ") rface 'r))) + ((or (= window-type 2) (= window-type 5)) + (list (funcall separator-right face1 rface) + (powerline-raw "%*" rface) + (powerline-buffer-id rface 'r) + (powerline-raw " " rface))) + (t + nil)))) (concat (powerline-render lhs) (powerline-fill-center face1 (/ (powerline-width center) 2.0)) (powerline-render center) @@ -126,3 +131,5 @@ window type." (provide 'my-mode-line) ;;; my-mode-line.el ends here + +