Skip to content

Commit b3d4e1e

Browse files
committed
Merge pull request #517 from jonpither/removing-ido
Removing references to IDO.
2 parents 3e3120e + 8b446f3 commit b3d4e1e

File tree

5 files changed

+55
-45
lines changed

5 files changed

+55
-45
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ visually distinctive from `cider-repl-output-face` (used for STDOUT output).
2222

2323
### Changes
2424

25+
* [#513](https://github.com/clojure-emacs/cider/issues/513)
26+
Remove hardcoded use of IDO mode and use `completing-read`.
2527
* Required Emacs version is now 24.1.
2628
* [#486](https://github.com/clojure-emacs/cider/issues/486) Improve
2729
support for tramp, so tramp paths do not get used in compiled debug
@@ -31,6 +33,8 @@ visually distinctive from `cider-repl-output-face` (used for STDOUT output).
3133

3234
### Bugs fixed
3335

36+
* [#515](https://github.com/clojure-emacs/cider/issues/515) Fix
37+
inconsistent prompt used for load symbol functions.
3438
* [#501](https://github.com/clojure-emacs/cider/issues/501) Fix
3539
nil appearing in nrepl-server buffer name when no project directory.
3640
* [#493](https://github.com/clojure-emacs/cider/issues/493) Fix rotate connection to handle no

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ You can certainly use `CIDER` without configuring it any further,
137137
but here are some ways other folks are adjusting their `CIDER`
138138
experience.
139139

140+
Using a completion system such as `IDO` will enhance certain `CIDER`
141+
functionality. If you are using `IDO`, be sure to use both `ido-everywhere`
142+
and [`ido-ubiquitous`](https://github.com/technomancy/ido-ubiquitous).
143+
140144
* Enable `eldoc` in Clojure buffers:
141145

142146
```el
@@ -268,10 +272,10 @@ underlying project directories:
268272
(setq cider-switch-to-repl-command 'cider-switch-to-current-repl-buffer)
269273
```
270274

271-
* You can configure known endpoints used by the cider command. This is useful if you
272-
have a list of common host/ports you want to establish remote nREPL connections to.
273-
Using an optional label is helpful for identifying each host.
274-
If you want to bypass IDO selection of an endpoint, use <kbd>C-j</kbd>.
275+
* You can configure known endpoints used by the cider command offered via a
276+
completing read. This is useful if you have a list of common host/ports you
277+
want to establish remote nREPL connections to. Using an optional label is
278+
helpful for identifying each host.
275279

276280
```el
277281
(setq cider-known-endpoints '(("host-a" "10.10.10.1" "7888") ("host-b" "7888")))
@@ -495,7 +499,7 @@ Keyboard shortcut | Description
495499
<kbd>C-c C-d</kbd> | Display doc string for the symbol at point. If invoked with a prefix argument, or no symbol is found at point, prompt for a symbol
496500
<kbd>C-c C-j</kbd> | Display JavaDoc (in your default browser) for the symbol at point. If invoked with a prefix argument, or no symbol is found at point, prompt for a symbol.
497501
<kbd>C-c C-z</kbd> | Switch to the previous Clojure buffer. This complements <kbd>C-c C-z</kbd> used in cider-mode.
498-
<kbd>C-c M-f</kbd> | Select a function from the current namespace using `ido` and insert into the REPL buffer.
502+
<kbd>C-c M-f</kbd> | Select a function from the current namespace and insert into the REPL buffer.
499503
<kbd>C-c M-i</kbd> | Inspect expression. Will act on expression at point if present.
500504
<kbd>C-c M-n</kbd> | Select a namespace and switch to it.
501505

cider-interaction.el

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ With a prefix ARG sets the namespace in the REPL buffer to that
270270
of the namespace in the Clojure source buffer.
271271
272272
With a second prefix ARG the chosen REPL buffer is based on a
273-
supplied project directory using IDO."
273+
supplied project directory."
274274
(interactive "p")
275275
(cider-ensure-connected)
276276
(let* ((project-directory
277-
(or (when (eq 16 arg) (ido-read-directory-name "Project: "))
277+
(or (when (eq 16 arg) (read-directory-name "Project: "))
278278
(nrepl-project-directory-for (nrepl-current-dir))))
279279
(connection-buffer
280280
(or
@@ -1173,8 +1173,8 @@ See command `cider-mode'."
11731173
(unless (cider-connected-p)
11741174
(cider-disable-on-existing-clojure-buffers)))
11751175

1176-
(defun cider-ido-form (ns)
1177-
"Construct a Clojure form for ido read using NS."
1176+
(defun cider-fetch-vars-form (ns)
1177+
"Construct a Clojure form to read vars inside for NS."
11781178
`(concat (if (find-ns (symbol ,ns))
11791179
(map name (concat (keys (ns-interns (symbol ,ns)))
11801180
(keys (ns-refers (symbol ,ns))))))
@@ -1189,51 +1189,54 @@ See command `cider-mode'."
11891189
(map (fn [n] (str n "/")))
11901190
(into (hash-set)))))
11911191

1192-
(defun cider-ido-up-ns (ns)
1193-
"Perform up using NS."
1192+
(defun cider-parent-ns (ns)
1193+
"Go up a level of NS.
1194+
For example \"foo.bar.tar\" -> \"foo.bar\"."
11941195
(mapconcat 'identity (butlast (split-string ns "\\.")) "."))
11951196

1196-
(defun cider-ido-var-select (prompt ido-callback cider-ido-ns selected targets)
1197-
"Peform ido select using SELECTED and TARGETS.
1197+
(defun cider-completing-read-var-select (prompt callback ns selected targets)
1198+
"Peform completing read using SELECTED and TARGETS.
11981199
If SELECTED is \"..\" then another selection is made for vars in the parent namespace of
1199-
CIDER-IDO-NS using PROMPT.
1200+
NS using PROMPT.
12001201
If SELECTED is a namespace then another selection is made against that namespace
12011202
using PROMPT.
1202-
Once a selecton is made IDO-CALLBACK is called with SELECTED."
1203+
Once a selecton is made CALLBACK is called with SELECTED."
12031204
;; TODO: immediate RET gives "" as selected for some reason
12041205
;; this is an OK workaround though
12051206
(cond ((equal "" selected)
1206-
(cider-ido-var-select prompt ido-callback cider-ido-ns (car targets) targets))
1207+
(cider-completing-read-var-select prompt callback ns (car targets) targets))
12071208
((equal "/" (substring selected -1)) ; selected a namespace
1208-
(cider-ido-read-var prompt (substring selected 0 -1) ido-callback))
1209+
(cider-completing-read-var prompt (substring selected 0 -1) callback))
12091210
((equal ".." selected)
1210-
(cider-ido-read-var prompt (cider-ido-up-ns cider-ido-ns) ido-callback))
1211+
(cider-completing-read-var prompt (cider-parent-ns ns) callback))
12111212
;; non ido variable selection techniques don't return qualified symbols, so this shouldn't either
1212-
(t (funcall ido-callback selected))))
1213+
(t (funcall callback selected))))
12131214

1214-
(defun cider-ido-read-sym-handler (label ido-select buffer)
1215-
"Create an ido read var handler with IDO-SELECT for BUFFER."
1215+
(defun cider-completing-read-sym-handler (label completing-read-callback buffer)
1216+
"Create an nrepl response handler for BUFFER.
1217+
The handler will parse the response from nrepl to create targets for a completing read.
1218+
The result of the completing read will be passed to COMPLETING-READ-CALLBACK."
12161219
(nrepl-make-response-handler buffer
12171220
(lambda (buffer value)
12181221
;; make sure to eval the callback in the buffer that the symbol was requested from so we get the right namespace
12191222
(with-current-buffer buffer
12201223
(let* ((targets (car (read-from-string value)))
1221-
(selected (ido-completing-read label targets nil t)))
1222-
(funcall ido-select selected targets))))
1224+
(selected (completing-read label targets nil t)))
1225+
(funcall completing-read-callback selected targets))))
12231226
nil nil nil))
12241227

1225-
(defun cider-ido-read-sym-form (label form callback)
1228+
(defun cider-completing-read-sym-form (label form callback)
12261229
"Eval the FORM and pass the result to the response handler."
1227-
(cider-tooling-eval form (cider-ido-read-sym-handler label callback (current-buffer))
1230+
(cider-tooling-eval form (cider-completing-read-sym-handler label callback (current-buffer))
12281231
nrepl-buffer-ns))
12291232

1230-
(defun cider-ido-read-var (prompt ns ido-callback)
1231-
"Perform ido read var in NS using IDO-CALLBACK."
1232-
(cider-ido-read-sym-form prompt (prin1-to-string (cider-ido-form ns))
1233+
(defun cider-completing-read-var (prompt ns callback)
1234+
"Perform completing read var in NS using CALLBACK."
1235+
(cider-completing-read-sym-form prompt (prin1-to-string (cider-fetch-vars-form ns))
12331236
(lambda (selected targets)
1234-
(cider-ido-var-select prompt ido-callback ns selected targets))))
1237+
(cider-completing-read-var-select prompt callback ns selected targets))))
12351238

1236-
(defun cider-ido-fns-form (ns)
1239+
(defun cider-fetch-fns-form (ns)
12371240
"Construct a Clojure form for reading fns using supplied NS."
12381241
(format "(let [fn-pred (fn [[k v]] (and (fn? (.get v))
12391242
(not (re-find #\"clojure.\" (str v)))))]
@@ -1245,27 +1248,26 @@ Once a selecton is made IDO-CALLBACK is called with SELECTED."
12451248
(ns-refers '%s))))))" ns ns))
12461249

12471250
(defun cider-load-fn-into-repl-buffer ()
1248-
"Browse functions available in current repl buffer using ido.
1251+
"Browse functions available in current repl buffer.
12491252
Once selected, the name of the fn will appear in the repl buffer in parens
12501253
ready to call."
12511254
(interactive)
1252-
(cider-ido-read-sym-form (format "Fn: %s/" nrepl-buffer-ns)
1253-
(cider-ido-fns-form (cider-current-ns))
1254-
(lambda (f _targets)
1255-
(with-current-buffer (cider-current-repl-buffer)
1256-
(cider-repl--replace-input (format "(%s)" f))
1257-
(goto-char (- (point-max) 1))))))
1255+
(cider-completing-read-sym-form (format "Fn: %s/" nrepl-buffer-ns)
1256+
(cider-fetch-fns-form (cider-current-ns))
1257+
(lambda (f _targets)
1258+
(with-current-buffer (cider-current-repl-buffer)
1259+
(cider-repl--replace-input (format "(%s)" f))
1260+
(goto-char (- (point-max) 1))))))
12581261

12591262
(defun cider-read-symbol-name (prompt callback &optional query)
12601263
"Either read a symbol name using PROMPT or choose the one at point.
1261-
Use CALLBACK as the ido read var callback.
1264+
Use CALLBACK as the completing read var callback.
12621265
The user is prompted with PROMPT if a prefix argument is in effect,
12631266
if there is no symbol at point, or if QUERY is non-nil."
12641267
(let ((symbol-name (cider-symbol-at-point)))
1265-
(cond ((not (or current-prefix-arg query (not symbol-name)))
1266-
(funcall callback symbol-name))
1267-
(ido-mode (cider-ido-read-var prompt nrepl-buffer-ns callback))
1268-
(t (funcall callback (read-from-minibuffer prompt symbol-name))))))
1268+
(if (not (or current-prefix-arg query (not symbol-name)))
1269+
(funcall callback symbol-name)
1270+
(cider-completing-read-var prompt nrepl-buffer-ns callback))))
12691271

12701272
(defun cider-doc-buffer-for (symbol)
12711273
"Return buffer with documentation for SYMBOL."

cider.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ start the server."
9393
(interactive "P")
9494
(setq cider-current-clojure-buffer (current-buffer))
9595
(let* ((project (when prompt-project
96-
(ido-read-directory-name "Project: ")))
96+
(read-directory-name "Project: ")))
9797
(project-dir (nrepl-project-directory-for
9898
(or project (nrepl-current-dir)))))
9999
(when (nrepl-check-for-repl-buffer nil project-dir)
@@ -126,7 +126,7 @@ A default will be included consisting of `nrepl-default-host' and
126126
"Select an endpoint from known endpoints.
127127
The returned endpoint has the label removed."
128128
(let ((selected-endpoint (split-string
129-
(ido-completing-read
129+
(completing-read
130130
"Host: " (cider-known-endpoint-candidates)))))
131131
(if (= 3 (length selected-endpoint))
132132
(cdr selected-endpoint)

test/cider-tests.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@
446446

447447
(ert-deftest test-cider-select-known-endpoint-remove-label ()
448448
(noflet ((cider-known-endpoint-candidates () '())
449-
(ido-completing-read (dontcare dontcare) "label host port"))
449+
(completing-read (dontcare dontcare) "label host port"))
450450
(should (equal '("host" "port") (cider-select-known-endpoint)))))
451451

452452
(ert-deftest test-cider-change-buffers-designation ()

0 commit comments

Comments
 (0)