From 6c2d45e81b394f3c197a8f3935dcd9fd76d7cdf3 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 20 Jun 2023 10:18:30 -0500 Subject: Add dinghie --- emacs.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/emacs.el b/emacs.el index 73e0e8b..0ec616c 100644 --- a/emacs.el +++ b/emacs.el @@ -1441,3 +1441,49 @@ NEW is passed to `eshell'." (wiki-abbrev-insinuate) (add-hook 'text-mode-hook #'abbrev-mode)) (put 'list-timers 'disabled nil) + +;;; Dinghie + +(add-to-list 'mode-line-misc-info + '(buffer-ding-cookie buffer-ding-cookie) + :append) + +(defvar buffer-ding-timer nil + "Timer for `buffer-ding'.") +(defvar buffer-ding-cookie nil + "Variable to hold the `face-remap-add-relative' cookie.") +(defcustom buffer-ding-timeout 0.25 + "How long to ding the buffer for.") + +(defun buffer-unding () + "Unflash the buffer after done `ding'ing." + ;; (face-remap-remove-relative buffer-ding-cookie) + (setq buffer-ding-cookie nil) + (force-mode-line-update)) + +(defun buffer-ding () + "Flash the buffer for `ding'." + (cond + ((timerp buffer-ding-timer) + (cancel-timer buffer-ding-timer) + (setq buffer-ding-timer nil) + (buffer-ding)) + ((and (null buffer-ding-timer) + buffer-ding-cookie) + (setq buffer-ding-cookie nil) + (buffer-unding)) + (t + ;; (setq buffer-ding-cookie (face-remap-add-relative 'default 'error)) + (setq buffer-ding-cookie " Ding!") + (force-mode-line-update) + (run-with-timer buffer-ding-timeout nil #'buffer-unding)))) + +(setopt ring-bell-function #'buffer-ding) +(add-hook 'isearch-mode-end-hook #'buffer-unding) + +(defun mapc-buffers (fn &rest modes) + (cl-loop for buf being the buffers + do (with-current-buffer buf + (when (or (null modes) + (apply #'derived-mode-p modes)) + (funcall fn))))) -- cgit 1.4.1-21-gabe81