From 619015bbe0dc2596e92ba6897d844b5324452aaa Mon Sep 17 00:00:00 2001 From: defanor Date: Sat, 28 Oct 2017 07:30:27 +0300 Subject: Add backward/forward/quit pancake-mode commands Now it is easier to quickly go through the history. --- pancake.el | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'pancake.el') diff --git a/pancake.el b/pancake.el index 57cb848..af6bf6f 100644 --- a/pancake.el +++ b/pancake.el @@ -250,15 +250,32 @@ (interactive) (funcall (pancake-input (gui-get-primary-selection)))) +(defun pancake-process-send (line) + "Send LINE to the pancake process." + (process-send-string pancake-process (concat line "\n"))) + +(defun pancake-go-backward () + "Go backward in history." + (interactive) + (pancake-process-send "b")) + +(defun pancake-go-forward () + "Go forward in history." + (interactive) + (pancake-process-send "f")) + +(defun pancake-quit () + "Quit pancake." + (interactive) + (pancake-process-send "q")) + (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) - (process-send-string - pancake-process - (concat (read-from-minibuffer "" string) "\n")))) + (pancake-process-send (read-from-minibuffer "" string)))) (defvar pancake-mode-map (let ((map (make-sparse-keymap)) @@ -271,6 +288,9 @@ it to `pancake-process' as input." (define-key map (kbd "C-y") 'pancake-yank) (define-key map (kbd "") 'pancake-yank-primary) (define-key map (kbd "C-c C-c") 'pancake-interrupt) + (define-key map (kbd "B") 'pancake-go-backward) + (define-key map (kbd "F") 'pancake-go-forward) + (define-key map (kbd "Q") 'pancake-quit) map) "Keymap for `pancake-mode'.") -- cgit v1.2.3