@@ -1571,8 +1571,22 @@ otherwise fall back to \"user\"."
1571
1571
#'identity )
1572
1572
" Function to translate Emacs filenames to nREPL namestrings." )
1573
1573
1574
- (defvar-local cider--cached-ns-form nil
1575
- " Cached ns form in the current buffer." )
1574
+ (defvar-local cider--ns-form-cache (make-hash-table :test 'equal )
1575
+ " ns form cache for the current buffer.
1576
+
1577
+ The cache is a hash where the keys are connection names and the values
1578
+ are ns forms. This allows every connection to keep track of the ns
1579
+ form independently." )
1580
+
1581
+ (defun cider--cache-ns-form ()
1582
+ " Cache the form in the current buffer for the current connection."
1583
+ (puthash (nrepl-current-connection-buffer)
1584
+ (cider-ns-form)
1585
+ cider--ns-form-cache))
1586
+
1587
+ (defun cider--cached-ns-form ()
1588
+ " Retrieve the cached ns form for the current buffer & connection."
1589
+ (gethash (nrepl-current-connection-buffer) cider--ns-form-cache))
1576
1590
1577
1591
(defun cider--prep-interactive-eval (form )
1578
1592
" Prepares the environment for an interactive eval of FORM.
@@ -1586,12 +1600,12 @@ Clears any compilation highlights and kills the error window."
1586
1600
(cider--quit-error-window)
1587
1601
(let ((cur-ns-form (cider-ns-form)))
1588
1602
(when (and cur-ns-form
1589
- (not (string= cur-ns-form cider--cached-ns-form))
1603
+ (not (string= cur-ns-form ( cider--cached-ns-form) ))
1590
1604
(not (cider-ns-form-p form)))
1591
1605
; ; this should probably be done synchronously
1592
1606
; ; otherwise an errors in the ns form will go unnoticed
1593
1607
(cider-eval-ns-form)
1594
- (setq cider--cached-ns-form cur -ns-form))))
1608
+ (cider--cache -ns-form))))
1595
1609
1596
1610
(defun cider-interactive-eval (form &optional callback )
1597
1611
" Evaluate FORM and dispatch the response to CALLBACK.
@@ -1937,7 +1951,7 @@ unconditionally."
1937
1951
(buffer-file-name ))))))
1938
1952
(cider--clear-compilation-highlights)
1939
1953
(cider--quit-error-window)
1940
- (setq cider--cached -ns-form (cider-ns-form) )
1954
+ (cider--cache -ns-form)
1941
1955
(cider-request:load-file
1942
1956
(cider-file-string filename)
1943
1957
(funcall cider-to-nrepl-filename-function (cider--server-filename filename))
@@ -2102,7 +2116,7 @@ Quitting closes all active nREPL connections and kills all CIDER buffers."
2102
2116
; ; which connection we simply clean the cache for all buffers
2103
2117
(dolist (clojure-buffer (cider-util--clojure-buffers))
2104
2118
(with-current-buffer clojure-buffer
2105
- (setq cider--cached- ns-form nil )))))
2119
+ (setq cider--ns-form-cache ( make-hash-table :test 'equal ) )))))
2106
2120
2107
2121
(defun cider-restart (&optional prompt-project )
2108
2122
" Quit CIDER and restart it.
0 commit comments