tools/lookup: fix missing +lookup-symbol-or-region error
This commit is contained in:
parent
4002313e79
commit
1f88efeb82
3 changed files with 21 additions and 20 deletions
|
@ -85,7 +85,7 @@ Use `dash-docs-install-docset' to install docsets."
|
||||||
(interactive)
|
(interactive)
|
||||||
(require 'dash-docs)
|
(require 'dash-docs)
|
||||||
(let ((dash-docs-docsets (or docsets (dash-docs-buffer-local-docsets)))
|
(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)
|
(cond ((featurep! :completion helm)
|
||||||
(helm-dash query))
|
(helm-dash query))
|
||||||
((featurep! :completion ivy)
|
((featurep! :completion ivy)
|
||||||
|
|
|
@ -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))
|
(put fn '+lookup-async (or (plist-get plist :async) async))
|
||||||
(add-hook functions-var fn nil t))))
|
(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)
|
(defun +lookup--run-handler (handler identifier)
|
||||||
(if (commandp handler)
|
(if (commandp handler)
|
||||||
(call-interactively 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)))
|
(better-jumper-set-jump (marker-position origin)))
|
||||||
result)))
|
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
|
;;; 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
|
point or current buffer. Falls back to dumb-jump, naive
|
||||||
ripgrep/the_silver_searcher text search, then `evil-goto-definition' if
|
ripgrep/the_silver_searcher text search, then `evil-goto-definition' if
|
||||||
evil-mode is active."
|
evil-mode is active."
|
||||||
(interactive (list (+lookup--symbol-or-region)))
|
(interactive (list (+lookup-symbol-or-region)))
|
||||||
(cond ((null identifier) (user-error "Nothing under point"))
|
(cond ((null identifier) (user-error "Nothing under point"))
|
||||||
((+lookup--jump-to :definition identifier))
|
((+lookup--jump-to :definition identifier))
|
||||||
((error "Couldn't find the definition of %S" 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
|
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
|
point and/or current buffer. Falls back to a naive ripgrep/the_silver_searcher
|
||||||
search otherwise."
|
search otherwise."
|
||||||
(interactive (list (+lookup--symbol-or-region)))
|
(interactive (list (+lookup-symbol-or-region)))
|
||||||
(cond ((null identifier) (user-error "Nothing under point"))
|
(cond ((null identifier) (user-error "Nothing under point"))
|
||||||
((+lookup--jump-to :references identifier))
|
((+lookup--jump-to :references identifier))
|
||||||
((error "Couldn't find references of %S" 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!'
|
First attempts the :documentation handler specified with `set-lookup-handlers!'
|
||||||
for the current mode/buffer (if any), then falls back to the backends in
|
for the current mode/buffer (if any), then falls back to the backends in
|
||||||
`+lookup-documentation-functions'."
|
`+lookup-documentation-functions'."
|
||||||
(interactive (list (+lookup--symbol-or-region)))
|
(interactive (list (+lookup-symbol-or-region)))
|
||||||
(cond ((+lookup--jump-to :documentation identifier 'pop-to-buffer))
|
(cond ((+lookup--jump-to :documentation identifier #'pop-to-buffer))
|
||||||
((user-error "Couldn't find documentation for %S" identifier))))
|
((user-error "Couldn't find documentation for %S" identifier))))
|
||||||
|
|
||||||
(defvar ffap-file-finder)
|
(defvar ffap-file-finder)
|
||||||
|
@ -275,7 +276,7 @@ Otherwise, falls back on `find-file-at-point'."
|
||||||
(or (ffap-guesser)
|
(or (ffap-guesser)
|
||||||
(ffap-read-file-or-url
|
(ffap-read-file-or-url
|
||||||
(if ffap-url-regexp "Find file or URL: " "Find file: ")
|
(if ffap-url-regexp "Find file or URL: " "Find file: ")
|
||||||
(+lookup--symbol-or-region))))))
|
(+lookup-symbol-or-region))))))
|
||||||
(require 'ffap)
|
(require 'ffap)
|
||||||
(cond ((not path)
|
(cond ((not path)
|
||||||
(call-interactively #'find-file-at-point))
|
(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)
|
(or (bound-and-true-p counsel-dash-docsets)
|
||||||
(bound-and-true-p helm-dash-docsets)))))
|
(bound-and-true-p helm-dash-docsets)))))
|
||||||
(helm-dash-docsets counsel-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)
|
(cond ((featurep! :completion helm)
|
||||||
(helm-dash query))
|
(helm-dash query))
|
||||||
((featurep! :completion ivy)
|
((featurep! :completion ivy)
|
||||||
|
|
|
@ -140,7 +140,7 @@ this list.")
|
||||||
|
|
||||||
;; Before `gnutls' is loaded, `gnutls-algorithm-priority' is treated as a
|
;; Before `gnutls' is loaded, `gnutls-algorithm-priority' is treated as a
|
||||||
;; lexical variable, which breaks `+lookup*fix-gnutls-error'
|
;; lexical variable, which breaks `+lookup*fix-gnutls-error'
|
||||||
(defvar gnutls-algorithm-priority)
|
(defvar gnutls-algorithm-priority)
|
||||||
(defun +lookup*fix-gnutls-error (orig-fn url)
|
(defun +lookup*fix-gnutls-error (orig-fn url)
|
||||||
"Fixes integer-or-marker-p errors emitted from Emacs' url library,
|
"Fixes integer-or-marker-p errors emitted from Emacs' url library,
|
||||||
particularly, the `url-retrieve-synchronously' call in
|
particularly, the `url-retrieve-synchronously' call in
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue