From 6cda303ae627868f67042af354643cd370b33cc0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 22 Jul 2019 23:45:31 +0200 Subject: [PATCH] tools/lookup: conform to new conventions --- modules/tools/lookup/autoload/docsets.el | 2 +- modules/tools/lookup/autoload/lookup.el | 12 ++++++------ modules/tools/lookup/autoload/online.el | 2 +- modules/tools/lookup/config.el | 24 ++++++++++++------------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/tools/lookup/autoload/docsets.el b/modules/tools/lookup/autoload/docsets.el index 7ce92b989..a3e20021f 100644 --- a/modules/tools/lookup/autoload/docsets.el +++ b/modules/tools/lookup/autoload/docsets.el @@ -51,7 +51,7 @@ Used by `+lookup/in-docsets' and `+lookup/documentation'." (add-hook hook fn 'append)))))) ;;;###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. This backend is meant for `+lookup-documentation-functions'. diff --git a/modules/tools/lookup/autoload/lookup.el b/modules/tools/lookup/autoload/lookup.el index 25db27e47..f9a72e1fe 100644 --- a/modules/tools/lookup/autoload/lookup.el +++ b/modules/tools/lookup/autoload/lookup.el @@ -60,7 +60,7 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g. (declare (indent defun)) (dolist (mode (doom-enlist modes)) (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)) (remove-hook hook fn) (unintern fn nil)) @@ -183,15 +183,15 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g. 'deferred t)))) -(defun +lookup-xref-definitions-backend (identifier) +(defun +lookup-xref-definitions-backend-fn (identifier) "Non-interactive wrapper for `xref-find-definitions'" (+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'" (+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 project search with ag, rg, pt, or git-grep, combined with extra heuristics to reduce false positives. @@ -200,7 +200,7 @@ This backend prefers \"just working\" over accuracy." (and (require 'dumb-jump nil t) (dumb-jump-go))) -(defun +lookup-project-search-backend (identifier) +(defun +lookup-project-search-backend-fn (identifier) "Conducts a simple project text search for IDENTIFIER. 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) 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 current buffer." (and (fboundp 'evil-goto-definition) diff --git a/modules/tools/lookup/autoload/online.el b/modules/tools/lookup/autoload/online.el index 79908ec19..89f49e1e4 100644 --- a/modules/tools/lookup/autoload/online.el +++ b/modules/tools/lookup/autoload/online.el @@ -15,7 +15,7 @@ provider)))) ;;;###autoload -(defun +lookup-online-backend (identifier) +(defun +lookup-online-backend-fn (identifier) "Opens the browser and searches for IDENTIFIER online. Will prompt for which search engine to use the first time (or if the universal diff --git a/modules/tools/lookup/config.el b/modules/tools/lookup/config.el index 46349025d..f3e817ef5 100644 --- a/modules/tools/lookup/config.el +++ b/modules/tools/lookup/config.el @@ -33,10 +33,10 @@ produces an url. Used by `+lookup/online'.") "Function to use to open search urls.") (defvar +lookup-definition-functions - '(+lookup-xref-definitions-backend - +lookup-dumb-jump-backend - +lookup-project-search-backend - +lookup-evil-goto-definition-backend) + '(+lookup-xref-definitions-backend-fn + +lookup-dumb-jump-backend-fn + +lookup-project-search-backend-fn + +lookup-evil-goto-definition-backend-fn) "Functions for `+lookup/definition' to try, before resorting to `dumb-jump'. Stops at the first function to return non-nil or change the current window/point. @@ -47,8 +47,8 @@ argument: the identifier at point. See `set-lookup-handlers!' about adding to this list.") (defvar +lookup-references-functions - '(+lookup-xref-references-backend - +lookup-project-search-backend) + '(+lookup-xref-references-backend-fn + +lookup-project-search-backend-fn) "Functions for `+lookup/references' to try, before resorting to `dumb-jump'. Stops at the first function to return non-nil or change the current window/point. @@ -59,7 +59,7 @@ argument: the identifier at point. See `set-lookup-handlers!' about adding to this list.") (defvar +lookup-documentation-functions - '(+lookup-online-backend) + '(+lookup-online-backend-fn) "Functions for `+lookup/documentation' to try, before resorting to `dumb-jump'. Stops at the first function to return non-nil or change the current window/point. @@ -108,10 +108,10 @@ this list.") ;; xref to be one too. (remove-hook 'xref-backend-functions #'etags--xref-backend) ;; ...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))) (funcall orig-fn))) - (advice-add #'projectile-find-tag :around #'+lookup*projectile-find-tag) ;; Use `better-jumper' instead of xref's marker stack (advice-add #'xref-push-marker-stack :around #'doom-set-jump-a) @@ -133,7 +133,7 @@ this list.") (def-package! dash-docs :when (featurep! +docsets) :init - (add-hook '+lookup-documentation-functions #'+lookup-dash-docsets-backend) + (add-hook '+lookup-documentation-functions #'+lookup-dash-docsets-backend-fn) :config (setq dash-docs-enable-debugging doom-debug-mode 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 ;; lexical variable, which breaks `+lookup*fix-gnutls-error' (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, particularly, the `url-retrieve-synchronously' call in `dash-docs-read-json-from-url'. This is part of a systemic issue with Emacs 26's networking library (fixed in Emacs 27+, apparently). See https://github.com/magit/ghub/issues/81" + :around #'dash-docs-read-json-from-url (let ((gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")) (funcall orig-fn url))) - (advice-add #'dash-docs-read-json-from-url :around #'+lookup*fix-gnutls-error) (def-package! helm-dash :when (featurep! :completion helm))