29 lines
1000 B
EmacsLisp
29 lines
1000 B
EmacsLisp
;;; acdw-bell.el --- flash mode-line on error -*- lexical-binding: t; -*-
|
|
|
|
;; cribbed pretty heavily from doom-themes-ext-visual-bell.el ...
|
|
|
|
(require 'face-remap)
|
|
|
|
(defface acdw-bell '((t (:inherit mode-line-highlight)))
|
|
"Face to use for the mode-line when `doom-themes-visual-bell-config' is used."
|
|
:group 'mode-line)
|
|
|
|
;;;###autoload
|
|
(defun acdw-bell/flash-mode-line (&optional beep-p)
|
|
"Blink the mode-line red briefly. Set `ring-bell-function' to this to use it.
|
|
If BEEP-P is non-nil, beep too."
|
|
(let ((acdw-bell//cookie
|
|
(face-remap-add-relative 'mode-line 'acdw-bell)))
|
|
(force-mode-line-update)
|
|
(when beep-p (beep))
|
|
(run-with-timer 0.15 nil
|
|
(lambda (cookie buf)
|
|
(with-current-buffer buf
|
|
(face-remap-remove-relative cookie)
|
|
(force-mode-line-update)))
|
|
acdw-bell//cookie
|
|
(current-buffer))))
|
|
|
|
(provide 'acdw-bell)
|
|
;;; acdw-bell.el ends here
|