Skip to content

Commit ee78b65

Browse files
committed
Commands don't prompt anymore by default closes #48
The patch makes so that the REPL commands don't prompt for things anymore (except for `inf-clojure-apropos`). For prompting, the user will need to pass a prefix argument to the command.
1 parent d265232 commit ee78b65

File tree

3 files changed

+52
-37
lines changed

3 files changed

+52
-37
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
### New Features
66

7+
* [#51](https://github.com/clojure-emacs/inf-clojure/pull/51): Commands do not prompt by default anymore, unless they receive a non-nil prefix argument.
78
* [#44](https://github.com/clojure-emacs/inf-clojure/pull/44): Add REPL types and Lumo support.
89
* [#50](https://github.com/clojure-emacs/inf-clojure/pull/50): Rename defcustoms to `inf-clojure-*-form` where appropriate.
910
* [#34](https://github.com/clojure-emacs/inf-clojure/pull/34): Add support for socket REPL connections.
10-
* [#46](https://github.com/clojure-emacs/inf-clojure/pull/46): Make it possible to disable prompt on `inf-clojure-set-ns`.
1111
* New interactive command `inf-clojure-display-version`.
1212
* [#42](https://github.com/clojure-emacs/inf-clojure/issues/42): Add a defcustom controlling the window in which the REPL buffer is displayed (`inf-clojure-repl-use-same-window`).
1313
* Font-lock the code in the REPL.

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ the default specified in `inf-clojure-program`.
7070
You can set custom values to `inf-clojure` variables on a per-project basis using [directory
7171
variables](https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html).
7272

73+
The REPL commands don't prompt by default but a prefix argument will invert
74+
this. For instance: `C-u C-c C-v` will ask for the symbol you want to show the
75+
docstring for.
76+
7377
## REPL Type
7478

7579
An `inf-clojure` REPL can be of different types: Clojure, ClojureScript, Lumo and Planck are all potentially valid options.

inf-clojure.el

+47-36
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,6 @@ This should usually be a combination of `inf-clojure-prompt' and
238238
`inf-clojure-subprompt'."
239239
:type 'regexp)
240240

241-
(defcustom inf-clojure-prompt-on-set-ns t
242-
"Controls whether to prompt when switching namespace."
243-
:type '(choice (const :tag "always" t)
244-
(const :tag "never" nil))
245-
:package-version '(inf-clojure . "2.0.0"))
246-
247241
(defcustom inf-clojure-repl-use-same-window nil
248242
"Controls whether to display the REPL buffer in the current window or not."
249243
:type '(choice (const :tag "same" t)
@@ -722,22 +716,29 @@ The value is nil if it can't find one."
722716
;;; Documentation functions: var doc and arglist.
723717
;;; ======================================================================
724718

725-
(defun inf-clojure-show-var-documentation (var)
719+
(defun inf-clojure-show-var-documentation (prompt-for-symbol)
726720
"Send a form to the inferior Clojure to give documentation for VAR.
727-
See function `inf-clojure-var-doc-form'."
728-
(interactive (inf-clojure-symprompt "Var doc" (inf-clojure-var-at-pt)))
729-
(comint-proc-query (inf-clojure-proc) (format (inf-clojure-var-doc-form) var)))
730-
731-
(defun inf-clojure-show-var-source (var)
732-
"Send a form to the inferior Clojure to give source for VAR.
733-
See variable `inf-clojure-var-source-form'."
734-
(interactive (inf-clojure-symprompt "Var source" (inf-clojure-var-at-pt)))
735-
(comint-proc-query (inf-clojure-proc) (format inf-clojure-var-source-form var)))
721+
See function `inf-clojure-var-doc-form'. When invoked with a
722+
prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
723+
(interactive "P")
724+
(let ((var (if prompt-for-symbol
725+
(car (inf-clojure-symprompt "Var doc" (inf-clojure-var-at-pt)))
726+
(inf-clojure-var-at-pt))))
727+
(comint-proc-query (inf-clojure-proc) (format (inf-clojure-var-doc-form) var))))
728+
729+
(defun inf-clojure-show-var-source (prompt-for-symbol)
730+
"Send a command to the inferior Clojure to give source for VAR.
731+
See variable `inf-clojure-var-source-form'. When invoked with a
732+
prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
733+
(interactive "P")
734+
(let ((var (if prompt-for-symbol
735+
(car (inf-clojure-symprompt "Var source" (inf-clojure-var-at-pt)))
736+
(inf-clojure-var-at-pt))))
737+
(comint-proc-query (inf-clojure-proc) (format inf-clojure-var-source-form var))))
736738

737739
(defun inf-clojure-arglist (fn)
738740
"Send a query to the inferior Clojure for the arglist for function FN.
739741
See variable `inf-clojure-arglist-form'."
740-
(interactive (inf-clojure-symprompt "Arglist" (inf-clojure-fn-called-at-pt)))
741742
(let* ((proc (inf-clojure-proc))
742743
(comint-filt (process-filter proc))
743744
(kept "")
@@ -748,34 +749,44 @@ See variable `inf-clojure-arglist-form'."
748749
(process-send-string proc eldoc-snippet)
749750
(while (and (not (string-match inf-clojure-prompt kept))
750751
(accept-process-output proc 2)))
751-
(setq eldoc (and (string-match "(.+)" kept) (match-string 0 kept)))
752-
)
752+
(setq eldoc (and (string-match "(.+)" kept) (match-string 0 kept))))
753753
(set-process-filter proc comint-filt))
754754
eldoc))
755755

756-
(defun inf-clojure-show-arglist (fn)
757-
"Show the arglist for function FN in the mini-buffer."
758-
(interactive (inf-clojure-symprompt "Arglist" (inf-clojure-fn-called-at-pt)))
759-
(let ((eldoc (inf-clojure-arglist fn)))
756+
(defun inf-clojure-show-arglist (prompt-for-symbol)
757+
"Show the arglist for function FN in the mini-buffer.
758+
See variable `inf-clojure-arglist-form'. When invoked with a
759+
prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
760+
(interactive "P")
761+
(let* ((fn (if prompt-for-symbol
762+
(car (inf-clojure-symprompt "Arglist" (inf-clojure-fn-called-at-pt)))
763+
(inf-clojure-fn-called-at-pt)))
764+
(eldoc (inf-clojure-arglist fn)))
760765
(when eldoc
761766
(message "%s: %s" fn eldoc))))
762767

763-
(defun inf-clojure-show-ns-vars (ns)
768+
(defun inf-clojure-show-ns-vars (prompt-for-ns)
764769
"Send a query to the inferior Clojure for the public vars in NS.
765-
See variable `inf-clojure-ns-vars-form'."
766-
(interactive (inf-clojure-symprompt "Ns vars" (clojure-find-ns)))
767-
(comint-proc-query (inf-clojure-proc) (format inf-clojure-ns-vars-form ns)))
770+
See variable `inf-clojure-ns-vars-form'. When invoked with a
771+
prefix argument PROMPT-FOR-NS, it prompts for a namespace name."
772+
(interactive "P")
773+
(let ((ns (if prompt-for-ns
774+
(car (inf-clojure-symprompt "Ns vars" (clojure-find-ns)))
775+
(clojure-find-ns))))
776+
(comint-proc-query (inf-clojure-proc) (format inf-clojure-ns-vars-form ns))))
768777

769-
(defun inf-clojure-set-ns (ns)
778+
(defun inf-clojure-set-ns (prompt-for-ns)
770779
"Set the ns of the inferior Clojure process to NS.
771-
Defaults to the ns of the current buffer, always prompting before
772-
setting, unless `inf-clojure-prompt-on-set-ns` is nil."
773-
(interactive (list (if inf-clojure-prompt-on-set-ns
774-
(inf-clojure-symprompt "Set ns to" (clojure-find-ns))
775-
(clojure-find-ns))))
776-
(when (or (not ns) (equal ns ""))
777-
(user-error "No namespace selected"))
778-
(comint-proc-query (inf-clojure-proc) (format inf-clojure-set-ns-form ns)))
780+
See variable `inf-clojure-set-ns-form`. It defaults to the ns of
781+
the current buffer. When invoked with a prefix argument
782+
PROMPT-FOR-NS, it prompts for a namespace name."
783+
(interactive "P")
784+
(let ((ns (if prompt-for-ns
785+
(car (inf-clojure-symprompt "Set ns to" (clojure-find-ns)))
786+
(clojure-find-ns))))
787+
(when (or (not ns) (equal ns ""))
788+
(user-error "No namespace selected"))
789+
(comint-proc-query (inf-clojure-proc) (format inf-clojure-set-ns-form ns))))
779790

780791
(defun inf-clojure-apropos (var)
781792
"Send a form to the inferior Clojure to give apropos for VAR.

0 commit comments

Comments
 (0)