tools/lookup: conform to new conventions
This commit is contained in:
parent
d106272574
commit
6cda303ae6
4 changed files with 20 additions and 20 deletions
|
@ -51,7 +51,7 @@ Used by `+lookup/in-docsets' and `+lookup/documentation'."
|
||||||
(add-hook hook fn 'append))))))
|
(add-hook hook fn 'append))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +lookup-dash-docsets-backend (identifier)
|
(defun +lookup-dash-docsets-backend-fn (identifier)
|
||||||
"Looks up IDENTIFIER in available Dash docsets, if any are installed.
|
"Looks up IDENTIFIER in available Dash docsets, if any are installed.
|
||||||
|
|
||||||
This backend is meant for `+lookup-documentation-functions'.
|
This backend is meant for `+lookup-documentation-functions'.
|
||||||
|
|
|
@ -60,7 +60,7 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g.
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
(dolist (mode (doom-enlist modes))
|
(dolist (mode (doom-enlist modes))
|
||||||
(let ((hook (intern (format "%s-hook" mode)))
|
(let ((hook (intern (format "%s-hook" mode)))
|
||||||
(fn (intern (format "+lookup|init-%s-handlers" mode))))
|
(fn (intern (format "+lookup--init-%s-handlers-h" mode))))
|
||||||
(cond ((null (car plist))
|
(cond ((null (car plist))
|
||||||
(remove-hook hook fn)
|
(remove-hook hook fn)
|
||||||
(unintern fn nil))
|
(unintern fn nil))
|
||||||
|
@ -183,15 +183,15 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g.
|
||||||
'deferred
|
'deferred
|
||||||
t))))
|
t))))
|
||||||
|
|
||||||
(defun +lookup-xref-definitions-backend (identifier)
|
(defun +lookup-xref-definitions-backend-fn (identifier)
|
||||||
"Non-interactive wrapper for `xref-find-definitions'"
|
"Non-interactive wrapper for `xref-find-definitions'"
|
||||||
(+lookup--xref-show 'xref-backend-definitions identifier))
|
(+lookup--xref-show 'xref-backend-definitions identifier))
|
||||||
|
|
||||||
(defun +lookup-xref-references-backend (identifier)
|
(defun +lookup-xref-references-backend-fn (identifier)
|
||||||
"Non-interactive wrapper for `xref-find-references'"
|
"Non-interactive wrapper for `xref-find-references'"
|
||||||
(+lookup--xref-show 'xref-backend-references identifier))
|
(+lookup--xref-show 'xref-backend-references identifier))
|
||||||
|
|
||||||
(defun +lookup-dumb-jump-backend (_identifier)
|
(defun +lookup-dumb-jump-backend-fn (_identifier)
|
||||||
"Look up the symbol at point (or selection) with `dumb-jump', which conducts a
|
"Look up the symbol at point (or selection) with `dumb-jump', which conducts a
|
||||||
project search with ag, rg, pt, or git-grep, combined with extra heuristics to
|
project search with ag, rg, pt, or git-grep, combined with extra heuristics to
|
||||||
reduce false positives.
|
reduce false positives.
|
||||||
|
@ -200,7 +200,7 @@ This backend prefers \"just working\" over accuracy."
|
||||||
(and (require 'dumb-jump nil t)
|
(and (require 'dumb-jump nil t)
|
||||||
(dumb-jump-go)))
|
(dumb-jump-go)))
|
||||||
|
|
||||||
(defun +lookup-project-search-backend (identifier)
|
(defun +lookup-project-search-backend-fn (identifier)
|
||||||
"Conducts a simple project text search for IDENTIFIER.
|
"Conducts a simple project text search for IDENTIFIER.
|
||||||
|
|
||||||
Uses and requires `+ivy-file-search' or `+helm-file-search'. Will return nil if
|
Uses and requires `+ivy-file-search' or `+helm-file-search'. Will return nil if
|
||||||
|
@ -217,7 +217,7 @@ falling back to git-grep)."
|
||||||
(+helm-file-search nil :query query)
|
(+helm-file-search nil :query query)
|
||||||
t))))))
|
t))))))
|
||||||
|
|
||||||
(defun +lookup-evil-goto-definition-backend (_identifier)
|
(defun +lookup-evil-goto-definition-backend-fn (_identifier)
|
||||||
"Uses `evil-goto-definition' to conduct a text search for IDENTIFIER in the
|
"Uses `evil-goto-definition' to conduct a text search for IDENTIFIER in the
|
||||||
current buffer."
|
current buffer."
|
||||||
(and (fboundp 'evil-goto-definition)
|
(and (fboundp 'evil-goto-definition)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
provider))))
|
provider))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +lookup-online-backend (identifier)
|
(defun +lookup-online-backend-fn (identifier)
|
||||||
"Opens the browser and searches for IDENTIFIER online.
|
"Opens the browser and searches for IDENTIFIER online.
|
||||||
|
|
||||||
Will prompt for which search engine to use the first time (or if the universal
|
Will prompt for which search engine to use the first time (or if the universal
|
||||||
|
|
|
@ -33,10 +33,10 @@ produces an url. Used by `+lookup/online'.")
|
||||||
"Function to use to open search urls.")
|
"Function to use to open search urls.")
|
||||||
|
|
||||||
(defvar +lookup-definition-functions
|
(defvar +lookup-definition-functions
|
||||||
'(+lookup-xref-definitions-backend
|
'(+lookup-xref-definitions-backend-fn
|
||||||
+lookup-dumb-jump-backend
|
+lookup-dumb-jump-backend-fn
|
||||||
+lookup-project-search-backend
|
+lookup-project-search-backend-fn
|
||||||
+lookup-evil-goto-definition-backend)
|
+lookup-evil-goto-definition-backend-fn)
|
||||||
"Functions for `+lookup/definition' to try, before resorting to `dumb-jump'.
|
"Functions for `+lookup/definition' to try, before resorting to `dumb-jump'.
|
||||||
Stops at the first function to return non-nil or change the current
|
Stops at the first function to return non-nil or change the current
|
||||||
window/point.
|
window/point.
|
||||||
|
@ -47,8 +47,8 @@ argument: the identifier at point. See `set-lookup-handlers!' about adding to
|
||||||
this list.")
|
this list.")
|
||||||
|
|
||||||
(defvar +lookup-references-functions
|
(defvar +lookup-references-functions
|
||||||
'(+lookup-xref-references-backend
|
'(+lookup-xref-references-backend-fn
|
||||||
+lookup-project-search-backend)
|
+lookup-project-search-backend-fn)
|
||||||
"Functions for `+lookup/references' to try, before resorting to `dumb-jump'.
|
"Functions for `+lookup/references' to try, before resorting to `dumb-jump'.
|
||||||
Stops at the first function to return non-nil or change the current
|
Stops at the first function to return non-nil or change the current
|
||||||
window/point.
|
window/point.
|
||||||
|
@ -59,7 +59,7 @@ argument: the identifier at point. See `set-lookup-handlers!' about adding to
|
||||||
this list.")
|
this list.")
|
||||||
|
|
||||||
(defvar +lookup-documentation-functions
|
(defvar +lookup-documentation-functions
|
||||||
'(+lookup-online-backend)
|
'(+lookup-online-backend-fn)
|
||||||
"Functions for `+lookup/documentation' to try, before resorting to
|
"Functions for `+lookup/documentation' to try, before resorting to
|
||||||
`dumb-jump'. Stops at the first function to return non-nil or change the current
|
`dumb-jump'. Stops at the first function to return non-nil or change the current
|
||||||
window/point.
|
window/point.
|
||||||
|
@ -108,10 +108,10 @@ this list.")
|
||||||
;; xref to be one too.
|
;; xref to be one too.
|
||||||
(remove-hook 'xref-backend-functions #'etags--xref-backend)
|
(remove-hook 'xref-backend-functions #'etags--xref-backend)
|
||||||
;; ...however, it breaks `projectile-find-tag', unless we put it back.
|
;; ...however, it breaks `projectile-find-tag', unless we put it back.
|
||||||
(defun +lookup*projectile-find-tag (orig-fn)
|
(def-advice! +lookup-projectile-find-tag-a (orig-fn)
|
||||||
|
:around #'projectile-find-tag
|
||||||
(let ((xref-backend-functions '(etags--xref-backend t)))
|
(let ((xref-backend-functions '(etags--xref-backend t)))
|
||||||
(funcall orig-fn)))
|
(funcall orig-fn)))
|
||||||
(advice-add #'projectile-find-tag :around #'+lookup*projectile-find-tag)
|
|
||||||
|
|
||||||
;; Use `better-jumper' instead of xref's marker stack
|
;; Use `better-jumper' instead of xref's marker stack
|
||||||
(advice-add #'xref-push-marker-stack :around #'doom-set-jump-a)
|
(advice-add #'xref-push-marker-stack :around #'doom-set-jump-a)
|
||||||
|
@ -133,7 +133,7 @@ this list.")
|
||||||
(def-package! dash-docs
|
(def-package! dash-docs
|
||||||
:when (featurep! +docsets)
|
:when (featurep! +docsets)
|
||||||
:init
|
:init
|
||||||
(add-hook '+lookup-documentation-functions #'+lookup-dash-docsets-backend)
|
(add-hook '+lookup-documentation-functions #'+lookup-dash-docsets-backend-fn)
|
||||||
:config
|
:config
|
||||||
(setq dash-docs-enable-debugging doom-debug-mode
|
(setq dash-docs-enable-debugging doom-debug-mode
|
||||||
dash-docs-docsets-path (concat doom-etc-dir "docsets/")
|
dash-docs-docsets-path (concat doom-etc-dir "docsets/")
|
||||||
|
@ -143,16 +143,16 @@ 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)
|
(def-advice! +lookup-fix-gnutls-error-a (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
|
||||||
`dash-docs-read-json-from-url'. This is part of a systemic issue with Emacs 26's
|
`dash-docs-read-json-from-url'. This is part of a systemic issue with Emacs 26's
|
||||||
networking library (fixed in Emacs 27+, apparently).
|
networking library (fixed in Emacs 27+, apparently).
|
||||||
|
|
||||||
See https://github.com/magit/ghub/issues/81"
|
See https://github.com/magit/ghub/issues/81"
|
||||||
|
:around #'dash-docs-read-json-from-url
|
||||||
(let ((gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
|
(let ((gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
|
||||||
(funcall orig-fn url)))
|
(funcall orig-fn url)))
|
||||||
(advice-add #'dash-docs-read-json-from-url :around #'+lookup*fix-gnutls-error)
|
|
||||||
|
|
||||||
(def-package! helm-dash
|
(def-package! helm-dash
|
||||||
:when (featurep! :completion helm))
|
:when (featurep! :completion helm))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue