Skip to content

Add haskell-interactive-copy-to-prompt. #457

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

Merged
merged 1 commit into from
Mar 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions haskell-interactive-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ be nil.")
(switch-to-buffer-other-window haskell-interactive-previous-buffer)
(message "No previous buffer.")))

(defun haskell-interactive-copy-to-prompt ()
"Copy the current line to the prompt, overwriting the current
prompt."
(interactive)
(let ((l (buffer-substring-no-properties (line-beginning-position)
(line-end-position))))
;; If it looks like the prompt is at the start of the line, chop
;; it off.
(when (and (>= (length l) (length haskell-interactive-prompt))
(string= (substring l 0 (length haskell-interactive-prompt))
haskell-interactive-prompt))
(setq l (substring l (length haskell-interactive-prompt))))

(haskell-interactive-mode-set-prompt l)))

(defun haskell-interactive-mode-space (n)
"Handle the space key."
(interactive "p")
Expand Down
9 changes: 8 additions & 1 deletion haskell.el
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,17 @@
"Handle the return key."
(interactive)
(cond
;; At a compile message, jump to the location of the error in the
;; source.
((haskell-interactive-at-compile-message)
(next-error-internal))
;; At the input prompt, handle the expression in the usual way.
((haskell-interactive-at-prompt)
(haskell-interactive-handle-expr))
;; At any other location in the buffer, copy the line to the
;; current prompt.
(t
(haskell-interactive-handle-expr))))
(haskell-interactive-copy-to-prompt))))

;;;###autoload
(defun haskell-session-kill (&optional leave-interactive-buffer)
Expand Down