Skip to content

Jump to next/previous prompt in haskell-interactive-mode #391

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
Jan 17, 2015
Merged
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
17 changes: 17 additions & 0 deletions haskell-interactive-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ interference with prompts that look like haskell expressions."
(define-key map (kbd "C-c C-z") 'haskell-interactive-switch-back)
(define-key map (kbd "M-p") 'haskell-interactive-mode-history-previous)
(define-key map (kbd "M-n") 'haskell-interactive-mode-history-next)
(define-key map (kbd "C-c C-p") 'haskell-interactive-mode-prompt-previous)
(define-key map (kbd "C-c C-n") 'haskell-interactive-mode-prompt-next)
(define-key map (kbd "C-<up>") 'haskell-interactive-mode-history-previous)
(define-key map (kbd "C-<down>") 'haskell-interactive-mode-history-next)
(define-key map (kbd "TAB") 'haskell-interactive-mode-tab)
Expand Down Expand Up @@ -960,6 +962,21 @@ don't care when the thing completes as long as it's soonish."
(setq haskell-interactive-mode-history-index 0)
(haskell-interactive-mode-history-toggle -1))))

(defun haskell-interactive-mode-prompt-previous ()
"Jump to the previous prompt."
(interactive)
(let ((prev-prompt-pos
(save-excursion
(beginning-of-line) ;; otherwise prompt at current line matches
(and (search-backward-regexp (haskell-interactive-prompt-regex) nil t)
(match-end 0)))))
(when prev-prompt-pos (goto-char prev-prompt-pos))))

(defun haskell-interactive-mode-prompt-next ()
"Jump to the next prompt."
(interactive)
(search-forward-regexp (haskell-interactive-prompt-regex) nil t))

(defun haskell-interactive-mode-clear ()
"Clear the screen and put any current input into the history."
(interactive)
Expand Down