diff --git a/clojure-repl.el b/clojure-repl.el index 3314dab..d83805a 100644 --- a/clojure-repl.el +++ b/clojure-repl.el @@ -4,7 +4,7 @@ ;; Author: Valery Kocubinsky ;; URL: https://github.com/vkocubinsky/clojure-repl -;; Version: 0.1.0 +;; Version: 0.2.0 ;; Package-Requires: ((emacs "30.1") (clojure-mode "5.23.0")) ;; Keywords: clojure, languages, processes, lisp @@ -385,18 +385,6 @@ See command `clojure-repl-minor-mode'." :type 'regexp) -(defcustom clojure-repl-filter-auto t - "Filter output from in-ns, load, load-repl") - -(defun clojure-repl-preoutput-filter (str) - "Filter clojure-repl command" - ;;(message "got: '%s'" str) - (if clojure-repl-filter-auto - (let ((newstr (replace-regexp-in-string ":clojure-repl/\\(in-ns\\|load\\|load-repl\\)\n[^=> ]+=> " "" str))) - ;;(message "translate: '%s'" newstr) - newstr - ) - str)) (define-derived-mode clojure-repl-mode comint-mode "Clojure Repl" "Major mode for run Clojure. @@ -405,7 +393,6 @@ See command `clojure-repl-minor-mode'." " ;;(setq-local comint-process-echoes t) - (add-hook 'comint-preoutput-filter-functions #'clojure-repl-preoutput-filter nil t) (setq-local comint-use-prompt-regexp t) (setq-local comint-prompt-regexp clojure-repl-comint-prompt-regexp) (setq-local comint-prompt-read-only t) @@ -522,12 +509,11 @@ process buffer for a list of commands.)" (comint-send-string proc (clojure-repl--normalize-input text)) (display-buffer (clojure-repl--repl-buffer))) -(defun clojure-repl--eval-text (proc text query-p newline-p) - (when newline-p - (with-current-buffer (process-buffer (clojure-repl--repl-process)) +(defun clojure-repl--eval-text (proc text query-p) + (with-current-buffer (process-buffer (clojure-repl--repl-process)) (comint-goto-process-mark) (insert "\n") - (comint-set-process-mark))) + (comint-set-process-mark)) (if query-p (clojure-repl--eval-text-as-query proc text) (clojure-repl--eval-text-silently proc text))) @@ -537,46 +523,46 @@ process buffer for a list of commands.)" (comint-send-string (clojure-repl--repl-process) "\n") ) -(defun clojure-repl--eval-thing (thing query-p newline-p) +(defun clojure-repl--eval-thing (thing query-p) "Eval things such as `sexp', `defun', `region', `buffer'" (let ((text (thing-at-point thing t))) (unless text (user-error (format "No %s found at point" thing))) - (clojure-repl--eval-text (clojure-repl--repl-process) text query-p newline-p))) + (clojure-repl--eval-text (clojure-repl--repl-process) text query-p))) -(defun clojure-repl--eval-command-with-ns (command query-p newline-p) +(defun clojure-repl--eval-command-with-ns (command query-p) "Execute command template which accept namespace as an argument." (let* ((proc (clojure-repl--repl-process)) (ns (clojure-find-ns))) (unless ns (user-error "No namespace found in current buffer")) - (clojure-repl--eval-text proc (format command ns) query-p newline-p))) + (clojure-repl--eval-text proc (format command ns) query-p))) -(defun clojure-repl--eval-command-with-thing (command thing query-p newline-p) +(defun clojure-repl--eval-command-with-thing (command thing query-p) "Execute command template which accept things such as 'symbol, 'sexp as argument ." (let* ((text (thing-at-point thing t))) (unless text (user-error (format "No %s found at point" thing))) - (clojure-repl--eval-text (clojure-repl--repl-process) (format command text) query-p newline-p))) + (clojure-repl--eval-text (clojure-repl--repl-process) (format command text) query-p))) (defun clojure-repl-load () "Execute repl load command. See variable `clojure-repl-load-command' and variable" (interactive) - (clojure-repl--eval-command-with-ns clojure-repl-load-command t (not clojure-repl-filter-auto))) + (clojure-repl--eval-command-with-ns clojure-repl-load-command t)) (defun clojure-repl-switch-ns () "Execute switch ns command. See variable `clojure-repl-switch-ns-command'." (interactive) - (clojure-repl--eval-command-with-ns clojure-repl-switch-ns-command t (not clojure-repl-filter-auto))) + (clojure-repl--eval-command-with-ns clojure-repl-switch-ns-command t)) (defun clojure-repl-load-repl () "Execute load repl command. See variables `clojure-repl-load-repl-command'" (interactive) - (clojure-repl--eval-text (clojure-repl--repl-process) clojure-repl-load-repl-command t (not clojure-repl-filter-auto))) + (clojure-repl--eval-text (clojure-repl--repl-process) clojure-repl-load-repl-command t)) (defun clojure-repl--auto-load () (when (derived-mode-p 'clojure-mode) @@ -591,31 +577,31 @@ process buffer for a list of commands.)" "Execute region." (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-thing 'region nil t)) + (clojure-repl--eval-thing 'region nil)) (defun clojure-repl-eval-defun () "Execute defun." (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-thing 'defun nil t)) + (clojure-repl--eval-thing 'defun nil)) (defun clojure-repl-eval-paragraph () "Execute defun." (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-thing 'paragraph nil t)) + (clojure-repl--eval-thing 'paragraph nil)) (defun clojure-repl-eval-buffer () "Execute buffer." (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-thing 'buffer nil t)) + (clojure-repl--eval-thing 'buffer nil)) (defun clojure-repl-eval-sexp () "Execute sexp." (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-thing 'sexp nil t)) + (clojure-repl--eval-thing 'sexp nil)) (defun clojure-repl-load-file () "Load current clojure file into the inferior Clojure process." @@ -623,54 +609,54 @@ process buffer for a list of commands.)" (let* ((proc (clojure-repl--repl-process)) (file-name (buffer-file-name))) (if (and (derived-mode-p 'clojure-mode) file-name) - (clojure-repl--eval-text proc (format clojure-repl-load-file-command file-name) t t) + (clojure-repl--eval-text proc (format clojure-repl-load-file-command file-name) t) (user-error "Current buffer file is not clojure or doesn't exists.")))) (defun clojure-repl-reload () "Execute repl reload command. See variable `clojure-repl-reload-command' and variable" (interactive) - (clojure-repl--eval-command-with-ns clojure-repl-reload-command t nil)) + (clojure-repl--eval-command-with-ns clojure-repl-reload-command t)) (defun clojure-repl-reload-all () "Execute reload all command. See variable `clojure-repl-reload-all-command' and variable" (interactive) - (clojure-repl--eval-command-with-ns clojure-repl-reload-all-command t nil)) + (clojure-repl--eval-command-with-ns clojure-repl-reload-all-command t)) (defun clojure-repl-show-var-doc () "Execute doc command. See variable `clojure-repl-doc-command'." (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-command-with-thing clojure-repl-doc-command 'symbol t t)) + (clojure-repl--eval-command-with-thing clojure-repl-doc-command 'symbol t)) (defun clojure-repl-show-var-source () "Execute source command. See variable `clojure-repl-var-source-form'." (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-command-with-thing clojure-repl-source-command 'symbol t t)) + (clojure-repl--eval-command-with-thing clojure-repl-source-command 'symbol t)) (defun clojure-repl-show-pst () "Execute print stack trace command. See variable `clojure-repl-pst-command'." (interactive) - (clojure-repl--eval-command-with-ns clojure-repl-pst-command t t)) + (clojure-repl--eval-command-with-ns clojure-repl-pst-command t)) (defun clojure-repl-run-all-tests () "Execute test all namespaces command. See variable `clojure-repl-run-all-tests-command'" (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-text (clojure-repl--repl-process) clojure-repl-run-all-tests-command nil t)) + (clojure-repl--eval-text (clojure-repl--repl-process) clojure-repl-run-all-tests-command nil)) (defun clojure-repl-run-ns-tests () "Excute test current namespace command. See variable `clojure-repl-run-ns-tests-command'" (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-text (clojure-repl--repl-process) clojure-repl-run-ns-tests-command nil t)) + (clojure-repl--eval-text (clojure-repl--repl-process) clojure-repl-run-ns-tests-command nil)) (defun clojure-repl-run-test () "Execute current test command. @@ -678,13 +664,13 @@ process buffer for a list of commands.)" (interactive) (clojure-repl--auto-load) (when-let ((defun-name (clojure-current-defun-name))) - (clojure-repl--eval-text (clojure-repl--repl-process) (format clojure-repl-run-test-command defun-name nil t)))) + (clojure-repl--eval-text (clojure-repl--repl-process) (format clojure-repl-run-test-command defun-name nil)))) (defun clojure-repl-pprint-sexp () "Execute sexp at point as pretty print." (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-command-with-thing clojure-repl-pprint-command 'sexp nil t)) + (clojure-repl--eval-command-with-thing clojure-repl-pprint-command 'sexp nil)) (defun clojure-repl-macroexpand (&optional macro-1) "Execute macro expansion command. @@ -696,14 +682,14 @@ process buffer for a list of commands.)" (let* ((macroexpand-form (if macro-1 clojure-repl-macroexpand-1-command clojure-repl-macroexpand-command))) - (clojure-repl--eval-command-with-thing macroexpand-form 'sexp t nil))) + (clojure-repl--eval-command-with-thing macroexpand-form 'sexp t))) (defun clojure-repl-javadoc () "Execute javadoc command. See variable `clojure-repl-javadoc-command'." (interactive) (clojure-repl--auto-load) - (clojure-repl--eval-command-with-thing clojure-repl-javadoc-command 'symbol t t)) + (clojure-repl--eval-command-with-thing clojure-repl-javadoc-command 'symbol t)) (provide 'clojure-repl)