summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-28 01:59:05 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-28 01:59:05 +0100
commitaf446e1e0783e3b560baa8bc6134eb6e5d282f06 (patch)
tree8acc33096521016f38af61b7b93be10e0f5802a2
parentbe1f88d86f0f72929b00903fd1cf52e459714916 (diff)
downloadgeiser-af446e1e0783e3b560baa8bc6134eb6e5d282f06.tar.gz
geiser-af446e1e0783e3b560baa8bc6134eb6e5d282f06.tar.bz2
Persistent REPL history.
-rw-r--r--elisp/geiser-repl.el36
1 files changed, 36 insertions, 0 deletions
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index b4a7f9e..ff1f920 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -67,12 +67,46 @@ REPL buffer."
:type 'boolean
:group 'geiser-repl)
+(defcustom geiser-repl-history-filename (expand-file-name "~/.geiser_history")
+ "File where REPL input history is saved, so that it persists between sessions."
+ :type 'filename
+ :group 'geiser-repl)
+
+(defcustom geiser-repl-history-size comint-input-ring-size
+ "Maximum size of the saved REPL input history."
+ :type 'integer
+ :group 'geiser-repl)
+
(defcustom geiser-repl-autodoc-p t
"Whether to enable `geiser-autodoc-mode' in the REPL by default."
:type 'boolean
:group 'geiser-repl)
+;;; REPL History:
+
+(defun geiser-repl--sentinel (proc event)
+ (when (string= event "finished\n")
+ (with-current-buffer (process-buffer proc)
+ (let ((comint-input-ring-file-name geiser-repl-history-filename))
+ (comint-write-input-ring)
+ (when (buffer-name (current-buffer))
+ (insert "\nIt's been nice to interact with you!\n")
+ (insert "Press C-cz to bring me back.\n" ))))))
+
+(defun geiser-repl--input-filter (str)
+ (and (not (string-match "^\\s *$" str))
+ (not (string-match "^,quit *$" str))))
+
+(defun geiser-repl--history-setup ()
+ (set (make-local-variable 'comint-input-ring-file-name) geiser-repl-history-filename)
+ (set (make-local-variable 'comint-input-ring-size) geiser-repl-history-size)
+ (set (make-local-variable 'comint-input-filter) 'geiser-repl--input-filter)
+ (add-hook 'kill-buffer-hook 'comint-write-input-ring nil t)
+ (comint-read-input-ring t)
+ (set-process-sentinel (get-buffer-process (current-buffer)) 'geiser-repl--sentinel))
+
+
;;; Geiser REPL buffer/process:
(defvar geiser-repl--buffer nil
@@ -98,6 +132,7 @@ REPL buffer."
(pop-to-buffer (geiser-repl--buffer))
(apply 'make-comint-in-buffer `("Geiser REPL" ,(current-buffer) ,guile nil ,@args))
(geiser-repl--wait-for-prompt 10000)
+ (geiser-repl--history-setup)
(geiser-con--setup-connection (current-buffer) geiser-repl--prompt-regex)))
(defun geiser-repl--process (&optional start)
@@ -157,6 +192,7 @@ REPL buffer."
(set (make-local-variable 'comint-prompt-regexp) geiser-repl--prompt-regex)
(set (make-local-variable 'comint-use-prompt-regexp) t)
(set (make-local-variable 'comint-prompt-read-only) t)
+ (set-syntax-table scheme-mode-syntax-table)
(when geiser-repl-autodoc-p (geiser-autodoc-mode 1)))
(define-key geiser-repl-mode-map "\C-cz" 'run-guile)