From 417405d84ddb65494633c1716c701b983161ec7d Mon Sep 17 00:00:00 2001 From: Markus Hauck Date: Tue, 9 Dec 2014 09:07:32 +0100 Subject: [PATCH] Jump to next/previous prompt in haskell-interactive-mode New functions: - `haskell-interactive-mode-next-prompt` - `haskell-interactive-mode-prev-prompt` New keybindings in `haskell-interactive-mode-map`: - `C-c C-n` jump to next prompt - `C-c C-p` jump to previous prompt --- haskell-interactive-mode.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/haskell-interactive-mode.el b/haskell-interactive-mode.el index 5cfc5f3a7..949a9d741 100644 --- a/haskell-interactive-mode.el +++ b/haskell-interactive-mode.el @@ -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-") 'haskell-interactive-mode-history-previous) (define-key map (kbd "C-") 'haskell-interactive-mode-history-next) (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." (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)