@@ -131,6 +131,7 @@ mode. Default is whitespace followed by 0 or 1 single-letter colon-keyword
131
131
(define-key map " \C -c\C -c" #'inf-clojure-eval-defun ) ; SLIME/CIDER style
132
132
(define-key map " \C -c\C -b" #'inf-clojure-eval-buffer )
133
133
(define-key map " \C -c\C -r" #'inf-clojure-eval-region )
134
+ (define-key map " \C -c\M -r" #'inf-clojure-reload )
134
135
(define-key map " \C -c\C -n" #'inf-clojure-eval-form-and-next )
135
136
(define-key map " \C -c\C -z" #'inf-clojure-switch-to-repl )
136
137
(define-key map " \C -c\C -i" #'inf-clojure-show-ns-vars )
@@ -152,6 +153,7 @@ mode. Default is whitespace followed by 0 or 1 single-letter colon-keyword
152
153
[" Eval buffer" inf-clojure-eval-buffer t]
153
154
" --"
154
155
[" Load file..." inf-clojure-load-file t]
156
+ [" Reload file... " inf-clojure-reload t]
155
157
" --"
156
158
[" Switch to REPL" inf-clojure-switch-to-repl t]
157
159
[" Set REPL ns" inf-clojure-set-ns t]
@@ -372,6 +374,48 @@ If you are using REPL types, it will pickup the most appropriate
372
374
(`planck inf-clojure-load-form-planck)
373
375
(_ inf-clojure-load-form)))
374
376
377
+ (defcustom inf-clojure-reload-form " (require '\" %s\" :reload)"
378
+ " Format-string for building a Clojure expression to reload a file.
379
+ Reload forces loading of all the identified libs even if they are
380
+ already loaded.
381
+ This format string should use `%s' to substitute a namespace and
382
+ should result in a Clojure form that will be sent to the inferior
383
+ Clojure to load that file."
384
+ :type 'string
385
+ :safe #'stringp
386
+ :package-version '(inf-clojure . " 2.2.0" ))
387
+
388
+ ; ; :reload forces loading of all the identified libs even if they are
389
+ ; ; already loaded
390
+ ; ; :reload-all implies :reload and also forces loading of all libs that the
391
+ ; ; identified libs directly or indirectly load via require or use
392
+
393
+ (defun inf-clojure-reload-form (proc )
394
+ " Return the form to query the Inf-Clojure PROC for reloading a namespace.
395
+ If you are using REPL types, it will pickup the most appropriate
396
+ `inf-clojure-reload-form` variant."
397
+ (inf-clojure--set-repl-type proc)
398
+ inf-clojure-reload-form)
399
+
400
+ (defcustom inf-clojure-reload-all-form " (require '\" %s\" :reload-all)"
401
+ " Format-string for building a Clojure expression to :reload-all a file.
402
+ Reload-all implies :reload and also forces loading of all libs
403
+ that the identified libs directly or indirectly load via require
404
+ or use.
405
+ This format string should use `%s' to substitute a namespace and
406
+ should result in a Clojure form that will be sent to the inferior
407
+ Clojure to load that file."
408
+ :type 'string
409
+ :safe #'stringp
410
+ :package-version '(inf-clojure . " 2.2.0" ))
411
+
412
+ (defun inf-clojure-reload-all-form (proc )
413
+ " Return the form to query the Inf-Clojure PROC for :reload-all of a namespace.
414
+ If you are using REPL types, it will pickup the most appropriate
415
+ `inf-clojure-reload-all-form` variant."
416
+ (inf-clojure--set-repl-type proc)
417
+ inf-clojure-reload-all-form)
418
+
375
419
(defcustom inf-clojure-prompt " ^[^=> \n ]+=> *"
376
420
" Regexp to recognize prompts in the Inferior Clojure mode."
377
421
:type 'regexp )
@@ -702,6 +746,28 @@ is present it will be used instead of the current file."
702
746
(when switch-to-repl
703
747
(inf-clojure-switch-to-repl t ))))
704
748
749
+ (defun inf-clojure-reload (arg )
750
+ " Send a query to the inferior Clojure for reloading the namespace.
751
+ See variable `inf-clojure-reload-form' and
752
+ `inf-clojure-reload-all-form' .
753
+
754
+ The prefix argument ARG can change the behavior of the command:
755
+
756
+ - C-u M-x `inf-clojure-reload' : prompts for a namespace name.
757
+ - M-- M-x `inf-clojure-reload' : executes (require ... :reload-all).
758
+ - M-- C-u M-x `inf-clojure-reload' : reloads all AND prompts."
759
+ (interactive " P" )
760
+ (let* ((proc (inf-clojure-proc))
761
+ (invertp (or (equal arg " -" ) (equal arg '(-4 ))))
762
+ (promptp (or (equal arg '(4 )) (equal arg '(-4 ))))
763
+ (ns (if promptp
764
+ (car (inf-clojure-symprompt " Namespace" (clojure-find-ns)))
765
+ (clojure-find-ns)))
766
+ (form (if (not invertp)
767
+ (inf-clojure-reload-form proc)
768
+ (inf-clojure-reload-all-form proc))))
769
+ (inf-clojure--send-string proc (format form ns))))
770
+
705
771
(defun inf-clojure-connected-p ()
706
772
" Return t if inferior Clojure is currently connected, nil otherwise."
707
773
(not (null inf-clojure-buffer)))
0 commit comments