Skip to content

Commit a06c0c2

Browse files
committed
Insert flavor check before project type check
1 parent a450a0b commit a06c0c2

File tree

1 file changed

+27
-94
lines changed

1 file changed

+27
-94
lines changed

inf-clojure.el

Lines changed: 27 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,9 @@
4242
(require 'clojure-mode)
4343
(require 'eldoc)
4444
(require 'thingatpt)
45-
<<<<<<< variant A
4645
(require 'ansi-color)
4746
(require 'cl-lib)
48-
>>>>>>> variant B
4947
(require 'subr-x)
50-
####### Ancestor
51-
======= end
5248

5349

5450
(defgroup inf-clojure nil
@@ -153,7 +149,6 @@ The following commands are available:
153149
154150
\\{inf-clojure-minor-mode-map}"
155151
:lighter "" :keymap inf-clojure-minor-mode-map
156-
(inf-clojure--flavor-setup)
157152
(inf-clojure-eldoc-setup)
158153
(make-local-variable 'completion-at-point-functions)
159154
(add-to-list 'completion-at-point-functions
@@ -189,6 +184,16 @@ often connecting to a remote REPL process."
189184
:type '(choice (string)
190185
(cons string integer)))
191186

187+
(defcustom inf-clojure-lumo-cmd "lumo -d"
188+
"The command used to start a Lumo REPL.
189+
190+
Alternative you can specify a TCP connection cons pair, instead
191+
of command, consisting of a host and port
192+
number (e.g. (\"localhost\" . 5555)). That's useful if you're
193+
often connecting to a remote REPL process."
194+
:type '(choice (string)
195+
(cons string integer)))
196+
192197
(defcustom inf-clojure-load-command "(clojure.core/load-file \"%s\")\n"
193198
"Format-string for building a Clojure expression to load a file.
194199
This format string should use `%s' to substitute a file name
@@ -261,26 +266,10 @@ whichever process buffer you want to use.")
261266

262267
(put 'inf-clojure-mode 'mode-class 'special)
263268

264-
(defcustom inf-clojure-repl-default-flavor 'clojure
265-
"Symbol to define your default REPL flavor.
266-
The default flavor is clojure, lumo is the other supported
267-
one."
268-
:type '(choice (const :tag "Lumo" lumo)
269-
(other :tag "Clojure" clojure))
270-
:group 'inf-clojure)
271-
272-
(defvar-local inf-clojure-repl-flavor inf-clojure-repl-default-flavor
269+
(defvar-local inf-clojure-repl-flavor nil
273270
"Symbol to define your REPL flavor.
274-
Takes its root binding from inf-clojure-repl-default-flavor but
275-
can be further customized using either `setq-local` or an entry
276-
in `.dir-locals.el`." )
277-
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."))))
271+
Its root binding is nil and it can be further customized using
272+
either `setq-local` or an entry in `.dir-locals.el`." )
284273

285274
(define-derived-mode inf-clojure-mode comint-mode "Inferior Clojure"
286275
"Major mode for interacting with an inferior Clojure process.
@@ -645,21 +634,6 @@ The value is nil if it can't find one."
645634
"Return the name of the symbol at point, otherwise nil."
646635
(or (thing-at-point 'symbol) ""))
647636

648-
(defun inf-clojure--read-classpath (classpath-option)
649-
"Read the classpath from the input CLASSPATH-OPTION."
650-
(let ((classpath-file-path (concat (inf-clojure-project-root) classpath-option)))
651-
(cond
652-
((and (file-exists-p classpath-file-path) (file-readable-p classpath-file-path))
653-
(f-read classpath-file-path))
654-
;; TODO launch a command that returns the classpath string?
655-
((message (concat "Option \"" classpath-option "\" was not a (readable) file, the classpath will be empty."))
656-
""))))
657-
658-
(defun inf-clojure--maybe-set-program (program)
659-
"Set inf-clojure-program iff it is not a cons cell."
660-
(when (nlistp inf-clojure-program)
661-
(setq inf-clojure-program program)))
662-
663637
;;; Documentation functions: var doc and arglist.
664638
;;; ======================================================================
665639

@@ -926,61 +900,20 @@ to suppress the usage of the target buffer discovery logic."
926900
;;;; Lumo
927901
;;;; ====
928902

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)))
903+
;; The defcustoms for the following are already ok:
904+
;; * inf-clojure-set-ns-command
905+
;; * inf-clojure-macroexpand-command
906+
;; * inf-clojure-macroexpand-1-command
907+
;;
908+
;; TODOs
909+
;; https://github.com/anmonteiro/lumo/issues/84
910+
;; (setq inf-clojure-var-source-command "(lumo.repl/source %s)")
911+
;; https://github.com/anmonteiro/lumo/issues/87
912+
;; (setq inf-clojure-ns-vars-command "(lumo.repl/dir %s)")
913+
;; https://github.com/anmonteiro/lumo/issues/86
914+
;; (setq inf-clojure-var-apropos-command "(lumo.repl/apropos %s)")
915+
;; https://github.com/anmonteiro/lumo/pull/88
916+
;; (setq inf-clojure-arglist-command "(lumo.repl/get-arglists \"%s\")")
984917

985918
(provide 'inf-clojure)
986919
;;; inf-clojure.el ends here

0 commit comments

Comments
 (0)