@@ -518,6 +518,9 @@ Should be a symbol that is a key in `inf-clojure-repl-features'."
518518 (const :tag " babashka" babashka)
519519 (const :tag " determine at startup" nil )))
520520
521+ (defvar inf-clojure-custom-repl-name nil
522+ " A string to be used as the repl buffer name." )
523+
521524(defun inf-clojure--whole-comment-line-p (string )
522525 " Return non-nil iff STRING is a whole line semicolon comment."
523526 (string-match-p " ^\s *;" string))
@@ -606,7 +609,9 @@ This should usually be a combination of `inf-clojure-prompt' and
606609 :package-version '(inf-clojure . " 2.0.0" ))
607610
608611(defcustom inf-clojure-auto-mode t
609- " When non-nil, automatically enable inf-clojure-minor-mode for all Clojure buffers."
612+ " Automatically enable inf-clojure-minor-mode.
613+ All buffers in `clojure-mode' will automatically be in
614+ `inf-clojure-minor-mode' unless set to nil."
610615 :type 'boolean
611616 :safe #'booleanp
612617 :package-version '(inf-clojure . " 3.1.0" ))
@@ -795,7 +800,7 @@ The name is simply the final segment of the path."
795800 (file-name-nondirectory (directory-file-name dir)))
796801
797802;;;### autoload
798- (defun inf-clojure (cmd )
803+ (defun inf-clojure (cmd &optional suppress-message )
799804 " Run an inferior Clojure process, input and output via buffer `*inf-clojure*' .
800805If there is a process already running in `*inf-clojure*' , just
801806switch to that buffer.
@@ -809,6 +814,9 @@ and `inf-clojure-custom-startup' if those are set.
809814Use a prefix to prevent using these when they
810815are set.
811816
817+ Prints a message that it has connected to the host and port
818+ unless SUPPRESS-MESSAGE is truthy.
819+
812820 Runs the hooks from `inf-clojure-mode-hook' (after the
813821`comint-mode-hook' is run). \( Type \\ [describe-mode] in the
814822process buffer for a list of commands.)"
@@ -833,12 +841,12 @@ process buffer for a list of commands.)"
833841 (cmdlist (if (consp cmd)
834842 (list cmd)
835843 (split-string-and-unquote cmd)))
836- (repl-type (or inf-clojure-socket-repl-type
837- (unless prefix-arg
844+ (repl-type (or (unless prefix-arg
838845 inf-clojure-custom-repl-type)
839- (car (rassoc cmd inf-clojure-startup-forms))
840- (inf-clojure--prompt-repl-type))))
841- (message " Starting Clojure REPL via `%s' ... " cmd)
846+ (car (rassoc cmd inf-clojure-startup-forms))
847+ (inf-clojure--prompt-repl-type))))
848+ (unless suppress-message
849+ (message " Starting Clojure REPL via `%s' ... " cmd))
842850 (with-current-buffer (apply #'make-comint
843851 process-buffer-name (car cmdlist) nil (cdr cmdlist))
844852 (inf-clojure-mode)
@@ -849,14 +857,17 @@ process buffer for a list of commands.)"
849857 (setq inf-clojure-buffer (get-buffer repl-buffer-name))
850858 (if inf-clojure-repl-use-same-window
851859 (pop-to-buffer-same-window repl-buffer-name)
852- (pop-to-buffer repl-buffer-name))))
860+ (pop-to-buffer repl-buffer-name))
861+ repl-buffer-name))
853862
854- ;;;### autoload
855- (defun inf-clojure-connect (host port )
863+ ; ;;###autol
864+ (defun inf-clojure-connect (host port &optional suppress-message )
856865 " Connect to a running socket REPL server via `inf-clojure' .
857- HOST is the host the process is running on, PORT is where it's listening."
866+ HOST is the host the process is running on, PORT is where it's
867+ listening. SUPPRESS-MESSAGE is optional and if truthy will
868+ prevent showing the startup message."
858869 (interactive " shost: \n nport: " )
859- (inf-clojure (cons host port)))
870+ (inf-clojure (cons host port) suppress-message ))
860871
861872(defvar-local inf-clojure-socket-callback nil
862873 " Used to transfer state between the socket process buffer & REPL buffer." )
@@ -882,12 +893,11 @@ OUTPUT is the latest data received from the process"
882893 (insert output)))
883894 (let ((prompt-displayed (string-match inf-clojure-prompt output)))
884895 (when prompt-displayed
885- (message (format " Socket REPL startup detected for %s " (process-name process)))
886896 (with-current-buffer server-buffer
887897 (when inf-clojure-socket-callback
888898 (funcall inf-clojure-socket-callback)))))))
889899
890- (defun inf-clojure-socket-repl-sentinel (process event )
900+ (defun inf-clojure-socket-repl-sentinel (process _event )
891901 " Ensures socket REPL are cleaned up when the REPL buffer is closed.
892902
893903PROCESS is the process object that is connected to a socket REPL.
@@ -917,11 +927,11 @@ If left as nil a random port will be selected between 5500-6000."
917927
918928;;;### autoload
919929(defun inf-clojure-socket-repl (cmd )
920- " Start a socket REPL server and connect to it via `inf-clojure' .
921- CMD is the command line used to start the socket REPL, if this
922- isn't provided you will be prompted to select from the defaults
923- provided in `inf-clojure-socket-repl- startup-forms ' or
924- `inf-clojure-custom- startup' if this is defined ."
930+ " Start a socket REPL server and connects to it via `inf-clojure-connect ' .
931+ CMD is the command line instruction used to start the socket
932+ REPL. It should be a string with \" %d \" in it to take a random
933+ port. Set `inf-clojure-custom- startup' or choose from the
934+ defaults provided in `inf-clojure-socket-repl- startup-forms' ."
925935 (interactive (list (or (unless current-prefix-arg
926936 inf-clojure-custom-startup)
927937 (completing-read " Select Clojure socket REPL startup command: "
@@ -937,13 +947,9 @@ provided in `inf-clojure-socket-repl-startup-forms' or
937947 (inf-clojure--prompt-repl-type)))
938948 (project-name (inf-clojure--project-name (or project-dir " standalone" )))
939949 (socket-process-name (format " *%s -%s -socket-server* " project-name repl-type))
940- (socket-buffer-name (format " *%s -%s -socket* " project-name repl-type))
941- (socket-buffer (get-buffer-create socket-buffer-name))
942- (repl-buffer-name (format " %s -%s -repl" project-name repl-type))
943- (socket-form (or cmd
944- (cdr (assoc repl-type inf-clojure-socket-repl-startup-forms))
945- inf-clojure-custom-startup))
946- (socket-cmd (format socket-form port))
950+ (socket-buffer (get-buffer-create
951+ (format " *%s -%s -socket* " project-name repl-type)))
952+ (socket-cmd (format cmd port))
947953 (sock (let ((default-directory (or project-dir default-directory)))
948954 (start-file-process-shell-command
949955 socket-process-name socket-buffer
@@ -952,19 +958,13 @@ provided in `inf-clojure-socket-repl-startup-forms' or
952958 (setq-local
953959 inf-clojure-socket-callback
954960 (lambda ()
955- (let ((with-process-repl-buffer-name (concat " *" repl-buffer-name " *" )))
956- (setq inf-clojure-socket-repl-type
957- repl-type
958- inf-clojure-custom-repl-name
959- repl-buffer-name
960- repl-buffer
961- (get-buffer-create with-process-repl-buffer-name))
962- (inf-clojure-connect host port)
963- (with-current-buffer with-process-repl-buffer-name
964- (setq inf-clojure-socket-buffer socket-buffer))
965- (set-process-sentinel
966- (get-buffer-process (get-buffer with-process-repl-buffer-name))
967- #'inf-clojure-socket-repl-sentinel )))))
961+ (let* ((inf-clojure-custom-repl-type repl-type)
962+ (created-repl-buffer (inf-clojure-connect host port :suppress-message )))
963+ (with-current-buffer (get-buffer created-repl-buffer)
964+ (setq-local inf-clojure-socket-buffer socket-buffer)
965+ (set-process-sentinel
966+ (get-buffer-process (current-buffer ))
967+ #'inf-clojure-socket-repl-sentinel ))))))
968968 (set-process-filter sock #'inf-clojure-socket-filter )
969969 (message " Starting %s socket REPL server at %s :%d with %s " repl-type host port socket-cmd)))
970970
0 commit comments