diff options
Diffstat (limited to 'modeline.el')
-rw-r--r-- | modeline.el | 99 |
1 files changed, 52 insertions, 47 deletions
diff --git a/modeline.el b/modeline.el index a505733..52ae9af 100644 --- a/modeline.el +++ b/modeline.el @@ -169,53 +169,58 @@ MAP is the local keymap of the text." ;; NOTE: I tried to avoid this, but it turns out that this is the most ;; reliable way to do so. -;;;###autoload -(defun modeline-get-active-window (&optional frame) - "The active window excluding the child windows." - (cond - ((and (fboundp #'frame-parent) (frame-parent frame)) - (frame-selected-window (frame-parent frame))) - ((frame-selected-window frame)))) - -;;;###autoload -(defvar modeline-active-window (modeline-get-active-window) - "The active window excluding the child windows.") - -;;;###autoload -(defun modeline-active-window-p () - "Whether we are in the active window." - (and modeline-active-window - (eq modeline-active-window (selected-window)))) - -;;;###autoload -(defun modeline-set-active-window (&rest _) - "Update `modeline-active-window'." - (let ((active-wn (modeline-get-active-window))) - (cond - ((minibuffer-window-active-p active-wn)) - (t (setq modeline-active-window active-wn)))) - (force-mode-line-update t)) - -;;;###autoload -(defsubst modeline-unset-active-window (&rest _) - "Set `modeline-active-window' to `nil'." - (setq modeline-active-window nil)) - -;;;###autoload -(defun modeline-refresh-modeline () - "Refresh the focus state of the mode line." - (setq modeline-active-window nil) - (mapc (lambda (frame) - (cond ((eq (frame-focus-state frame) t) - (setq modeline-active-window (modeline-get-active-window frame))))) - (frame-list))) - -(add-hook 'window-configuration-change-hook #'modeline-set-active-window) -(add-hook 'buffer-list-update-hook #'modeline-set-active-window) -(add-hook 'after-make-frame-functions #'modeline-set-active-window) -(add-hook 'delete-frame-functions #'modeline-set-active-window) -(advice-add #'handle-switch-frame :after #'modeline-set-active-window) -(add-function :after after-focus-change-function #'modeline-refresh-modeline) +;; NOTE: Emacs-29 adds the function `mode-line-window-selected-p' +;; which does what I manually implemented here. + +;; ;;;###autoload +;; (defun modeline-get-active-window (&optional frame) +;; "The active window excluding the child windows." +;; (cond +;; ((and (fboundp #'frame-parent) (frame-parent frame)) +;; (frame-selected-window (frame-parent frame))) +;; ((frame-selected-window frame)))) + +;; ;;;###autoload +;; (defvar modeline-active-window (modeline-get-active-window) +;; "The active window excluding the child windows.") + +(defalias #'modeline-active-window-p #'mode-line-window-selected-p) + +;; ;;;###autoload +;; (defun modeline-active-window-p () +;; "Whether we are in the active window." +;; (and modeline-active-window +;; (eq modeline-active-window (selected-window)))) + +;; ;;;###autoload +;; (defun modeline-set-active-window (&rest _) +;; "Update `modeline-active-window'." +;; (let ((active-wn (modeline-get-active-window))) +;; (cond +;; ((minibuffer-window-active-p active-wn)) +;; (t (setq modeline-active-window active-wn)))) +;; (force-mode-line-update t)) + +;; ;;;###autoload +;; (defsubst modeline-unset-active-window (&rest _) +;; "Set `modeline-active-window' to `nil'." +;; (setq modeline-active-window nil)) + +;; ;;;###autoload +;; (defun modeline-refresh-modeline () +;; "Refresh the focus state of the mode line." +;; (setq modeline-active-window nil) +;; (mapc (lambda (frame) +;; (cond ((eq (frame-focus-state frame) t) +;; (setq modeline-active-window (modeline-get-active-window frame))))) +;; (frame-list))) + +;; (add-hook 'window-configuration-change-hook #'modeline-set-active-window) +;; (add-hook 'buffer-list-update-hook #'modeline-set-active-window) +;; (add-hook 'after-make-frame-functions #'modeline-set-active-window) +;; (add-hook 'delete-frame-functions #'modeline-set-active-window) +;; (advice-add #'handle-switch-frame :after #'modeline-set-active-window) +;; (add-function :after after-focus-change-function #'modeline-refresh-modeline) ;;; Faces |