@@ -179,9 +179,6 @@ either `setq-local` or an entry in `.dir-locals.el`." )
179179(defvar-local inf-clojure-repl-name nil
180180 " When creating a REPL, set the name to be given to the buffer it's output is sent to." )
181181
182- (defvar inf-clojure-cljs-buffer nil
183- " The current `inf-clojure' process buffer with repl-type `cljs' " )
184-
185182(defvar inf-clojure-buffer nil
186183 " The current `inf-clojure' process buffer.
187184
@@ -218,11 +215,6 @@ one process, this does the right thing. If you run multiple
218215processes, you might need to change `inf-clojure-buffer' to
219216whichever process buffer you want to use." )
220217
221- (defun inf-clojure--get-buffer ()
222- (if (eq major-mode 'clojurescript-mode )
223- inf-clojure-cljs-buffer
224- inf-clojure-buffer))
225-
226218(defun inf-clojure--get-feature (repl-type feature no-error )
227219 " Get FEATURE for REPL-TYPE from repl-features.
228220If 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
264256has been found. See also variable `inf-clojure-buffer' ."
265257 (or (get-buffer-process (if (derived-mode-p 'inf-clojure-mode )
266258 (current-buffer )
267- ( inf-clojure--get- buffer) ))
259+ inf-clojure-buffer))
268260 (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' " ))))
274262
275263(defun inf-clojure-repl-p (&optional buf )
276264 " Indicates if BUF is an inf-clojure REPL.
@@ -311,9 +299,7 @@ buffers after they are created with `rename-buffer'."
311299 (not (inf-clojure-repl-p)))
312300 (inf-clojure--prompt-repl-buffer " Select default REPL: " )
313301 (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)
317303 (message " Current inf-clojure REPL set to %s " new-repl-buffer)))
318304
319305(defvar inf-clojure--repl-type-lock nil
@@ -358,12 +344,11 @@ mode. Default is whitespace followed by 0 or 1 single-letter colon-keyword
358344(defun inf-clojure--modeline-info ()
359345 " Return modeline info for `inf-clojure-minor-mode' .
360346Either \" 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" ))
367352
368353(defvar inf-clojure-mode-map
369354 (let ((map (make-sparse-keymap )))
@@ -754,10 +739,9 @@ to continue it."
754739 " Switch to the inferior Clojure process buffer.
755740With prefix argument EOB-P, positions cursor at end of buffer."
756741 (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 ))
761745 (when eob-p
762746 (push-mark )
763747 (goto-char (point-max ))))
@@ -801,6 +785,8 @@ to suppress the usage of the target buffer discovery logic."
801785The name is simply the final segment of the path."
802786 (file-name-nondirectory (directory-file-name dir)))
803787
788+ ; ; TODO add entrypoint here!!
789+ ; ; include :connection-method (shorter name!)
804790;;;### autoload
805791(defun inf-clojure (cmd )
806792 " Run an inferior Clojure process, input and output via buffer `*inf-clojure*' .
@@ -834,9 +820,9 @@ process buffer for a list of commands.)"
834820 ; ; comint adds the asterisks to both sides
835821 (repl-buffer-name (format " *%s * " process-buffer-name))
836822 (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))))
840826 ; ; Create a new comint buffer if needed
841827 (unless (comint-check-proc repl-buffer-name)
842828 ; ; 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.)"
852838 (setq-local inf-clojure-repl-type repl-type)
853839 (hack-dir-local-variables-non-file-buffer ))))
854840 ; ; 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))
858842 (if inf-clojure-repl-use-same-window
859843 (pop-to-buffer-same-window repl-buffer-name)
860844 (pop-to-buffer repl-buffer-name))))
@@ -873,17 +857,6 @@ inf-clojure-connect process/buffer.")
873857(defvar-local inf-clojure-socket-buffer nil
874858 " Used to kill the socket buffer for a Clojure REPL with the REPL buffer is shutdown." )
875859
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-
887860(defun inf-clojure-socket-filter (process output )
888861 " A filter that gets triggered each time the socket receives new OUTPUT.
889862This 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
959932
960933`:project-name'
961934
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' "
963943
964944 (interactive )
965945 (setq args (purecopy args)) ; ; not sure if purecopy is useful, set-face-attribute does it.
966946 (let* ((host (or (plist-get args :host ) " localhost" ))
967947 (port (or (plist-get args :port ) (+ 5500 (random 500 ))))
968948 (repl-type (or (plist-get args :repl-type ) " clojure" ))
949+ (opts (plist-get args :opts ))
969950 (project-name (or (plist-get args :project-name )
970951 (inf-clojure--project-name (or (clojure-project-dir)
971952 " standalone" ))))
@@ -974,15 +955,14 @@ VALUE can be any string, by default this is either derived from your current dir
974955 (socket-buffer (get-buffer-create socket-buffer-name))
975956 (repl-buffer-name (format " %s -%s -repl" project-name repl-type))
976957 (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))))
986966 (with-current-buffer socket-buffer
987967 (setq-local
988968 inf-clojure-socket-callback
0 commit comments