summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-11-15 03:59:47 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-11-15 03:59:47 +0100
commit9bf7ade943a755881837a28d77c4e9eb30ad8137 (patch)
treefa072150f41dfd55f8681ace43c05ae1335e462f /elisp
parent557fce4325f5dcdce89a925553edf0a22f3910b6 (diff)
downloadgeiser-9bf7ade943a755881837a28d77c4e9eb30ad8137.tar.gz
geiser-9bf7ade943a755881837a28d77c4e9eb30ad8137.tar.bz2
REPL: sexpy history file (fix for #30269)
The trick consists on using a comint-input-ring-separator that is *not* a newline, both for reading and writing the history file.
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-impl.el4
-rw-r--r--elisp/geiser-repl.el35
2 files changed, 29 insertions, 10 deletions
diff --git a/elisp/geiser-impl.el b/elisp/geiser-impl.el
index 4266cbc..4a5ce17 100644
--- a/elisp/geiser-impl.el
+++ b/elisp/geiser-impl.el
@@ -200,7 +200,9 @@ Here's how a typical call to this macro looks like:
(display-help)
(check-buffer geiser-guile--guess)
(keywords geiser-guile--keywords))
-"
+
+This macro also defines a runner function (run-NAME) and a
+switcher (switch-to-NAME), and provides geiser-NAME."
(let ((name (if (listp name) (car name) name))
(parent (and (listp name) (cadr name))))
(unless (symbolp name)
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 4ca5b2c..7acaa23 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -255,6 +255,7 @@ module command as a string")
(error "Sorry, I don't know how to start a REPL for %s" impl))
(geiser-repl--save-remote-data address)
(geiser-repl--start-scheme impl address prompt)
+ (geiser-repl--quit-setup)
(geiser-repl--history-setup)
(add-to-list 'geiser-repl--repls (current-buffer))
(geiser-repl--set-this-buffer-repl (current-buffer))
@@ -330,13 +331,33 @@ module command as a string")
(comint-redirect-results-list cmd ".+" 0))
-;;; REPL history and clean-up:
+;;; REPL history
+
+(defconst geiser-repl--history-separator "\n\0\n")
(defsubst geiser-repl--history-file ()
(format "%s.%s" geiser-repl-history-filename geiser-impl--implementation))
+(defun geiser-repl--read-input-ring ()
+ (let ((comint-input-ring-file-name (geiser-repl--history-file))
+ (comint-input-ring-separator geiser-repl--history-separator))
+ (comint-read-input-ring t)))
+
+(defun geiser-repl--write-input-ring ()
+ (let ((comint-input-ring-file-name (geiser-repl--history-file))
+ (comint-input-ring-separator geiser-repl--history-separator))
+ (comint-write-input-ring)))
+
+(defun geiser-repl--history-setup ()
+ (set (make-local-variable 'comint-input-ring-size) geiser-repl-history-size)
+ (set (make-local-variable 'comint-input-filter) 'geiser-repl--input-filter)
+ (geiser-repl--read-input-ring))
+
+
+;;; Cleaning up on quit
+
(defun geiser-repl--on-quit ()
- (comint-write-input-ring)
+ (geiser-repl--write-input-ring)
(let ((cb (current-buffer))
(impl geiser-impl--implementation)
(comint-prompt-read-only nil))
@@ -355,7 +376,8 @@ module command as a string")
(when (buffer-live-p pb)
(with-current-buffer pb
(let ((comint-prompt-read-only nil)
- (comint-input-ring-file-name (geiser-repl--history-file)))
+ (comint-input-ring-file-name (geiser-repl--history-file))
+ (comint-input-ring-separator geiser-repl--history-separator))
(geiser-repl--on-quit)
(push pb geiser-repl--closed-repls)
(goto-char (point-max))
@@ -379,14 +401,9 @@ module command as a string")
(backward-sexp)
(buffer-substring (point) end))))
-(defun geiser-repl--history-setup ()
- (set (make-local-variable 'comint-input-ring-file-name)
- (geiser-repl--history-file))
- (set (make-local-variable 'comint-input-ring-size) geiser-repl-history-size)
- (set (make-local-variable 'comint-input-filter) 'geiser-repl--input-filter)
+(defun geiser-repl--quit-setup ()
(set (make-local-variable 'comint-get-old-input) 'geiser-repl--old-input)
(add-hook 'kill-buffer-hook 'geiser-repl--on-kill nil t)
- (comint-read-input-ring t)
(set-process-sentinel (get-buffer-process (current-buffer))
'geiser-repl--sentinel))