diff --git a/modules/tools/lookup/autoload/docsets.el b/modules/tools/lookup/autoload/docsets.el index bab2bfe7d..99fb0cd01 100644 --- a/modules/tools/lookup/autoload/docsets.el +++ b/modules/tools/lookup/autoload/docsets.el @@ -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) diff --git a/modules/tools/lookup/autoload/lookup.el b/modules/tools/lookup/autoload/lookup.el index a3efffa19..efeeea5fd 100644 --- a/modules/tools/lookup/autoload/lookup.el +++ b/modules/tools/lookup/autoload/lookup.el @@ -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) diff --git a/modules/tools/lookup/config.el b/modules/tools/lookup/config.el index 7c4411041..232d0c772 100644 --- a/modules/tools/lookup/config.el +++ b/modules/tools/lookup/config.el @@ -140,7 +140,7 @@ this list.") ;; Before `gnutls' is loaded, `gnutls-algorithm-priority' is treated as a ;; lexical variable, which breaks `+lookup*fix-gnutls-error' - (defvar gnutls-algorithm-priority) + (defvar gnutls-algorithm-priority) (defun +lookup*fix-gnutls-error (orig-fn url) "Fixes integer-or-marker-p errors emitted from Emacs' url library, particularly, the `url-retrieve-synchronously' call in