Skip to content

Commit 12da44f

Browse files
committed
Merge pull request #391 from markus1189/jump-prompts
Jump to next/previous prompt in haskell-interactive-mode
2 parents d412c0c + 417405d commit 12da44f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

haskell-interactive-mode.el

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ interference with prompts that look like haskell expressions."
7676
(define-key map (kbd "C-c C-z") 'haskell-interactive-switch-back)
7777
(define-key map (kbd "M-p") 'haskell-interactive-mode-history-previous)
7878
(define-key map (kbd "M-n") 'haskell-interactive-mode-history-next)
79+
(define-key map (kbd "C-c C-p") 'haskell-interactive-mode-prompt-previous)
80+
(define-key map (kbd "C-c C-n") 'haskell-interactive-mode-prompt-next)
7981
(define-key map (kbd "C-<up>") 'haskell-interactive-mode-history-previous)
8082
(define-key map (kbd "C-<down>") 'haskell-interactive-mode-history-next)
8183
(define-key map (kbd "TAB") 'haskell-interactive-mode-tab)
@@ -960,6 +962,21 @@ don't care when the thing completes as long as it's soonish."
960962
(setq haskell-interactive-mode-history-index 0)
961963
(haskell-interactive-mode-history-toggle -1))))
962964

965+
(defun haskell-interactive-mode-prompt-previous ()
966+
"Jump to the previous prompt."
967+
(interactive)
968+
(let ((prev-prompt-pos
969+
(save-excursion
970+
(beginning-of-line) ;; otherwise prompt at current line matches
971+
(and (search-backward-regexp (haskell-interactive-prompt-regex) nil t)
972+
(match-end 0)))))
973+
(when prev-prompt-pos (goto-char prev-prompt-pos))))
974+
975+
(defun haskell-interactive-mode-prompt-next ()
976+
"Jump to the next prompt."
977+
(interactive)
978+
(search-forward-regexp (haskell-interactive-prompt-regex) nil t))
979+
963980
(defun haskell-interactive-mode-clear ()
964981
"Clear the screen and put any current input into the history."
965982
(interactive)

0 commit comments

Comments
 (0)