From bda5b2538fc037f7e0239cca801452d39360d002 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 28 May 2021 07:31:53 -0500 Subject: Fix mode-line flashing Thanks, doom-themes! --- init.el | 13 ++++--------- lisp/acdw-bell.el | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 lisp/acdw-bell.el diff --git a/init.el b/init.el index 7c9d96a..b6e73ba 100644 --- a/init.el +++ b/init.el @@ -50,14 +50,6 @@ ;; see also: `acdw' and friends. Functions here aren't big enough, or they're ;; too tightly bound to stuff here, to be placed in `acdw'. -;; Flash the mode line -(defun flash-mode-line () - "Flash the modeline as a bell." - (when (acdw/system :home) - (beep)) - (invert-face 'mode-line) - (run-with-timer 0.1 nil #'invert-face 'mode-line)) - (defvar lispy-modes '(emacs-lisp-mode eval-expression-minibuffer ielm-mode @@ -690,11 +682,14 @@ (:global "M-SPC" cycle-spacing)) (setup windows + (require 'acdw-bell) (:option use-dialog-box nil use-file-dialog nil tab-bar-show 1 visible-bell nil - ring-bell-function #'flash-mode-line + ring-bell-function (lambda () + (acdw-bell/flash-mode-line + (acdw/system :home))) recenter-positions '(top middle bottom)) (tooltip-mode -1) diff --git a/lisp/acdw-bell.el b/lisp/acdw-bell.el new file mode 100644 index 0000000..514be1f --- /dev/null +++ b/lisp/acdw-bell.el @@ -0,0 +1,28 @@ +;;; 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 -- cgit 1.4.1-21-gabe81