aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2018-04-28 17:23:40 +0100
committerWilfred Hughes <me@wilfred.me.uk>2018-04-28 17:23:40 +0100
commit88771efa6327e94076b3815d374c1750efe2f01b (patch)
tree67eae3ed5479c4ef1488e607cf2952766d364c3f
parentd062359168f4f53309d91c4b4aec1d912e403af5 (diff)
When visiting a reference, temporarily highlight the symbol
-rw-r--r--CHANGELOG.md3
-rw-r--r--helpful.el17
2 files changed, 18 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2cd728e..6c5c0d8 100644
--- 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
index 24ad119..6ba0b14 100644
--- 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.