@@ -516,6 +516,34 @@ This should usually be a combination of `inf-clojure-prompt' and
516516 :safe #'booleanp
517517 :package-version '(inf-clojure . " 2.0.0" ))
518518
519+ (defcustom inf-clojure-auto-mode t
520+ " When non-nil, automatically enable inf-clojure-minor-mode for all Clojure buffers."
521+ :type 'boolean
522+ :safe #'booleanp
523+ :package-version '(inf-clojure . " 3.1.0" ))
524+
525+ (defun inf-clojure--clojure-buffers ()
526+ " Return a list of all existing `clojure-mode' buffers."
527+ (cl-remove-if-not
528+ (lambda (buffer ) (with-current-buffer buffer (derived-mode-p 'clojure-mode )))
529+ (buffer-list )))
530+
531+ (defun inf-clojure-enable-on-existing-clojure-buffers ()
532+ " Enable inf-clojure's minor mode on existing Clojure buffers.
533+ See command `inf-clojure-minor-mode' ."
534+ (interactive )
535+ (add-hook 'clojure-mode-hook #'inf-clojure-minor-mode )
536+ (dolist (buffer (inf-clojure--clojure-buffers))
537+ (with-current-buffer buffer
538+ (inf-clojure-minor-mode +1 ))))
539+
540+ (defun inf-clojure-disable-on-existing-clojure-buffers ()
541+ " Disable command `inf-clojure-minor-mode' on existing Clojure buffers."
542+ (interactive )
543+ (dolist (buffer (inf-clojure--clojure-buffers))
544+ (with-current-buffer buffer
545+ (inf-clojure-minor-mode -1 ))))
546+
519547(defvar inf-clojure-buffer nil
520548 " The current `inf-clojure' process buffer.
521549
@@ -609,7 +637,9 @@ to continue it."
609637 (setq-local comint-prompt-read-only inf-clojure-prompt-read-only)
610638 (add-hook 'comint-preoutput-filter-functions #'inf-clojure-preoutput-filter nil t )
611639 (add-hook 'completion-at-point-functions #'inf-clojure-completion-at-point nil t )
612- (ansi-color-for-comint-mode-on ))
640+ (ansi-color-for-comint-mode-on )
641+ (when inf-clojure-auto-mode
642+ (inf-clojure-enable-on-existing-clojure-buffers)))
613643
614644(defun inf-clojure-get-old-input ()
615645 " Return a string containing the sexp ending at point."
0 commit comments