Skip to content

Commit b4c8f96

Browse files
committed
Add inf-clojure-prompt-on-commands and closes #48
The patch introduces a way to globally disable prompting. It deletes `inf-clojure-prompt-when-set-ns`. Only apropos always prompts.
1 parent 3929054 commit b4c8f96

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
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): Add `Add inf-clojure-prompt-on-commands` to globally disable prompting on commands.
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.

inf-clojure.el

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,16 @@ This should usually be a combination of `inf-clojure-prompt' and
230230
`inf-clojure-subprompt'."
231231
:type 'regexp)
232232

233-
(defcustom inf-clojure-prompt-on-set-ns t
233+
(defcustom inf-clojure-prompt-on-commands t
234234
"Controls whether to prompt when switching namespace."
235235
:type '(choice (const :tag "always" t)
236-
(const :tag "never" nil)))
236+
(const :tag "never" nil))
237+
:safe 'booleanp)
238+
239+
(defun inf-clojure--should-prompt-on-commands (&optional invert)
240+
"Return the value of the variable `inf-clojure-prompt-on-commands'.
241+
Optionally invert the value, if INVERT is truthy."
242+
(if invert (not inf-clojure-prompt-on-commands) inf-clojure-prompt-on-commands))
237243

238244
(defcustom inf-clojure-repl-use-same-window nil
239245
"Controls whether to display the REPL buffer in the current window or not."
@@ -686,19 +692,24 @@ The value is nil if it can't find one."
686692
(defun inf-clojure-show-var-documentation (var)
687693
"Send a form to the inferior Clojure to give documentation for VAR.
688694
See function `inf-clojure-var-doc-form'."
689-
(interactive (inf-clojure-symprompt "Var doc" (inf-clojure-var-at-pt)))
690-
(comint-proc-query (inf-clojure-proc) (format (inf-clojure-var-doc-form) var)))
695+
(interactive "P")
696+
(let ((var (if (inf-clojure--should-prompt-on-commands var)
697+
(inf-clojure-symprompt "Var doc" (inf-clojure-var-at-pt))
698+
(inf-clojure-var-at-pt))))
699+
(comint-proc-query (inf-clojure-proc) (format (inf-clojure-var-doc-form) var))))
691700

692701
(defun inf-clojure-show-var-source (var)
693-
"Send a form to the inferior Clojure to give source for VAR.
694-
See variable `inf-clojure-var-source-form'."
695-
(interactive (inf-clojure-symprompt "Var source" (inf-clojure-var-at-pt)))
696-
(comint-proc-query (inf-clojure-proc) (format inf-clojure-var-source-form var)))
702+
"Send a command to the inferior Clojure to give source for VAR.
703+
See variable `inf-clojure-var-source-command'."
704+
(interactive "P")
705+
(let ((var (if (inf-clojure--should-prompt-on-commands var)
706+
(inf-clojure-symprompt "Var source" (inf-clojure-var-at-pt))
707+
(inf-clojure-var-at-pt))))
708+
(comint-proc-query (inf-clojure-proc) (format inf-clojure-var-source-form var))))
697709

698710
(defun inf-clojure-arglist (fn)
699711
"Send a query to the inferior Clojure for the arglist for function FN.
700712
See variable `inf-clojure-arglist-form'."
701-
(interactive (inf-clojure-symprompt "Arglist" (inf-clojure-fn-called-at-pt)))
702713
(let* ((proc (inf-clojure-proc))
703714
(comint-filt (process-filter proc))
704715
(kept "")
@@ -709,34 +720,40 @@ See variable `inf-clojure-arglist-form'."
709720
(process-send-string proc eldoc-snippet)
710721
(while (and (not (string-match inf-clojure-prompt kept))
711722
(accept-process-output proc 2)))
712-
(setq eldoc (and (string-match "(.+)" kept) (match-string 0 kept)))
713-
)
723+
(setq eldoc (and (string-match "(.+)" kept) (match-string 0 kept))))
714724
(set-process-filter proc comint-filt))
715725
eldoc))
716726

717727
(defun inf-clojure-show-arglist (fn)
718728
"Show the arglist for function FN in the mini-buffer."
719-
(interactive (inf-clojure-symprompt "Arglist" (inf-clojure-fn-called-at-pt)))
720-
(let ((eldoc (inf-clojure-arglist fn)))
729+
(interactive "P")
730+
(let* ((fn (if (inf-clojure--should-prompt-on-commands fn)
731+
(inf-clojure-symprompt "Arglist" (inf-clojure-fn-called-at-pt))
732+
(inf-clojure-fn-called-at-pt)))
733+
(eldoc (inf-clojure-arglist fn)))
721734
(when eldoc
722735
(message "%s: %s" fn eldoc))))
723736

724737
(defun inf-clojure-show-ns-vars (ns)
725738
"Send a query to the inferior Clojure for the public vars in NS.
726739
See variable `inf-clojure-ns-vars-form'."
727-
(interactive (inf-clojure-symprompt "Ns vars" (clojure-find-ns)))
728-
(comint-proc-query (inf-clojure-proc) (format inf-clojure-ns-vars-form ns)))
740+
(interactive "P")
741+
(let ((ns (if (inf-clojure--should-prompt-on-commands ns)
742+
(inf-clojure-symprompt "Ns vars" (clojure-find-ns))
743+
(clojure-find-ns))))
744+
(comint-proc-query (inf-clojure-proc) (format inf-clojure-ns-vars-form ns))))
729745

730746
(defun inf-clojure-set-ns (ns)
731747
"Set the ns of the inferior Clojure process to NS.
732748
Defaults to the ns of the current buffer, always prompting before
733749
setting, unless `inf-clojure-prompt-on-set-ns` is nil."
734-
(interactive (list (if inf-clojure-prompt-on-set-ns
735-
(inf-clojure-symprompt "Set ns to" (clojure-find-ns))
736-
(clojure-find-ns))))
737-
(when (or (not ns) (equal ns ""))
738-
(user-error "No namespace selected"))
739-
(comint-proc-query (inf-clojure-proc) (format inf-clojure-set-ns-form ns)))
750+
(interactive "P")
751+
(let ((ns (if (inf-clojure--should-prompt-on-commands ns)
752+
(inf-clojure-symprompt "Set ns to" (clojure-find-ns))
753+
(clojure-find-ns))))
754+
(when (or (not ns) (equal ns ""))
755+
(user-error "No namespace selected"))
756+
(comint-proc-query (inf-clojure-proc) (format inf-clojure-set-ns-form ns))))
740757

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

0 commit comments

Comments
 (0)