doomemacs/modules/editor/god/autoload.el

47 lines
2 KiB
EmacsLisp
Raw Normal View History

;;; editor/god/autoload.el -*- lexical-binding: t; -*-
2019-09-24 21:32:07 +12:00
2019-10-05 09:03:16 +13:00
(defvar +god-default-color (face-background 'cursor)
2019-09-24 21:32:07 +12:00
"Default cursor and bar color.")
2019-10-05 09:03:16 +13:00
(defvar +god-read-only-mode-color "Gray"
2019-09-24 21:32:07 +12:00
"Cursor and bar color when `read-only-mode' is enabled.")
2019-10-05 09:03:16 +13:00
(defvar +god-overwrite-mode-color "Yellow"
2019-09-24 21:32:07 +12:00
"Cursor and bar color when `overwrite-mode' is enabled.")
2019-10-05 09:03:16 +13:00
(defvar +god-fill-overflow-color "IndianRed"
2019-09-24 21:32:07 +12:00
"Cursor and bar color when fill column width has been exceeded.")
;;;###autoload
2019-10-05 09:02:13 +13:00
(defun +god--configure-cursor-and-modeline-h ()
2019-09-24 21:32:07 +12:00
"Configure cursor type, cursor color and doom-modeline bar color depending on mode."
(let* ((is-fill-overflow (> (current-column) fill-column))
(previous-cursor-color (face-background 'cursor))
(previous-modeline-color (and (facep 'doom-modeline-bar)
(face-background 'doom-modeline-bar)))
(is-god-mode (bound-and-true-p god-local-mode))
2019-09-24 21:32:07 +12:00
(next-cursor-type
(cond (buffer-read-only 'box)
((and overwrite-mode is-god-mode) 'hollow)
((or is-god-mode overwrite-mode) 'box)
(t 'bar)))
(next-cursor-and-modeline-color
2019-10-05 09:03:16 +13:00
(cond (buffer-read-only +god-read-only-mode-color)
(is-fill-overflow +god-fill-overflow-color)
(overwrite-mode +god-overwrite-mode-color)
(t +god-default-color))))
2019-09-24 21:32:07 +12:00
(setq cursor-type next-cursor-type)
(unless (eq previous-cursor-color next-cursor-and-modeline-color)
(set-cursor-color next-cursor-and-modeline-color))
(when (and (facep 'doom-modeline-bar)
(fboundp 'doom-modeline-refresh-bars)
(not (eq previous-modeline-color next-cursor-and-modeline-color)))
(set-face-attribute 'doom-modeline-bar nil :background next-cursor-and-modeline-color)
(doom-modeline-refresh-bars))))
;;;###autoload
2019-10-05 09:02:13 +13:00
(defun +god--toggle-on-overwrite-h ()
2019-09-24 21:32:07 +12:00
(if (bound-and-true-p overwrite-mode)
(god-local-mode-pause)
(god-local-mode-resume)))