@@ -649,11 +649,15 @@ not found."
649
649
(file (cadr (assoc " file" info))))
650
650
(cider-find-file file)))
651
651
652
- (defun cider-jump-to (buffer &optional pos )
652
+ (defun cider-jump-to (buffer &optional pos other-buffer )
653
653
" Push current point onto marker ring, and jump to BUFFER to position POS.
654
654
POS can be either a cons cell (LINE . COLUMN) or a number representing the
655
- character position in a buffer. "
655
+ character position in a buffer. If OTHER-BUFFER is non-nil use
656
+ `pop-to-buffer' to jump to the location, otherwise `switch-to-buffer' ."
656
657
(ring-insert find-tag-marker-ring (point-marker ))
658
+ (if other-buffer
659
+ (pop-to-buffer buffer)
660
+ (switch-to-buffer buffer))
657
661
(with-current-buffer buffer
658
662
(widen )
659
663
; ; check if we have a (line . column) pair or just a buffer position
@@ -664,8 +668,7 @@ character position in a buffer. "
664
668
(if (cdr pos)
665
669
(move-to-column (cdr pos))
666
670
(back-to-indentation )))
667
- (cider-mode +1 ))
668
- (switch-to-buffer buffer))
671
+ (cider-mode +1 )))
669
672
670
673
(defun cider-jump-to-resource (path &optional line )
671
674
" Jump to the resource at the relative PATH, optionally at a specific LINE.
@@ -679,24 +682,34 @@ When called interactively, this operates on point."
679
682
(cider-jump-to buffer (cons line nil ))
680
683
(message " Cannot find resource %s " path)))
681
684
682
- (defun cider-jump-to-var (var &optional line )
683
- " Jump to the definition of VAR, optionally at a specific LINE.
684
- When called interactively, this operates on point, or falls back to a prompt."
685
- (interactive (list (cider-read-symbol-name " Symbol: " 'identity )))
686
- (cider-ensure-op-supported " info" )
687
- (-if-let (info (cider-var-info var))
688
- (-if-let* ((file (cadr (assoc " file" info)))
689
- (line (or line (cadr (assoc " line" info))))
690
- (buffer (cider-find-file file)))
691
- (cider-jump-to buffer (cons line nil ))
685
+ (defun cider--jump-to-loc-from-info (info &optional other-buffer )
686
+ " Jump to location give by INFO.
687
+ INFO object is returned by `cider-var-info' or `cider-member-info' .
688
+ OTHER-BUFFER is passed to `cider-jamp-to' ."
689
+ (-if-let* ((file (cadr (assoc " file" info)))
690
+ (line (cadr (assoc " line" info)))
691
+ (buffer (cider-find-file file)))
692
+ (cider-jump-to buffer (cons line nil ) other-buffer)
692
693
; ; var was created interactively and has no file info
693
694
(-if-let* ((ns (cadr (assoc " ns" info)))
694
695
(name (cadr (assoc " name" info)))
695
696
(buffer (cider-find-buffer ns))
696
- (pos (cider-locate-def buffer name)))
697
- (cider-jump-to buffer pos)
698
- (message " No source available for %s " var)))
699
- (message " Symbol %s not resolved " var)))
697
+ (pos (cider-locate-def name buffer line)))
698
+ (cider-jump-to buffer pos other-buffer)
699
+ (-if-let (name (cadr (assoc " name" info)))
700
+ (message " No location found for %s " name)
701
+ (message " No source info " )))))
702
+
703
+ (defun cider-jump-to-var (&optional var line )
704
+ " Jump to the definition of VAR, optionally at a specific LINE.
705
+ When called interactively, this operates on point, or falls back to a prompt."
706
+ (interactive )
707
+ (cider-ensure-op-supported " info" )
708
+ (cider-read-symbol-name
709
+ " Symbol: " (lambda (var )
710
+ (-if-let (info (cider-var-info var))
711
+ (cider--jump-to-loc-from-info info)
712
+ (message " Symbol %s not resolved " var)))))
700
713
701
714
(define-obsolete-function-alias 'cider-jump 'cider-jump-to-var " 0.7.0" )
702
715
(defalias 'cider-jump-back 'pop-tag-mark )
0 commit comments