Skip to content

Commit

Permalink
Merge pull request #2 from fenril058/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
fenril058 authored Jun 28, 2022
2 parents f8795f1 + 840a762 commit 0623da8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 24 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Introduction

`hiwin.el` is a minor-mode of Emacs to change background color of
deactive window.
`hiwin.el` is a minor-mode of Emacs to change the background color of
the deactive window.

## Screenshot

Expand Down Expand Up @@ -38,3 +38,8 @@ You can custmize this variable BEFORE enabling `hiwin-mode`. If you
change it while enabling `hiwin-mode`, you have to run
`hiwin-refresh-ignore-buffer-names` to
refresh`hiwin-ignore-buffer-name-regexp`.

#### hiwin-ignore-minibuffer-selected-window

If the value is `non-nil`, the background color of the window selected
just before the minibuffer does not change. The default value is `nil`.
60 changes: 38 additions & 22 deletions hiwin.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
;; 2016 ril
;;
;; Author: k.sugita
;; Last Modified:
;; Version: 2.1.0
;; Keywords: faces, editing, emulating
;; Version: 2.2.2
;;
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
Expand All @@ -34,10 +33,23 @@
;; (hiwin-activate)
;; (set-face-background 'hiwin-face "gray80")
;;
;; if you want to ignore the *eshell* buffer,
;; put followings:
;; (add-to-list 'hiwin-ignore-buffer-names "*eshell*")
;;
;; if you invisible active window, type M-x hiwin-deactivate.

;;; Changes
;;
;; 2022-06-28 ril
;; - `select-window'のNORECORD optionをtにして記録されないようにした.
;; - ミニバッファ直前のウィンドウを除外するかどうか選べるようにした.
;; `hiwin-ignore-minibuffer-selected-window'がnon-nilのとき除外.
;; デフォルトはnilで除外しない.
;; - `post-command-hook'ではなく`window-configuration-change-hook'
;; にhookするようにした. これで十分.
;; - 以上の変更によりVersionを2.2.2に変更した.
;;
;; 2022-06-27 ril
;; - Emacs 27以上の対応として `hiwin-face'に :extend t を追加.
;; - DocumationとCommnetをわかりやすいように変更.
Expand Down Expand Up @@ -82,14 +94,19 @@
"Visible active window mode."
:group 'emacs)

(defconst hiwin-version "2.1.0"
(defconst hiwin-version "2.2.2"
"Version number of hiwin-mode.")

(defcustom hiwin-mode-lighter " hiwin"
"Lighter of hiwin-mode."
:type 'string
:group 'hiwin)

(defcustom hiwin-ignore-minibuffer-selected-window nil
"もしこの変数が non-nil であれば,ミニバッファ直前のウィンドウをハイライト対象外にする."
:type 'boolean
:group 'hiwin)

(defcustom hiwin-ignore-buffer-names '("+draft/" "*helm")
"ハイライト対象外にするバッファ名のリスト.
バッファ名にこのリストの文字列が含まれるとき,
Expand Down Expand Up @@ -188,6 +205,7 @@ Face for inactive window.")
(hw-tgt-win nil) ; 処理対象ウィンドウ
(hw-win-lst (window-list)) ; ウィンドウリスト
(hw-cnt 0) ; ループカウンタ
(minibuffer-selected-window (minibuffer-selected-window))
)
(while hw-win-lst
;; 処理対象ウィンドウを取得
Expand All @@ -199,11 +217,13 @@ Face for inactive window.")
;; ウィンドウ以外を処理
(unless (or (eq hw-tgt-win (minibuffer-window))
(eq hw-tgt-win hiwin-active-window)
(when hiwin-ignore-minibuffer-selected-window
(eq hw-tgt-win minibuffer-selected-window))
(string-match hiwin-ignore-buffer-name-regexp
(buffer-name (window-buffer hw-tgt-win))))
(save-selected-window
;; 処理対象ウィンドウを選択
(select-window hw-tgt-win)
(select-window hw-tgt-win t)
;; バッファ末尾の場合, ポイントを一文字戻す. overlayの
;; after-stringで末尾に改行をたくさん挿入するとき, こうしな
;; いとポイントが遠くに飛ばされてしまう.
Expand All @@ -224,20 +244,16 @@ Face for inactive window.")
))

(defun hiwin-command-hook ()
"オーバーレイを再描画する.
現在は前回の処理からウィンドウ数か, アクティブ ウィンドウが変更され
ている場合に実行される."
(unless (and (eq hiwin-overlay-count (count-windows))
(eq hiwin-active-window (selected-window)))
(if executing-kbd-macro
(input-pending-p)
(condition-case hiwin-error
(hiwin-draw-ovl)
(error
(if (not (window-minibuffer-p (selected-window)))
(message "[%s] hiwin-mode catched error: %s"
(format-time-string "%H:%M:%S" (current-time))
hiwin-error) ))))))
"オーバーレイを再描画する."
(if executing-kbd-macro
(input-pending-p)
(condition-case hiwin-error
(hiwin-draw-ovl)
(error
(if (not (window-minibuffer-p (selected-window)))
(message "[%s] hiwin-mode catched error: %s"
(format-time-string "%H:%M:%S" (current-time))
hiwin-error))))))

;;;###autoload
(defun hiwin-refresh-ignore-buffer-names ()
Expand All @@ -256,10 +272,10 @@ Face for inactive window.")
(if hiwin-mode
(progn
(hiwin-refresh-ignore-buffer-names)
(add-hook 'post-command-hook 'hiwin-command-hook))
(remove-hook 'post-command-hook 'hiwin-command-hook)
(hiwin-delete-ovl)
))
(add-hook 'window-configuration-change-hook 'hiwin-command-hook))
(remove-hook 'window-configuration-change-hook 'hiwin-command-hook)
(hiwin-delete-ovl))
)

;;;###autoload
(defun hiwin-activate ()
Expand Down

0 comments on commit 0623da8

Please sign in to comment.