From 5fc284788e59ea09e1aa6e37a1f2bd98cc322675 Mon Sep 17 00:00:00 2001 From: EricGebhart Date: Fri, 20 Mar 2015 12:27:32 -0400 Subject: [PATCH] [#1032] Combine jump-to-var and jump-to-resource into one function --- CHANGELOG.md | 2 ++ cider-interaction.el | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c05c3dabe..815929082 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ * [#958](https://github.com/clojure-emacs/cider/pull/958) Reuse existing repl buffers with dead processes. Users are now informed about existing zombie repl buffers and are offered the choice to reuse those for new connections. +* [#1032](https://github.com/clojure-emacs/cider/issues/1032) New function jump-to-resource-or-var + combines the functionality of jump-to-var and jump-to-resource. ### Changes diff --git a/cider-interaction.el b/cider-interaction.el index f5e1d353f..4064eceba 100644 --- a/cider-interaction.el +++ b/cider-interaction.el @@ -762,6 +762,32 @@ window." (when pos (goto-char pos))))) +(defun cider-jump-to-resource-or-var (symbol-file &optional other-window) + "Try to jump to the variable at point. + If variable is not found, try to jump to resource of the same name. +When called interactively, A prompt is given with a default value of +thing at point. If a prefix is given then the result is opened in 'other-window'. " + (interactive + (list (read-string "Jump to: " (thing-at-point 'filename) + nil (thing-at-point 'filename)) + current-prefix-arg)) + (-if-let (info (cider-var-info symbol-file)) + (cider--jump-to-loc-from-info info other-window) + (progn + (cider-ensure-op-supported "resource") + (-if-let* ((resource (cider-sync-request:resource symbol-file)) + (buffer (cider-find-file resource))) + (cider-jump-to buffer 0 other-window) + (message "Resource or variable %s not resolved" symbol-file))))) + +(defun cider-jump-to-resource-or-var-other-window (symbol-file) + "jump to var or resource at point, place results in other window." + (interactive + (list (read-string "Jump to: " (thing-at-point 'filename) + nil (thing-at-point 'filename)))) + (cider-jump-to-resource-or-var symbol-file t)) + + (defun cider-jump-to-resource (path) "Jump to the resource at the resource-relative PATH. When called interactively, this operates on point."