helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit 88771efa6327e94076b3815d374c1750efe2f01b
parent d062359168f4f53309d91c4b4aec1d912e403af5
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Sat, 28 Apr 2018 17:23:40 +0100

When visiting a reference, temporarily highlight the symbol

Diffstat:
MCHANGELOG.md | 3+++
Mhelpful.el | 17+++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -1,5 +1,8 @@ # v0.10 +When visiting a reference, the occurrences of the symbol are +temporarily highlighted. + URLs in docstrings are now converted to buttons. Function signatures are now correct when a function uses diff --git a/helpful.el b/helpful.el @@ -1860,10 +1860,17 @@ imenu." ;; Prevent imenu converting "Source Code" to "Source.Code". (setq-local imenu-space-replacement " ")) +(defun helpful--flash-region (start end) + "Temporarily highlight region from START to END." + (let ((overlay (make-overlay start end))) + (overlay-put overlay 'face 'highlight) + (run-with-timer 1.0 nil 'delete-overlay overlay))) + (defun helpful-visit-reference () "Go to the reference at point." (interactive) - (let* ((path (get-text-property (point) 'helpful-path)) + (let* ((sym helpful--sym) + (path (get-text-property (point) 'helpful-path)) (pos (get-text-property (point) 'helpful-pos)) (pos-is-start (get-text-property (point) 'helpful-pos-is-start))) (when (and path pos) @@ -1889,7 +1896,13 @@ imenu." (when (or (< pos (point-min)) (> pos (point-max))) (widen)) - (goto-char pos)))) + (goto-char pos) + (save-excursion + (let ((defun-end (scan-sexps (point) 1))) + (while (re-search-forward + (rx-to-string `(seq symbol-start ,(symbol-name sym) symbol-end)) + defun-end t) + (helpful--flash-region (match-beginning 0) (match-end 0)))))))) (defun helpful-kill-buffers () "Kill all `helpful-mode' buffers.