From 074ac6af53c750039f6b32d6fb8ba0371fa4771d Mon Sep 17 00:00:00 2001 From: defanor Date: Thu, 9 Nov 2017 00:35:04 +0300 Subject: pancake.el: prompt for input on RET This is useful mostly for backward search. Also ignore empty lines in embedded mode in pancake itself, and add a "pancake>" prompt. --- Pancake.hs | 12 ++++++------ pancake.el | 9 ++++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Pancake.hs b/Pancake.hs index ab27ed6..a2c37f8 100644 --- a/Pancake.hs +++ b/Pancake.hs @@ -190,12 +190,12 @@ command Forward = do _ -> liftIO $ putErrLn "Nowhere to go" command More = do st <- get - term <- liftIO setupTermFromEnv - let lineCount' = fromMaybe 25 (getCapability term termLines) - lineCount = lineCount' - div lineCount' 3 - showLines $ take lineCount $ drop (position st) (rLines $ rendered st) - modify (\s -> s { position = position st + lineCount }) - pure () + unless (embedded st) $ do + term <- liftIO setupTermFromEnv + let lineCount' = fromMaybe 25 (getCapability term termLines) + lineCount = lineCount' - div lineCount' 3 + showLines $ take lineCount $ drop (position st) (rLines $ rendered st) + modify (\s -> s { position = position st + lineCount }) command Reload = do st <- get case history st of diff --git a/pancake.el b/pancake.el index f98867c..4614749 100644 --- a/pancake.el +++ b/pancake.el @@ -346,13 +346,19 @@ (when line (goto-line line)))) +(defun pancake-prompt (&optional string) + "Prompts for input, passes it to `pancake-process'. Similar to +`pancake-input', but runs immediately." + (interactive) + (pancake-process-send (read-from-minibuffer "pancake> " string))) + (defun pancake-input (string) "Pancake input handler: opens minibuffer for input. Sets the initial contents to STRING, reads the rest, and passes it to `pancake-process' as input." (lambda () (interactive) - (pancake-process-send (read-from-minibuffer "" string)))) + (pancake-prompt string))) (defvar pancake-mode-map (let ((map (make-sparse-keymap)) @@ -368,6 +374,7 @@ it to `pancake-process' as input." (define-key map (kbd "") 'pancake-go-forward) (define-key map (kbd "TAB") 'pancake-next-button) (define-key map (kbd "") 'pancake-previous-button) + (define-key map (kbd "RET") 'pancake-prompt) (define-key map (kbd "C-c C-c") 'pancake-interrupt) (define-key map (kbd "C-c C-u") 'pancake-display-current-uri) (define-key map (kbd "C-M-e") 'pancake-next-heading) -- cgit v1.2.3