about summary refs log tree commit diff stats
path: root/cmd.lsp
diff options
context:
space:
mode:
Diffstat (limited to 'cmd.lsp')
-rw-r--r--cmd.lsp28
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd.lsp b/cmd.lsp
new file mode 100644
index 0000000..e186a4e
--- /dev/null
+++ b/cmd.lsp
@@ -0,0 +1,28 @@
+(defpackage #:cmd
+  (:use #:openlisp)
+  (:export
+    #:parse
+    #:create-tab
+    #:fun
+    #:lookup)
+  )
+(in-package #:cmd)
+(defclass <buf> () ((buf :initarg b :reader buf)
+                     (f :initarg f :reader f)))
+(defconstant +ht+ (convert 9 <character>))
+(defun parse (p)
+  (let ((toks (string-split (list #\Space +ht+) p)))
+    (create (class <buf>) 'b (car toks) 'f toks)))
+(defclass <tab> () ((fun :initarg f :reader fun)
+                     (cmd :initarg c :reader cmd)
+                     (narg :initarg n :reader narg)))
+(defun create-tab (f c n)
+  (create (class <tab>) 'f f 'c c 'n n))
+(defgeneric lookup (buf tabs))
+(defmethod lookup ((buf <buf>) tabs)
+  (let ((cmd (buf buf)))
+    (find-if (lambda (tab)
+               (let ((c (cmd tab)))
+                 (string= c cmd)))
+      tabs)))
+(provide "cmd")