summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Hoo <darren.hoo@gmail.com>2013-05-21 15:01:11 +0800
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-05-21 18:48:41 +0200
commit55edd1149d0c6dd94be7850adc4977104280bb98 (patch)
treef960964dd5951ad670700427b5299d20eabcccd3
parentdd27853ab0cf3d812438529614a6295a5cf4def5 (diff)
downloadgeiser-55edd1149d0c6dd94be7850adc4977104280bb98.tar.gz
geiser-55edd1149d0c6dd94be7850adc4977104280bb98.tar.bz2
yank input if point is over history input
-rw-r--r--elisp/geiser-repl.el19
1 files 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)