■ Emacs 全般で利用できる設定
【お知らせ】
<2019/05/28 追記>
TAB の表示がずれることがあるように思っていましたが、次のページに書いてあるように tab-mark を可視化すると発生する問題のようです。このため、tab-mark を可視化するのを中止しました。
【本題】
以下の設定を有効としてください。コメント箇所は必要に応じて有効化してください。
(require 'whitespace)
;; 一行が設定値を超えたら長すぎると判断する(whitespace-style 変数の lines-tail と連動)
(setq whitespace-line-column 80)
(setq whitespace-style
'(face
trailing
tabs
spaces
;; lines-tail
newline
;; empty
space-before-tab
space-after-tab
space-mark
tab-mark
newline-mark))
(setq whitespace-display-mappings
'((space-mark ?\u3000 [?□])
(newline-mark ?\n [?\xAB ?\n])
;; (tab-mark ?\t [?\u00BB ?\t]) ; TAB の表示がずれることがあるので可視化を中止
))
;; スペースは全角のみを可視化
(setq whitespace-space-regexp "\\(\u3000+\\)")
;; 対象外とするモードを指定
(setq whitespace-global-modes '(not dired-mode tar-mode))
;; 保存前に自動でクリーンアップ
;; (setq whitespace-action '(auto-cleanup))
(global-whitespace-mode 1)
(set-face-attribute 'whitespace-trailing nil
:foreground "red1"
:background 'unspecified
:underline t)
(set-face-attribute 'whitespace-tab nil
:foreground "slate grey"
:background 'unspecified
:underline t)
(set-face-attribute 'whitespace-space nil
:foreground "slate grey"
:background 'unspecified)
(set-face-attribute 'whitespace-newline nil
:foreground "slate grey")
(set-face-attribute 'whitespace-space-before-tab nil
:foreground "DarkOrange"
:background 'unspecified
:underline t)
(set-face-attribute 'whitespace-space-after-tab nil
:foreground "yellow"
:background 'unspecified
:underline t)
<変更履歴>
最終更新:2019年11月03日 09:57