Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 082c076

Browse filesBrowse 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 d265232 commit 082c076
Copy full SHA for 082c076

File tree

Expand file treeCollapse file tree

3 files changed

+48
-35
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+48
-35
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines 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.

‎README.md

Copy file name to clipboardExpand all lines: README.md
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ 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+
Every REPL command prompts by default, but with a prefix arg you can disable prompting (for instance: `C-u C-c C-v` will show the docstring of the var at point.
74+
This behavior is flipped when `inf-clojure-prompt-on-commands` is set to `nil`.
75+
7376
## REPL Type
7477

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

‎inf-clojure.el

Copy file name to clipboardExpand all lines: inf-clojure.el
+44-34Lines changed: 44 additions & 34 deletions
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', with non-nil
722+
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', with non-nil
732+
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,43 @@ 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', with non-nil
759+
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', with non-nil
771+
PROMPT-FOR-NS it prompts for a symbol 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.
771780
Defaults to the ns of the current buffer, always prompting before
772781
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)))
782+
(interactive "P")
783+
(let ((ns-at-pt (if (inf-clojure--prompt-on-commands-p ns)
784+
(car (inf-clojure-symprompt "Set ns to" (clojure-find-ns)))
785+
(clojure-find-ns))))
786+
(when (or (not ns-at-pt) (equal ns-at-pt ""))
787+
(user-error "No namespace selected"))
788+
(comint-proc-query (inf-clojure-proc) (format inf-clojure-set-ns-form ns-at-pt))))
779789

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.