cider icon indicating copy to clipboard operation
cider copied to clipboard

CIDER session is lost when navigating to definition

Open mmontone opened this issue 3 years ago • 0 comments

Hi,

when navigating to a definition via xref-find-definition (M-.), if the target buffer is not part of the Clojure project I'm in, the buffer is 'unlinked', and so I cannot continue navigating or evaluate Clojure code in the new buffer, unless I manually link it with sesman-link-buffer.

So, I've added this to my .emacs, that propagates the current CIDER session to the definition buffer:

(defun cider--xref-show-definitions-buffer (fetcher alist)
  "Propagate the CIDER session to the definitions buffer."
  (let ((session (sesman-current-session 'CIDER)))
    (xref-show-definitions-buffer fetcher alist)
    (sesman-link-with-buffer nil session)))

(add-hook 'cider-mode-hook
	  (lambda ()
	    (setq-local xref-show-definitions-function 'cider--xref-show-definitions-buffer)))

Not sure if this is the best fix, but it does the job for me.

mmontone avatar Sep 21 '22 23:09 mmontone