Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out how to handle subprompts #7

Closed
bbatsov opened this issue Jan 15, 2015 · 5 comments · Fixed by #17
Closed

Figure out how to handle subprompts #7

bbatsov opened this issue Jan 15, 2015 · 5 comments · Fixed by #17

Comments

@bbatsov
Copy link
Member

bbatsov commented Jan 15, 2015

When you pass a multi-line command to the REPL the output gets littered with #_> subprompts. Some possible ways to handle this include converting all REPL input to a single line before sending it to the REPL or adding to code to filter out the REPL subprompts.

@otijhuis
Copy link
Contributor

I've been doing it like this:

(defcustom inf-clojure-subprompt " *#_=> *"
  "Regexp to recognize subprompts in the Inferior Clojure mode."
  :type 'regexp
  :group 'inf-clojure)

(defun inf-clojure-remove-subprompts (txt)
  (replace-regexp-in-string inf-clojure-subprompt "" txt))

(add-hook 'comint-preoutput-filter-functions #'inf-clojure-remove-subprompts)

Seems to work very well. Haven't had any problems with it.

I tried converting multi-line strings to a single line by removing the newlines but then expressions like below will end up being evaluated incorrectly.

(def some-string "this
 is
 a
 multi-line
 string")

@bbatsov
Copy link
Member Author

bbatsov commented Oct 10, 2015

Looks reasonable. Guess you can convert this to a PR. :-)

@otijhuis
Copy link
Contributor

Damn, you're fast :)

I'll create a PR as soon as I can. Have to head out for a while.

@otijhuis
Copy link
Contributor

Do you want to me to keep it as a separate filter or add it to the current filter?

(defun inf-clojure-preoutput-filter (str)
  "Preprocess the output STR from interactive commands."
  (cond
   ((string-prefix-p "inf-clojure-" (symbol-name (or this-command last-command)))
    ;; prepend a newline to the output string
    (inf-clojure-chomp (concat "\n" str)))
   (t str)))

@bbatsov
Copy link
Member Author

bbatsov commented Oct 10, 2015

Using the same filter is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants