37 lines
1.5 KiB
EmacsLisp
37 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
|