diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2018-04-28 17:23:40 +0100 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2018-04-28 17:23:40 +0100 |
| commit | 88771efa6327e94076b3815d374c1750efe2f01b (patch) | |
| tree | 67eae3ed5479c4ef1488e607cf2952766d364c3f /helpful.el | |
| parent | d062359168f4f53309d91c4b4aec1d912e403af5 (diff) | |
When visiting a reference, temporarily highlight the symbol
Diffstat (limited to 'helpful.el')
| -rw-r--r-- | helpful.el | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -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. |
