42
42
(require 'clojure-mode )
43
43
(require 'eldoc )
44
44
(require 'thingatpt )
45
- <<<<<<< variant A
46
45
(require 'ansi-color )
47
46
(require 'cl-lib )
48
- >>>>>>> variant B
49
47
(require 'subr-x )
50
- ## ##### Ancestor
51
- ======= end
52
48
53
49
54
50
(defgroup inf-clojure nil
@@ -189,6 +185,16 @@ often connecting to a remote REPL process."
189
185
:type '(choice (string )
190
186
(cons string integer)))
191
187
188
+ (defcustom inf-clojure-lumo-cmd " lumo -d"
189
+ " The command used to start a Lumo REPL.
190
+
191
+ Alternative you can specify a TCP connection cons pair, instead
192
+ of command, consisting of a host and port
193
+ number (e.g. (\" localhost\" . 5555)). That's useful if you're
194
+ often connecting to a remote REPL process."
195
+ :type '(choice (string )
196
+ (cons string integer)))
197
+
192
198
(defcustom inf-clojure-load-command " (clojure.core/load-file \" %s\" )\n "
193
199
" Format-string for building a Clojure expression to load a file.
194
200
This format string should use `%s' to substitute a file name
@@ -261,12 +267,12 @@ whichever process buffer you want to use.")
261
267
262
268
(put 'inf-clojure-mode 'mode-class 'special )
263
269
264
- (defcustom inf-clojure-repl-default-flavor 'clojure
270
+ (defcustom inf-clojure-repl-default-flavor nil
265
271
" Symbol to define your default REPL flavor.
266
272
The default flavor is clojure, lumo is the other supported
267
273
one."
268
274
:type '(choice (const :tag " Lumo" lumo)
269
- (other :tag " Clojure " clojure ))
275
+ (other :tag " Project driven " nil ))
270
276
:group 'inf-clojure )
271
277
272
278
(defvar-local inf-clojure-repl-flavor inf-clojure-repl-default-flavor
@@ -275,13 +281,6 @@ Takes its root binding from inf-clojure-repl-default-flavor but
275
281
can be further customized using either `setq-local` or an entry
276
282
in `.dir-locals.el`." )
277
283
278
- (defun inf-clojure--flavor-setup ()
279
- " Setup inf-clojure defcustoms depending on the choose flavor."
280
- (pcase inf-clojure-repl-flavor
281
- (lumo (inf-clojure--flavor-lumo-setup))
282
- (clojure nil )
283
- (_ (user-error " [inf-clojure] The specified flavor is not supported at the moment." ))))
284
-
285
284
(define-derived-mode inf-clojure-mode comint-mode " Inferior Clojure"
286
285
" Major mode for interacting with an inferior Clojure process.
287
286
Runs a Clojure interpreter as a subprocess of Emacs, with Clojure
@@ -391,12 +390,21 @@ Fallback to `default-directory.' if not within a project."
391
390
((file-exists-p " build.boot" ) " boot" )
392
391
(t nil ))))
393
392
393
+ (defun inf-clojure-flavor-cmd ()
394
+ " Determine the flavor of the project.
395
+ Return nil if no flavor has been specified"
396
+ (pcase inf-clojure-repl-flavor
397
+ (lumo inf-clojure-lumo-cmd)
398
+ (_ nil )))
399
+
394
400
(defun inf-clojure-cmd (project-type )
395
401
" Determine the command `inf-clojure' needs to invoke for the PROJECT-TYPE."
396
- (pcase project-type
397
- (" lein" inf-clojure-lein-cmd)
398
- (" boot" inf-clojure-boot-cmd)
399
- (_ inf-clojure-generic-cmd)))
402
+ (if-let ((flavor-command (inf-clojure-flavor-cmd)))
403
+ flavor-command
404
+ (pcase project-type
405
+ (" lein" inf-clojure-lein-cmd)
406
+ (" boot" inf-clojure-boot-cmd)
407
+ (_ inf-clojure-generic-cmd))))
400
408
401
409
(defun inf-clojure-clear-repl-buffer ()
402
410
" Clear the REPL buffer."
@@ -926,61 +934,20 @@ to suppress the usage of the target buffer discovery logic."
926
934
; ;;; Lumo
927
935
; ;;; ====
928
936
929
- (defgroup lumo nil
930
- " Run an external Lumo process (REPL) in an Emacs buffer."
931
- :group 'inf-clojure )
932
-
933
- (defcustom inf-clojure-lumo-command " lumo"
934
- " The command used to launch lumo."
935
- :type 'string
936
- :group 'lumo )
937
-
938
- (defcustom inf-clojure-lumo-args " -d"
939
- " The command arguments used to launch lumo."
940
- :type 'string
941
- :group 'lumo )
942
-
943
- ; ; AR - TODO Alternatively you can specify a command string that will be called,
944
- ; ; which should return a string.
945
- (defcustom inf-clojure-lumo-classpath-generator " cp"
946
- " The file used to create the classpath string.
947
- The classpath string has to be a \" :\" separated list of dir and
948
- files."
949
- :type 'string
950
- :group 'lumo )
951
-
952
- ; ; AR - not used but left here because it is a possible sanity check
953
- (defun inf-clojure--lumo-mode-p ()
954
- " Return true if the lumo is the target REPL."
955
- (comint-send-string (inf-clojure-proc) " (js/global.hasOwnProperty \" $$LUMO_GLOBALS\" )" ))
956
-
957
- (defun inf-clojure--lumo-repl-command ()
958
- " Return inf-clojure-program for lumo."
959
- (concat inf-clojure-lumo-command
960
- " "
961
- (when (not (string-empty-p inf-clojure-lumo-classpath-generator))
962
- (concat inf-clojure-lumo-args " " ))
963
- " -c " (inf-clojure--read-classpath inf-clojure-lumo-classpath-generator)))
964
-
965
- (defun inf-clojure--flavor-lumo-setup ()
966
- " Setup defcustoms for the Lumo flavor."
967
- ; ; The defcustoms for the following are already ok:
968
- ; ; * inf-clojure-set-ns-command
969
- ; ; * inf-clojure-macroexpand-command
970
- ; ; * inf-clojure-macroexpand-1-command
971
- ; ;
972
- ; ; https://github.com/anmonteiro/lumo/issues/84
973
- ; ; (setq inf-clojure-var-source-command "(lumo.repl/source %s)")
974
- ; ; https://github.com/anmonteiro/lumo/issues/87
975
- ; ; (setq inf-clojure-ns-vars-command "(lumo.repl/dir %s)")
976
- ; ; https://github.com/anmonteiro/lumo/issues/86
977
- ; ; (setq inf-clojure-var-apropos-command "(lumo.repl/apropos %s)")
978
-
979
- ; ; Uncomment after https://github.com/anmonteiro/lumo/pull/88
980
- ; ; (setq inf-clojure-arglist-command "(lumo.repl/get-arglists \"%s\")")
981
- (setq inf-clojure-var-doc-command " (lumo.repl/doc %s)" )
982
- (setq inf-clojure-completion-command " (or (doall (map str (lumo.repl/get-completions \" %s\" )) '())" )
983
- (inf-clojure--maybe-set-program (inf-clojure--lumo-repl-command)))
937
+ ; ; The defcustoms for the following are already ok:
938
+ ; ; * inf-clojure-set-ns-command
939
+ ; ; * inf-clojure-macroexpand-command
940
+ ; ; * inf-clojure-macroexpand-1-command
941
+ ; ;
942
+ ; ; TODOs
943
+ ; ; https://github.com/anmonteiro/lumo/issues/84
944
+ ; ; (setq inf-clojure-var-source-command "(lumo.repl/source %s)")
945
+ ; ; https://github.com/anmonteiro/lumo/issues/87
946
+ ; ; (setq inf-clojure-ns-vars-command "(lumo.repl/dir %s)")
947
+ ; ; https://github.com/anmonteiro/lumo/issues/86
948
+ ; ; (setq inf-clojure-var-apropos-command "(lumo.repl/apropos %s)")
949
+ ; ; https://github.com/anmonteiro/lumo/pull/88
950
+ ; ; (setq inf-clojure-arglist-command "(lumo.repl/get-arglists \"%s\")")
984
951
985
952
(provide 'inf-clojure )
986
953
; ;; inf-clojure.el ends here
0 commit comments