From b1d307126913cbd4d8af818f7aec7ada6a0ea4ad Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 4 Dec 2021 23:09:33 -0600 Subject: uhhhhhhhh --- lisp/+pulse.el | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 lisp/+pulse.el (limited to 'lisp/+pulse.el') diff --git a/lisp/+pulse.el b/lisp/+pulse.el new file mode 100644 index 0000000..6ba7ded --- /dev/null +++ b/lisp/+pulse.el @@ -0,0 +1,50 @@ +;;; +pulse.el -*- lexical-binding: t; -*- + +;;; Code: + +(defgroup +pulse nil + "Extra customizations for `pulse'." + :group 'pulse + :prefix "+pulse-") + +(defcustom +pulse-location-commands '(scroll-up-command + scroll-down-command + recenter-top-bottom + other-window + switch-to-buffer + redraw-frame) + "Commands to pulse the current line after. +Good for finding location." + :type '(repeat function)) + +(defcustom +pulse-location-function '+pulse-line-current-window + "What function to call after `+pulse-location-commands'." + :type 'function) + +;; XXX: this doesn't work yet. I only want to pulse the line in the +;; active window, so when I have the same buffer viewed in multiple +;; windows I can still see where my cursor is. To see the issue, C-x +;; 2 then C-x o a few times. +(defun +pulse-line-current-window (&rest _) + "Pulse the current line, but only if this window is active." + (pulse-momentary-highlight-one-line + (window-point (selected-window)))) + +(defun +pulse--advice-remove (symbol where function &optional props) + "Remove advice SYMBOL from FUNCTION. +This uses the same args as `advice-add' for easy toggling. +WHERE and PROPS are discarded." + (ignore where props) + (advice-remove symbol function)) + +(define-minor-mode +pulse-location-mode + "After moving locations, pulse where we are." + :global t + :keymap nil + (dolist (command +pulse-location-commands) + (funcall + (if +pulse-location-mode 'advice-add '+pulse--advice-remove) + command :after +pulse-location-function))) + +(provide '+pulse) +;;; +pulse.el ends here -- cgit 1.4.1-21-gabe81