Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vspinu committed Aug 2, 2017
1 parent 5807f2b commit 6a47ee4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
34 changes: 20 additions & 14 deletions cider-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
(require 'cider-common)
(require 'cider-util)
(require 'clojure-mode)

(require 'subr-x)
(require 'cider-compat)
(require 'seq)
Expand Down Expand Up @@ -99,7 +98,7 @@ An error is signaled in the absence of a connection."
(delq buffer (cider-get-connection conn))))

(defun cider-add-connection-repl (conn buffer)
"Add a CONS's BUFFER to `cider-connection-alist'."
"Add REPL BUFFER for connection CONN to `cider-connection-alist'."
(if-let ((conn1 (cider-get-connection conn)))
(setcdr conn1 (cons buffer (delq buffer (cdr conn1))))
(setq cider-connection-alist
Expand All @@ -114,6 +113,7 @@ If CONN is not a string, just return it."
conn))

(defun cider-make-connection-name (&optional project-dir)
"Given PROJECT-DIR make a unique name for a connection."
(let* ((dir (or project-dir
(clojure-project-dir (cider-current-dir))
default-directory))
Expand Down Expand Up @@ -171,10 +171,15 @@ Also close associated REPL and server buffers."
(mapcar #'cider--close-connection-buffer
(cdr (cider-get-connection conn)))))

(defvar-local cider-connection-created-with 'jack-in
"Save how the connection was created.
Its value can be either 'jack-in or 'connect.")

(declare-function cider-jack-in "cider.el")
(defun cider--restart-connection-buffer (buff)
"Restart connection's buffer BUFF."
(let ((project-dir (with-current-buffer buff nrepl-project-dir))
(buf-name (buffer-name conn))
(buf-name (buffer-name buff))
;; save these variables before we kill the connection
(conn-creation-method (with-current-buffer buff cider-connection-created-with))
(conn-endpoint (with-current-buffer buff nrepl-endpoint)))
Expand Down Expand Up @@ -236,7 +241,7 @@ directory. When not in a project, return nil."
(apply #'append (mapcar #'cdr (cider-project-connections project-directory))))

(defun cider-project-connections-types (&optional project-directory)
"Return a list of types of connections within current project."
"Return a list of types of connections within PROJECT-DIRECTORY."
(let ((buffers (cider-project-connections-repls project-directory)))
(seq-uniq (seq-map #'cider--connection-type buffers))))

Expand All @@ -256,8 +261,9 @@ directory. When not in a project, return nil."
(cons match conn))))

(defun cider-current-connection (&optional ask-user)
"Get current connection.
Ask the user for association in ambiguous cases."
"Get the current connection.
When ASK-USER is non-nil, ask the user for association in ambiguous cases.
Return nil otherwise."
(when-let ((connections (cider-connections)))
(or
;; 1) Buffer Local Association
Expand All @@ -283,7 +289,7 @@ Ask the user for association in ambiguous cases."

(defun cider-current-connection-repls (&optional type)
"Get all REPL buffers of the current connection.
If TYPE is non-nil, return only REPL buffers of TYPE. TYPE can be either
If TYPE is non-nil, return only REPL buffers of TYPE. TYPE can be either
\"clj\" or \"cljs\"."
(let ((conn (cider-current-connection))
(right-type-p (lambda (b)
Expand All @@ -306,7 +312,7 @@ recently used one."
(seq-find (lambda (b) (member b buffs)) (buffer-list))))

(defun cider-other-repl (&optional repl)
"Return the first connection of another type than CONNECTION."
"Return the first connection of another type than that of REPL."
(when-let ((repl (or repl (cider-current-connection-repl)))
(type (cider--connection-type repl)))
;; FIXME: this logic beaks with more than 2 REPLs per connection
Expand All @@ -325,7 +331,7 @@ recently used one."
;;; Connection Associations

(defun cider-assoc-buffer-with-connection (&optional buffer connection)
"Associate the current buffer with CONNECTION.
"Associate the current BUFFER with CONNECTION.
Useful for connections created using `cider-connect', as for them such a
link cannot be established automatically."
(interactive)
Expand Down Expand Up @@ -360,13 +366,13 @@ Else, if current buffer has a physical file, associate with current
directory. Else, associate with current buffer."
(interactive)
(if cider-connection-name
(cider-assoc-buffer-with-connection)
(cider-assoc-buffer-with-connection nil connection)
(if-let ((project-dir (clojure-project-dir (cider-current-dir))))
(if-let ((dir (car (cider--connected-dir))))
(if (not (string= dir project-dir))
(cider-assoc-directory-with-connection default-directory)
(cider-assoc-project-with-connection project-dir))
(cider-assoc-project-with-connection project-dir))
(cider-assoc-directory-with-connection default-directory connection)
(cider-assoc-project-with-connection project-dir connection))
(cider-assoc-project-with-connection project-dir connection))
(if (buffer-file-name)
(cider-assoc-directory-with-connection default-directory)
(cider-assoc-buffer-with-connection)))))
Expand Down Expand Up @@ -589,7 +595,7 @@ will return nil instead of \"user\"."

(defun cider-expected-ns (&optional path)
"Return the namespace string matching PATH, or nil if not found.
PATH is expected to be an absolute file path. If PATH is nil, use the path
PATH is expected to be an absolute file path. If PATH is nil, use the path
to the file backing the current buffer. The command falls back to
`clojure-expected-ns' in the absence of an active connection."
(if (cider-connected-p)
Expand Down
6 changes: 1 addition & 5 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,6 @@ namespace-qualified function of zero arity."
map)
"Minibuffer keymap used for reading Clojure expressions.")

(defvar-local cider-connection-created-with 'jack-in
"Save how the connection was created.
Its value can be either 'jack-in or 'connect.")

(defun cider-read-from-minibuffer (prompt &optional value)
"Read a string from the minibuffer, prompting with PROMPT.
If VALUE is non-nil, it is inserted into the minibuffer as initial-input.
Expand Down Expand Up @@ -1753,7 +1749,7 @@ and all ancillary CIDER buffers."
(cider-ensure-connected)
(if (and quit-all (y-or-n-p "Are you sure you want to quit all CIDER connections? "))
(progn
(mapcar #'cider--quit-connection cider-connection-alist)
(mapc #'cider--quit-connection cider-connection-alist)
(message "All active nREPL connections were closed"))
(let ((conn (cider-current-connection)))
(when (y-or-n-p (format "Are you sure you want to quit the current CIDER connection %s? "
Expand Down
4 changes: 3 additions & 1 deletion cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ via `cider-current-connection-repl'.")

(defun cider-repl-create (endpoint repl-buffer connection-name)
"Create a REPL buffer and install `cider-repl-mode'.
ENDPOINT is a plist as returned by `nrepl-connect'."
ENDPOINT is a plist as returned by `nrepl-connect'. REPL-BUFFER is a
placeholder buffer to be used as REPL. CONNECTION-NAME is the connection
of which this REPL is part of."
;; Connection might not have been set as yet. Please don't send requests here.
(let* ((dup-ok (and repl-buffer
(not (eq 'new repl-buffer))))
Expand Down
4 changes: 2 additions & 2 deletions cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ own buffer."
(if (y-or-n-p "Are you sure you want to run `cider-jack-in' without a Clojure project? ")
default-directory
(signal 'quit nil)))
(user-error "`cider-jack-in' is not allowed without a Clojure project")))
(t (user-error "`cider-jack-in' is not allowed without a Clojure project"))))
(params (if prompt-project
(read-string (format "nREPL server command: %s "
command-params)
Expand Down Expand Up @@ -648,7 +648,7 @@ start the server."
;;;###autoload
(defun cider-connect (host port &optional project-dir)
"Connect to an nREPL server identified by HOST and PORT.
Create REPL buffer and start an nREPL client connection. When the optional
Create REPL buffer and start an nREPL client connection. When the optional
param PROJECT-DIR is present, the connection gets associated with it."
(interactive (cider-select-endpoint))
(setq cider-current-clojure-buffer (current-buffer))
Expand Down
1 change: 1 addition & 0 deletions nrepl-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
(require 'seq)
(require 'subr-x)
(require 'cider-compat)
(require 'cider-popup)
(require 'cl-lib)
(require 'nrepl-dict)
(require 'queue)
Expand Down
1 change: 1 addition & 0 deletions test/cider-bytecomp-warnings.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

(setq load-prefer-newer t)
(add-to-list 'load-path (expand-file-name "./"))
(add-to-list 'load-path (expand-file-name "./utils/"))
(require 'package)
(package-generate-autoloads 'cider default-directory)
(package-initialize)
Expand Down

0 comments on commit 6a47ee4

Please sign in to comment.