Skip to content

Commit e12db12

Browse files
oyvindstegardbbatsov
authored andcommitted
Fix prompt being included in input history
When navigating to previous input history and *current input is empty*, the `backward-sexp' call in function `inf-clojure-get-old-input' would not respect comint prompt boundary and jump to beginning of line. This caused the prompt text to be stored in `comint-stored-incomplete-input', which is annoying and causes even more problems if prompt text is set to read-only. This change makes sure that the extracted buffer substring for current input does not include the prompt, even when input is empty or just white space. Also, introduce a regexp to use for `comint-prompt-regexp' which matches both main prompt and sub prompts, so that boundary is respected when `comint-use-prompt-regexp' is set to t. Fixes #35
1 parent 117d8cb commit e12db12

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

inf-clojure.el

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ to load that file."
167167
:type 'regexp
168168
:group 'inf-clojure)
169169

170+
(defcustom inf-clojure-comint-prompt-regexp "^\\( *#_\\|[^=> \n]+\\)=> *"
171+
"Regexp to recognize both main prompt and subprompt for comint.
172+
This should usually be a combination of `inf-clojure-prompt' and
173+
`inf-clojure-subprompt'."
174+
:type 'regexp
175+
:group 'inf-clojure)
176+
170177
(defvar inf-clojure-buffer nil
171178
"The current inf-clojure process buffer.
172179
@@ -253,7 +260,7 @@ If `comint-use-prompt-regexp' is nil (the default), \\[comint-insert-input] on o
253260
Paragraphs are separated only by blank lines. Semicolons start comments.
254261
If you accidentally suspend your process, use \\[comint-continue-subjob]
255262
to continue it."
256-
(setq comint-prompt-regexp inf-clojure-prompt)
263+
(setq comint-prompt-regexp inf-clojure-comint-prompt-regexp)
257264
(setq mode-line-process '(":%s"))
258265
(clojure-mode-variables)
259266
(inf-clojure-eldoc-setup)
@@ -268,7 +275,7 @@ to continue it."
268275
(save-excursion
269276
(let ((end (point)))
270277
(backward-sexp)
271-
(buffer-substring (point) end))))
278+
(buffer-substring (max (point) (comint-line-beginning-position)) end))))
272279

273280
(defun inf-clojure-input-filter (str)
274281
"Return t if STR does not match `inf-clojure-filter-regexp'."

0 commit comments

Comments
 (0)