feature/lookup: use xref's symbol-at-point function in other lookups

This commit is contained in:
Henrik Lissner 2018-03-26 00:21:54 -04:00
parent 9e62898d92
commit 641e26431d
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -22,7 +22,7 @@
((use-region-p) ((use-region-p)
(buffer-substring-no-properties (region-beginning) (buffer-substring-no-properties (region-beginning)
(region-end))) (region-end)))
((thing-at-point 'symbol t)))) ((xref-backend-identifier-at-point (xref-find-backend)))))
(defun +lookup--jump-to (prop identifier &optional other-window) (defun +lookup--jump-to (prop identifier &optional other-window)
(with-selected-window (with-selected-window
@ -59,8 +59,7 @@ to find it:
Failing all that, it will give up with an error." Failing all that, it will give up with an error."
(interactive (interactive
(list (xref-backend-identifier-at-point (xref-find-backend)) (list (+lookup--symbol-or-region) current-prefix-arg))
current-prefix-arg))
(cond ((null identifier) (cond ((null identifier)
(user-error "Nothing under point")) (user-error "Nothing under point"))
@ -112,7 +111,8 @@ Failing all that, it will give up with an error."
"Show a list of references to the symbol at point. "Show a list of references to the symbol at point.
Tries `xref-find-references' and falls back to rg/ag." Tries `xref-find-references' and falls back to rg/ag."
(interactive (list (thing-at-point 'symbol t))) (interactive
(list (+lookup--symbol-or-region)))
(cond ((and (plist-member +lookup-current-functions :references) (cond ((and (plist-member +lookup-current-functions :references)
(+lookup--jump-to :references identifier))) (+lookup--jump-to :references identifier)))