Skip to content

Commit

Permalink
racket-xp-mode: Improve xref-backend-identifier-at-point method
Browse files Browse the repository at this point in the history
Use (thing-at-point 'symbol) only as a fallback; prefer the same
properties that our xref-backend-definitions method uses.

Closes #699, even though not exactly the issue originally reported.
  • Loading branch information
greghendershott committed Feb 19, 2024
1 parent d3ab936 commit 9e8e605
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion racket-xp.el
Expand Up @@ -1030,7 +1030,18 @@ around at the first and last errors."
'racket-xp-xref)

(cl-defmethod xref-backend-identifier-at-point ((_backend (eql racket-xp-xref)))
(thing-at-point 'symbol))
(or (seq-some (lambda (prop)
(when (get-text-property (point) prop)
(let* ((end (next-single-property-change (point) prop))
(beg (previous-single-property-change end prop)))
(buffer-substring beg end))))
;; Consider same props our xref-backend-definitions
;; method looks for.
'(racket-xp-require
racket-xp-visit
racket-xp-use
racket-xp-def))
(thing-at-point 'symbol)))

(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql racket-xp-xref)))
(completion-table-dynamic
Expand Down

0 comments on commit 9e8e605

Please sign in to comment.