summaryrefslogtreecommitdiff
path: root/pancake.el
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-10-28 03:55:31 +0300
committerdefanor <defanor@uberspace.net>2017-10-28 04:03:05 +0300
commitdf97f9ad38e54107ef433ccd00d67b9315701b2b (patch)
tree494864c7af3aa91dab9617dc362a25fb715978de /pancake.el
parentd2da10d36b857e399e10388ddc6f66850211ec77 (diff)
Handle yanking in pancake-mode
Diffstat (limited to 'pancake.el')
-rw-r--r--pancake.el28
1 files changed, 21 insertions, 7 deletions
diff --git a/pancake.el b/pancake.el
index 33bbee0..c90c1e8 100644
--- a/pancake.el
+++ b/pancake.el
@@ -235,22 +235,36 @@
(buffer-live-p (process-buffer process)))
(kill-buffer (process-buffer process))))
-(defun pancake-input (char)
+(defun pancake-yank ()
+ "Insert a string."
+ (interactive)
+ (funcall (pancake-input (current-kill 0))))
+
+(defun pancake-yank-primary ()
+ "Insert a string from the primary selection."
+ (interactive)
+ (funcall (pancake-input (gui-get-primary-selection))))
+
+(defun pancake-input (string)
"Pancake input handler: opens minibuffer for input.
-Sets the initial contents to CHAR, reads the rest,
-and passes it to `pancake-process' as 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 "" (char-to-string char)) "\n"))))
+ (concat (read-from-minibuffer "" string) "\n"))))
(defvar pancake-mode-map
(let ((map (make-sparse-keymap))
- (chars (append (number-sequence ?0 ?9)
- (number-sequence ?a ?z))))
+ (chars (cons ??
+ (append (number-sequence ?0 ?9)
+ (number-sequence ?a ?z)))))
(dolist (char chars)
- (define-key map (char-to-string char) (pancake-input char)))
+ (let ((str (char-to-string char)))
+ (define-key map (kbd str) (pancake-input str))))
+ (define-key map (kbd "C-y") 'pancake-yank)
+ (define-key map (kbd "<mouse-2>") 'pancake-yank-primary)
map)
"Keymap for `pancake-mode'.")