diff options
author | Bozhidar Batsov <bozhidar@batsov.com> | 2018-06-26 08:12:19 +0300 |
---|---|---|
committer | Bozhidar Batsov <bozhidar@batsov.com> | 2018-06-26 08:12:19 +0300 |
commit | 02dc4aca6077bc17752d762aa8aecc93c0b41b76 (patch) | |
tree | e839bd85b4d4487e66da0aa218821ae1b346a445 /cider-find.el | |
parent | d7d6821a80d149ba123d27e9e991fd2b9a7f11b4 (diff) |
Move the cider-find-var functionality to cider-find.el
Diffstat (limited to 'cider-find.el')
-rw-r--r-- | cider-find.el | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cider-find.el b/cider-find.el index a70461ae..739de9ab 100644 --- a/cider-find.el +++ b/cider-find.el @@ -31,6 +31,41 @@ (require 'thingatpt) +(defun cider--find-var-other-window (var &optional line) + "Find the definition of VAR, optionally at a specific LINE. + +Display the results in a different window." + (if-let* ((info (cider-var-info var))) + (progn + (if line (setq info (nrepl-dict-put info "line" line))) + (cider--jump-to-loc-from-info info t)) + (user-error "Symbol `%s' not resolved" var))) + +(defun cider--find-var (var &optional line) + "Find the definition of VAR, optionally at a specific LINE." + (if-let* ((info (cider-var-info var))) + (progn + (if line (setq info (nrepl-dict-put info "line" line))) + (cider--jump-to-loc-from-info info)) + (user-error "Symbol `%s' not resolved" var))) + +(defun cider-find-var (&optional arg var line) + "Find definition for VAR at LINE. +Prompt according to prefix ARG and `cider-prompt-for-symbol'. +A single or double prefix argument inverts the meaning of +`cider-prompt-for-symbol'. A prefix of `-` or a double prefix argument causes +the results to be displayed in a different window. The default value is +thing at point." + (interactive "P") + (cider-ensure-op-supported "info") + (if var + (cider--find-var var line) + (funcall (cider-prompt-for-symbol-function arg) + "Symbol" + (if (cider--open-other-window-p arg) + #'cider--find-var-other-window + #'cider--find-var)))) + (defun cider--find-dwim (symbol-file callback &optional other-window) "Find the SYMBOL-FILE at point. CALLBACK upon failure to invoke prompt if not prompted previously. |