Skip to content

Commit 6bc4195

Browse files
committed
Delete cider--ensure-session
nrepl-client now derives the session from the connection automatically. There was a bug because in some requests specified a connection different from the current one, but then ensure-session took the session from the current-connection.
1 parent 5de2e37 commit 6bc4195

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

cider-client.el

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,6 @@ Signal an error if it is not supported."
421421
(unless (cider-nrepl-op-supported-p op)
422422
(error "Can't find nREPL middleware providing op \"%s\". Please, install (or update) cider-nrepl %s and restart CIDER" op (upcase cider-version))))
423423

424-
(defun cider--ensure-session (request)
425-
"Make sure REQUEST has session.
426-
427-
If the nREPL request lacks a session `cider-current-session' is added."
428-
(if (seq-contains request "session")
429-
request
430-
(append request (list "session" (cider-current-session)))))
431-
432424
(defun cider-nrepl-send-request (request callback &optional connection)
433425
"Send REQUEST and register response handler CALLBACK.
434426
REQUEST is a pair list of the form (\"op\" \"operation\" \"par1-name\"
@@ -437,17 +429,16 @@ If CONNECTION is provided dispatch to that connection instead of
437429
the current connection.
438430
439431
Return the id of the sent message."
440-
(nrepl-send-request (cider--ensure-session request) callback
441-
(or connection (cider-current-connection))))
432+
(nrepl-send-request request callback (or connection (cider-current-connection))))
442433

443-
(defun cider-nrepl-send-sync-request (request &optional abort-on-input connection)
434+
(defun cider-nrepl-send-sync-request (request &optional connection abort-on-input)
444435
"Send REQUEST to the nREPL server synchronously.
445436
Hold till final \"done\" message has arrived and join all response messages
446437
of the same \"op\" that came along and return the accumulated response.
447438
If ABORT-ON-INPUT is non-nil, the function will return nil
448439
at the first sign of user input, so as not to hang the
449440
interface."
450-
(nrepl-send-sync-request (cider--ensure-session request)
441+
(nrepl-send-sync-request request
451442
(or connection (cider-current-connection))
452443
abort-on-input))
453444

nrepl-client.el

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -896,14 +896,17 @@ REQUEST is a pair list of the form (\"op\" \"operation\" \"par1-name\"
896896
\"par1\" ... ). See the code of `nrepl-request:clone',
897897
`nrepl-request:stdin', etc.
898898
Return the ID of the sent message."
899-
(let* ((id (nrepl-next-request-id connection))
900-
(request (cons 'dict (lax-plist-put request "id" id)))
901-
(message (nrepl-bencode request)))
902-
(nrepl-log-message request 'request)
903-
(with-current-buffer connection
899+
(with-current-buffer connection
900+
(unless (or (plist-get request "session")
901+
(not nrepl-session))
902+
(setq request (append request (list "session" nrepl-session))))
903+
(let* ((id (nrepl-next-request-id connection))
904+
(request (cons 'dict (lax-plist-put request "id" id)))
905+
(message (nrepl-bencode request)))
906+
(nrepl-log-message request 'request)
904907
(puthash id callback nrepl-pending-requests)
905-
(process-send-string nil message))
906-
id))
908+
(process-send-string nil message)
909+
id)))
907910

908911
(defvar nrepl-ongoing-sync-request nil
909912
"Dynamically bound to t while a sync request is ongoing.")
@@ -995,7 +998,7 @@ If LINE and COLUMN are non-nil and current buffer is a file buffer, \"line\",
995998
"line" line
996999
"column" column)))))
9971000

998-
(defun nrepl-request:eval (input callback connection session &optional ns line column)
1001+
(defun nrepl-request:eval (input callback connection &optional session ns line column)
9991002
"Send the request INPUT and register the CALLBACK as the response handler.
10001003
The request is dispatched via CONNECTION and SESSION. If NS is non-nil,
10011004
include it in the request. LINE and COLUMN, if non-nil, define the position

0 commit comments

Comments
 (0)