@@ -179,9 +179,6 @@ either `setq-local` or an entry in `.dir-locals.el`." )
179
179
(defvar-local inf-clojure-repl-name nil
180
180
" When creating a REPL, set the name to be given to the buffer it's output is sent to." )
181
181
182
- (defvar inf-clojure-cljs-buffer nil
183
- " The current `inf-clojure' process buffer with repl-type `cljs' " )
184
-
185
182
(defvar inf-clojure-buffer nil
186
183
" The current `inf-clojure' process buffer.
187
184
@@ -218,11 +215,6 @@ one process, this does the right thing. If you run multiple
218
215
processes, you might need to change `inf-clojure-buffer' to
219
216
whichever process buffer you want to use." )
220
217
221
- (defun inf-clojure--get-buffer ()
222
- (if (eq major-mode 'clojurescript-mode )
223
- inf-clojure-cljs-buffer
224
- inf-clojure-buffer))
225
-
226
218
(defun inf-clojure--get-feature (repl-type feature no-error )
227
219
" Get FEATURE for REPL-TYPE from repl-features.
228
220
If no-error is truthy don't error if feature is not present."
@@ -264,13 +256,9 @@ When NO-ERROR is non-nil, don't throw an error when no process
264
256
has been found. See also variable `inf-clojure-buffer' ."
265
257
(or (get-buffer-process (if (derived-mode-p 'inf-clojure-mode )
266
258
(current-buffer )
267
- ( inf-clojure--get- buffer) ))
259
+ inf-clojure-buffer))
268
260
(unless no-error
269
- (let ((subprocess-type (if (eq major-mode 'clojurescript-mode )
270
- " Clojurescript" " Clojure" ))
271
- (buffer-name (if (eq major-mode 'clojurescript-mode )
272
- " inf-clojure-cljs-buffer" " inf-clojure-buffer" )))
273
- (error " No %s subprocess; see variable `%s' " subprocess-type buffer-name)))))
261
+ (error " No Clojure subprocess; see variable `inf-clojure-buffer' " ))))
274
262
275
263
(defun inf-clojure-repl-p (&optional buf )
276
264
" Indicates if BUF is an inf-clojure REPL.
@@ -311,9 +299,7 @@ buffers after they are created with `rename-buffer'."
311
299
(not (inf-clojure-repl-p)))
312
300
(inf-clojure--prompt-repl-buffer " Select default REPL: " )
313
301
(current-buffer ))))
314
- (if (eq inf-clojure-repl-type 'cljs )
315
- (setq inf-clojure-cljs-buffer new-repl-buffer)
316
- (setq inf-clojure-buffer new-repl-buffer))
302
+ (setq inf-clojure-buffer new-repl-buffer)
317
303
(message " Current inf-clojure REPL set to %s " new-repl-buffer)))
318
304
319
305
(defvar inf-clojure--repl-type-lock nil
@@ -358,12 +344,11 @@ mode. Default is whitespace followed by 0 or 1 single-letter colon-keyword
358
344
(defun inf-clojure--modeline-info ()
359
345
" Return modeline info for `inf-clojure-minor-mode' .
360
346
Either \" no process\" or \" buffer-name(repl-type)\" "
361
- (let ((inf-buffer (inf-clojure--get-buffer)))
362
- (if (and (bufferp inf-buffer)
363
- (buffer-live-p inf-buffer))
364
- (with-current-buffer inf-buffer
365
- (format " %s (%s )" (buffer-name (current-buffer )) inf-clojure-repl-type))
366
- " no process" )))
347
+ (if (and (bufferp inf-clojure-buffer)
348
+ (buffer-live-p inf-clojure-buffer))
349
+ (with-current-buffer inf-clojure-buffer
350
+ (format " %s (%s )" (buffer-name (current-buffer )) inf-clojure-repl-type))
351
+ " no process" ))
367
352
368
353
(defvar inf-clojure-mode-map
369
354
(let ((map (make-sparse-keymap )))
@@ -754,10 +739,9 @@ to continue it."
754
739
" Switch to the inferior Clojure process buffer.
755
740
With prefix argument EOB-P, positions cursor at end of buffer."
756
741
(interactive " P" )
757
- (let ((inf-buffer (inf-clojure--get-buffer)))
758
- (if (get-buffer-process inf-buffer)
759
- (inf-clojure--swap-to-buffer-window inf-buffer)
760
- (call-interactively #'inf-clojure )))
742
+ (if (get-buffer-process inf-clojure-buffer)
743
+ (inf-clojure--swap-to-buffer-window inf-buffer)
744
+ (call-interactively #'inf-clojure ))
761
745
(when eob-p
762
746
(push-mark )
763
747
(goto-char (point-max ))))
@@ -801,6 +785,8 @@ to suppress the usage of the target buffer discovery logic."
801
785
The name is simply the final segment of the path."
802
786
(file-name-nondirectory (directory-file-name dir)))
803
787
788
+ ; ; TODO add entrypoint here!!
789
+ ; ; include :connection-method (shorter name!)
804
790
;;;### autoload
805
791
(defun inf-clojure (cmd )
806
792
" Run an inferior Clojure process, input and output via buffer `*inf-clojure*' .
@@ -834,9 +820,9 @@ process buffer for a list of commands.)"
834
820
; ; comint adds the asterisks to both sides
835
821
(repl-buffer-name (format " *%s * " process-buffer-name))
836
822
(repl-type (or (unless prefix-arg
837
- inf-clojure-custom-repl-type)
838
- (car (rassoc cmd inf-clojure-startup-forms))
839
- (inf-clojure--prompt-repl-type))))
823
+ inf-clojure-custom-repl-type)
824
+ (car (rassoc cmd inf-clojure-startup-forms))
825
+ (inf-clojure--prompt-repl-type))))
840
826
; ; Create a new comint buffer if needed
841
827
(unless (comint-check-proc repl-buffer-name)
842
828
; ; run the new process in the project's root when in a project folder
@@ -852,9 +838,7 @@ process buffer for a list of commands.)"
852
838
(setq-local inf-clojure-repl-type repl-type)
853
839
(hack-dir-local-variables-non-file-buffer ))))
854
840
; ; update the default comint buffer and switch to it
855
- (if (eq repl-type 'cljs )
856
- (setq inf-clojure-cljs-buffer (get-buffer repl-buffer-name))
857
- (setq inf-clojure-buffer (get-buffer repl-buffer-name)))
841
+ (setq inf-clojure-buffer (get-buffer repl-buffer-name))
858
842
(if inf-clojure-repl-use-same-window
859
843
(pop-to-buffer-same-window repl-buffer-name)
860
844
(pop-to-buffer repl-buffer-name))))
@@ -873,17 +857,6 @@ inf-clojure-connect process/buffer.")
873
857
(defvar-local inf-clojure-socket-buffer nil
874
858
" Used to kill the socket buffer for a Clojure REPL with the REPL buffer is shutdown." )
875
859
876
- (defcustom inf-clojure-cli-args nil
877
- " Arguments to be supplied when the clojure repl type is used e.g -Mdev."
878
- :type 'string
879
- :safe #'stringp )
880
-
881
- (defcustom inf-clojure-cljs-cli-args " -m cljs.main"
882
- " Arguments to be supplied when the cljs repl type is used e.g \" -Mdev:client -e (start-cljs)\" ."
883
- :type 'string
884
- :safe #'stringp )
885
-
886
-
887
860
(defun inf-clojure-socket-filter (process output )
888
861
" A filter that gets triggered each time the socket receives new OUTPUT.
889
862
This function prints out the output received but also
@@ -959,13 +932,21 @@ VALUE must be a valid repl type, given as a string e.g clojure/cljs/lein/babashk
959
932
960
933
`:project-name'
961
934
962
- VALUE can be any string, by default this is either derived from your current directory if you are inside a project or `standalone' "
935
+ VALUE can be any string, by default this is either derived from your current directory if you are inside a project or `standalone'
936
+
937
+ `:opts'
938
+
939
+ VALUE can be any string, by default this is nil and nothing is
940
+ added to the startup form is chosen according to your
941
+ `repl-type' . This is useful when you want to add some arguments
942
+ or flags for your chosen tool. e.g `-Adev:test' for `clojure' "
963
943
964
944
(interactive )
965
945
(setq args (purecopy args)) ; ; not sure if purecopy is useful, set-face-attribute does it.
966
946
(let* ((host (or (plist-get args :host ) " localhost" ))
967
947
(port (or (plist-get args :port ) (+ 5500 (random 500 ))))
968
948
(repl-type (or (plist-get args :repl-type ) " clojure" ))
949
+ (opts (plist-get args :opts ))
969
950
(project-name (or (plist-get args :project-name )
970
951
(inf-clojure--project-name (or (clojure-project-dir)
971
952
" standalone" ))))
@@ -974,15 +955,14 @@ VALUE can be any string, by default this is either derived from your current dir
974
955
(socket-buffer (get-buffer-create socket-buffer-name))
975
956
(repl-buffer-name (format " %s -%s -repl" project-name repl-type))
976
957
(socket-form (cdr (assoc (intern repl-type) inf-clojure-socket-forms)))
977
- (socket-cmd (concat (format socket-form (number-to-string port))
978
- (cond ((string= repl-type " clojure" )
979
- (concat " " inf-clojure-cli-args))
980
- ((string= repl-type " cljs" )
981
- (concat " " inf-clojure-cljs-cli-args))
982
- (t nil ))))
983
- (sock (start-file-process-shell-command
984
- socket-process-name socket-buffer
985
- socket-cmd)))
958
+ (socket-cmd (apply 'concat
959
+ (format socket-form (number-to-string port))
960
+ (when opts `(" " , opts ))))
961
+ (sock (let ((default-directory (or (clojure-project-dir)
962
+ default-directory)))
963
+ (start-file-process-shell-command
964
+ socket-process-name socket-buffer
965
+ socket-cmd))))
986
966
(with-current-buffer socket-buffer
987
967
(setq-local
988
968
inf-clojure-socket-callback
0 commit comments