branch: elpa/forth-mode
commit 3047dfa37a82e3f0f188b0926c92f50a2699f71c
Author: Lars Brinkhoff <[email protected]>
Commit: Lars Brinkhoff <[email protected]>
Run a subprocess Forth for interaction.
---
forth-interaction-mode.el | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/forth-interaction-mode.el b/forth-interaction-mode.el
index 74dc7696b7..ad298bf172 100644
--- a/forth-interaction-mode.el
+++ b/forth-interaction-mode.el
@@ -1,3 +1,34 @@
+(require 'comint)
+
+(defvar forth-interaction-mode-map
+ (let ((map (copy-keymap forth-mode-map)))
+ (set-keymap-parent map comint-mode-map)
+ (define-key map (kbd "C-c C-k") 'forth-interaction-kill)
+ map)
+ "Keymap for Forth interaction.")
+
(define-derived-mode forth-interaction-mode comint-mode "Forth Interaction"
"Major mode for interacting with Forth."
- :syntax-table forth-interaction-mode-syntax-table)
+ :syntax-table forth-mode-syntax-table
+ (use-local-map forth-interaction-mode-map))
+
+(defun forth-interaction-kill (&optional buffer)
+ (interactive)
+ (kill-buffer (or buffer (current-buffer))))
+
+(defun forth-interaction-sentinel (proc arg)
+ (message "Forth: %s" arg)
+ (forth-interaction-kill (process-buffer proc)))
+
+;;;### autoload
+(defun forth ()
+ "Start an interactive forth session."
+ (interactive)
+ (let ((buffer (get-buffer-create "*forth*")))
+ (pop-to-buffer-same-window buffer)
+ (unless (comint-check-proc buffer)
+ (make-comint-in-buffer "forth" buffer "forth")
+ (set-process-sentinel (get-buffer-process buffer)
+ 'forth-interaction-sentinel)
+ (forth-interaction-mode))))
+