[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Geiser-users] feature missed in geiser-repl

From: Darren Hoo
Subject: [Geiser-users] feature missed in geiser-repl
Date: Wed, 22 May 2013 00:31:03 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (darwin)

Slime REPL has a feature that if you put the point over the old repl
input  then hit enter, the old repl input will be yanked into the repl
again to the end of the comint buffer. I find it is very convenient way
of going through the repl input  history besides cycling through the
history using keybindings M-n and M-p.

How about adding this feature to geiser-repl?

--8<---------------cut here---------------start------------->8---
>From 31407eac6011bd6224699b95d4c9e723b83e67f2 Mon Sep 17 00:00:00 2001
From: Darren Hoo <address@hidden>
Date: Tue, 21 May 2013 15:01:11 +0800
Subject: [PATCH] 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..87c1588 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))
+(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))
+      (geiser-repl--mark-input-bounds pmark eob)
       (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")
   (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))
           (t (goto-char p)

--8<---------------cut here---------------end--------------->8---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]