From 55edd1149d0c6dd94be7850adc4977104280bb98 Mon Sep 17 00:00:00 2001 From: Darren Hoo Date: Tue, 21 May 2013 15:01:11 +0800 Subject: yank input if point is over history input --- elisp/geiser-repl.el | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 1d1b317..fca1c74 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -525,15 +525,28 @@ module command as a string") (narrow-to-region (geiser-repl--last-prompt-end) (point-max)) (geiser-syntax--nesting-level))) +(defun geiser-repl--mark-input-bounds (beg end) + (add-text-properties beg end '(field t))) + +(defun geiser-repl--is-history-input () + (get-text-property (if (eolp) (save-excursion (comint-bol)) (point)) 'field)) + +(defun geiser-repl--grab-input () + (let ((pos (comint-bol))) + (goto-char (point-max)) + (insert (field-string-no-properties pos)))) + (defun geiser-repl--send-input () (let* ((proc (get-buffer-process (current-buffer))) (pmark (and proc (process-mark proc))) - (intxt (and pmark (buffer-substring pmark (point))))) + (intxt (and pmark (buffer-substring pmark (point)))) + (eob (point-max))) (when intxt (and geiser-repl-forget-old-errors-p (not (geiser-repl--is-debugging)) (compilation-forget-errors)) (geiser-repl--prepare-send) + (geiser-repl--mark-input-bounds pmark eob) (comint-send-input) (when (string-match "^\\s-*$" intxt) (comint-send-string proc (geiser-eval--scheme-str '(:ge no-values))) @@ -543,7 +556,9 @@ module command as a string") (interactive) (let ((p (point))) (cond ((< p (geiser-repl--last-prompt-start)) - (ignore-errors (compile-goto-error))) + (if (geiser-repl--is-history-input) + (geiser-repl--grab-input) + (ignore-errors (compile-goto-error)))) ((progn (end-of-line) (<= (geiser-repl--nesting-level) 0)) (geiser-repl--send-input)) (t (goto-char p) -- cgit v1.2.3