Guest User

[emacs] mode-line-modified

a guest
Mar 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. (defcustom my-mode-line-readonly-string "<READONLY>"
  2. "モード行でバッファが読み取り専用であることを示す文字列。"
  3. :type 'string
  4. :group 'my)
  5.  
  6. (defcustom my-mode-line-modified-string "<MODIFIED>"
  7. "モード行でバッファが変更された状態であることを示す文字列。"
  8. :type 'string
  9. :group 'my)
  10.  
  11. (defcustom my-mode-line-readonly-string-face nil
  12. "`my-mode-line-readonly-string' に適用するフェイス。"
  13. :type 'face
  14. :group 'my)
  15.  
  16. (defcustom my-mode-line-modified-string-face font-lock-warning-face
  17. "`my-mode-line-modified-string' に適用するフェイス。"
  18. :type 'face
  19. :group 'my)
  20.  
  21. (setq-default mode-line-modified
  22. (let ((my-mode-line-readonly-string-propertized
  23. (propertize (replace-regexp-in-string
  24. "%" "%%"
  25. my-mode-line-readonly-string)
  26. 'face my-mode-line-readonly-string-face))
  27. (my-mode-line-modified-string-propertized
  28. (propertize (replace-regexp-in-string
  29. "%" "%%"
  30. my-mode-line-modified-string)
  31. 'face my-mode-line-modified-string-face)))
  32. `(:eval
  33. (cond ((buffer-modified-p)
  34. (list (if buffer-read-only
  35. ,my-mode-line-readonly-string-propertized
  36. "")
  37. ,my-mode-line-modified-string-propertized))
  38. (buffer-read-only
  39. ,my-mode-line-readonly-string-propertized)
  40. (t
  41. "")))))
Add Comment
Please, Sign In to add comment