;;; nf-other-window.el --- blink cursor when cursor changes windows ;; Author: Noah Friedman ;; Public domain. ;; $Id: nf-other-window.el,v 1.1 2022/01/01 23:26:49 friedman Exp $ ;;; Commentary: ;;; Code: (defgroup nf-other-window nil "See command `nf-other-window-blink-cursor-mode'." :group 'convenience) (defcustom nf-other-window-blink-cursor-default-count 3 "Number of times to blink the cursor." :type 'integer :group 'nf-other-window) (defcustom nf-other-window-blink-cursor-default-delay 0.04 "Speed of cursor blinkage, in seconds or fractions of a second. This value represents the delay between toggling cursor visibility." :type 'number :group 'nf-other-window) ;;;### autoload (define-minor-mode nf-other-window-blink-cursor-mode "Momentarily blink cursor radidly in the selected window when it is newly selected. This only occurs if the window is selected interactively by the user, not programatically." :init-value nil :global t) (defun nf-other-window-rapid-blink-cursor (&optional count delay) (unless delay (setq delay nf-other-window-blink-cursor-default-delay)) (let ((orig-show (internal-show-cursor-p (selected-window))) (x (* 2 (or count nf-other-window-blink-cursor-default-count))) (show nil)) (unwind-protect (while (and (not (zerop x)) (sit-for delay)) (setq show (not show)) (setq x (1- x)) (internal-show-cursor (selected-window) show)) (internal-show-cursor (selected-window) orig-show)))) (defadvice other-window (after nf-other-window activate) (and nf-other-window-blink-cursor-mode (not noninteractive) (not executing-kbd-macro) (nf-other-window-rapid-blink-cursor))) (provide 'nf-other-window) ;; nf-other-window.el ends here