tools/lookup: fix missing +lookup-symbol-or-region error

This commit is contained in:
Henrik Lissner 2019-05-16 00:10:56 -04:00
parent 4002313e79
commit 1f88efeb82
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 21 additions and 20 deletions

View file

@ -85,7 +85,7 @@ Use `dash-docs-install-docset' to install docsets."
(interactive)
(require 'dash-docs)
(let ((dash-docs-docsets (or docsets (dash-docs-buffer-local-docsets)))
(query (or query (+lookup--symbol-or-region) "")))
(query (or query (+lookup-symbol-or-region) "")))
(cond ((featurep! :completion helm)
(helm-dash query))
((featurep! :completion ivy)

View file

@ -94,18 +94,6 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g.
(put fn '+lookup-async (or (plist-get plist :async) async))
(add-hook functions-var fn nil t))))
(defun +lookup--symbol-or-region (&optional initial)
"Grab the symbol at point or selected region."
(cond ((stringp initial)
initial)
((use-region-p)
(buffer-substring-no-properties (region-beginning)
(region-end)))
((require 'xref nil t)
;; A little smarter than using `symbol-at-point', though in most cases,
;; xref ends up using `symbol-at-point' anyway.
(xref-backend-identifier-at-point (xref-find-backend)))))
(defun +lookup--run-handler (handler identifier)
(if (commandp handler)
(call-interactively handler)
@ -159,6 +147,19 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g.
(better-jumper-set-jump (marker-position origin)))
result)))
;;;###autoload
(defun +lookup-symbol-or-region (&optional initial)
"Grab the symbol at point or selected region."
(cond ((stringp initial)
initial)
((use-region-p)
(buffer-substring-no-properties (region-beginning)
(region-end)))
((require 'xref nil t)
;; A little smarter than using `symbol-at-point', though in most cases,
;; xref ends up using `symbol-at-point' anyway.
(xref-backend-identifier-at-point (xref-find-backend)))))
;;
;;; Lookup backends
@ -231,7 +232,7 @@ Each function in `+lookup-definition-functions' is tried until one changes the
point or current buffer. Falls back to dumb-jump, naive
ripgrep/the_silver_searcher text search, then `evil-goto-definition' if
evil-mode is active."
(interactive (list (+lookup--symbol-or-region)))
(interactive (list (+lookup-symbol-or-region)))
(cond ((null identifier) (user-error "Nothing under point"))
((+lookup--jump-to :definition identifier))
((error "Couldn't find the definition of %S" identifier))))
@ -243,7 +244,7 @@ evil-mode is active."
Tries each function in `+lookup-references-functions' until one changes the
point and/or current buffer. Falls back to a naive ripgrep/the_silver_searcher
search otherwise."
(interactive (list (+lookup--symbol-or-region)))
(interactive (list (+lookup-symbol-or-region)))
(cond ((null identifier) (user-error "Nothing under point"))
((+lookup--jump-to :references identifier))
((error "Couldn't find references of %S" identifier))))
@ -255,8 +256,8 @@ search otherwise."
First attempts the :documentation handler specified with `set-lookup-handlers!'
for the current mode/buffer (if any), then falls back to the backends in
`+lookup-documentation-functions'."
(interactive (list (+lookup--symbol-or-region)))
(cond ((+lookup--jump-to :documentation identifier 'pop-to-buffer))
(interactive (list (+lookup-symbol-or-region)))
(cond ((+lookup--jump-to :documentation identifier #'pop-to-buffer))
((user-error "Couldn't find documentation for %S" identifier))))
(defvar ffap-file-finder)
@ -275,7 +276,7 @@ Otherwise, falls back on `find-file-at-point'."
(or (ffap-guesser)
(ffap-read-file-or-url
(if ffap-url-regexp "Find file or URL: " "Find file: ")
(+lookup--symbol-or-region))))))
(+lookup-symbol-or-region))))))
(require 'ffap)
(cond ((not path)
(call-interactively #'find-file-at-point))
@ -323,7 +324,7 @@ DOCSETS is a list of docset strings. Docsets can be installed with
(or (bound-and-true-p counsel-dash-docsets)
(bound-and-true-p helm-dash-docsets)))))
(helm-dash-docsets counsel-dash-docsets)
(query (or query (+lookup--symbol-or-region) "")))
(query (or query (+lookup-symbol-or-region) "")))
(cond ((featurep! :completion helm)
(helm-dash query))
((featurep! :completion ivy)