emacs-doom-themes/doom-themes-ext-visual-bell.el
Henrik Lissner bda168b670
General refactor
In preparation for some big changes. I'd like to split out themes into
their own plugins and facilitate other users pulling in doom-themes to
publish their own derivatives.
2019-06-29 13:16:27 +02:00

36 lines
1.5 KiB
EmacsLisp

;;; doom-themes-ext-visual-bell.el --- flash mode-line on error -*- lexical-binding: t; -*-
(defface doom-visual-bell '((t (:inherit error :inverse-video t)))
"Face to use for the mode-line when `doom-themes-visual-bell-config' is used."
:group 'doom-themes)
(defvar doom-themes--bell-p nil)
;;;###autoload
(defun doom-themes-visual-bell-fn ()
"Blink the mode-line red briefly. Set `ring-bell-function' to this to use it."
(unless doom-themes--bell-p
(let ((old-remap (copy-alist face-remapping-alist)))
(setq doom-themes--bell-p t)
(setq face-remapping-alist
(append (delete (assq 'mode-line face-remapping-alist)
face-remapping-alist)
'((mode-line doom-visual-bell))))
(force-mode-line-update)
(run-with-timer 0.15 nil
(lambda (remap buf)
(with-current-buffer buf
(when (assq 'mode-line face-remapping-alist)
(setq face-remapping-alist remap
doom-themes--bell-p nil))
(force-mode-line-update)))
old-remap
(current-buffer)))))
;;;###autoload
(defun doom-themes-visual-bell-config ()
"Enable flashing the mode-line on error."
(setq ring-bell-function #'doom-themes-visual-bell-fn
visible-bell t))
(provide 'doom-themes-ext-visual-bell)
;;; doom-themes-ext-visual-bell.el ends here