branch: elpa/forth-mode
commit c64035c20934cd60ad948816f031451ba7fd0599
Author: Lars Brinkhoff <[email protected]>
Commit: Lars Brinkhoff <[email protected]>
Add backends for Forth implementations.
---
backend/gforth.el | 1 +
backend/lbforth.el | 1 +
backend/pforth.el | 1 +
backend/spforth.el | 1 +
backend/swiftforth.el | 1 +
backend/vfxforth.el | 1 +
forth-interaction-mode.el | 10 ++++++++--
7 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/backend/gforth.el b/backend/gforth.el
new file mode 100644
index 0000000000..e05c8425c6
--- /dev/null
+++ b/backend/gforth.el
@@ -0,0 +1 @@
+(provide 'gforth)
diff --git a/backend/lbforth.el b/backend/lbforth.el
new file mode 100644
index 0000000000..c90a3b47a3
--- /dev/null
+++ b/backend/lbforth.el
@@ -0,0 +1 @@
+(provide 'lbforth)
diff --git a/backend/pforth.el b/backend/pforth.el
new file mode 100644
index 0000000000..a6f1398db6
--- /dev/null
+++ b/backend/pforth.el
@@ -0,0 +1 @@
+(provide 'pforth)
diff --git a/backend/spforth.el b/backend/spforth.el
new file mode 100644
index 0000000000..21d08fa2a5
--- /dev/null
+++ b/backend/spforth.el
@@ -0,0 +1 @@
+(provide 'spforth)
diff --git a/backend/swiftforth.el b/backend/swiftforth.el
new file mode 100644
index 0000000000..84b749cb98
--- /dev/null
+++ b/backend/swiftforth.el
@@ -0,0 +1 @@
+(provide 'swiftforth)
diff --git a/backend/vfxforth.el b/backend/vfxforth.el
new file mode 100644
index 0000000000..5504a3a7d7
--- /dev/null
+++ b/backend/vfxforth.el
@@ -0,0 +1 @@
+(provide 'vfxforth)
diff --git a/forth-interaction-mode.el b/forth-interaction-mode.el
index 524f41025c..f3f15de847 100644
--- a/forth-interaction-mode.el
+++ b/forth-interaction-mode.el
@@ -5,6 +5,8 @@
(defvar forth-interaction-callback nil)
(defvar forth-words-cache nil)
(defvar forth-implementation nil)
+(defvar forth-banner "")
+(defvar forth-backend-dir (concat default-directory "backend"))
(defvar forth-implementation-matches
'(("Gforth" . gforth)
@@ -28,9 +30,11 @@
(defun forth-interaction-preoutput-filter (text)
(unless forth-implementation
+ (setq forth-banner (concat forth-banner text))
(dolist (x forth-implementation-matches)
- (when (string-match (car x) text)
- (setq forth-implementation (cdr x)))))
+ (when (string-match (car x) forth-banner)
+ (let ((load-path (cons forth-backend-dir load-path)))
+ (require (setq forth-implementation (cdr x)))))))
(if forth-interaction-callback
(funcall forth-interaction-callback text)
text))
@@ -56,6 +60,8 @@
(defun run-forth ()
"Start an interactive forth session."
(interactive)
+ (setq forth-implementation nil)
+ (setq forth-banner "")
(unless forth-executable
(setq forth-executable
(read-string "Forth executable: ")))