Commits

lotabout committed 5ece596

fix context switch problem.

Comments (0)

Files changed (2)

 *~
+*.bak

swank-newlisp/swank-newlisp.lsp

 (define (error-number err) (if (list? err) (nth 0 err) -1))
 (define (error-text err) (if (list? err) (nth 1 err) "What error?"))
 
+;(define (find-context obj)
+;  "Return context named OBJ. If not found, then return nil."
+;  (let ((x (cond ((string? obj) (eval-string obj MAIN nil))
+;                 ((symbol? obj) (eval-string (term obj) MAIN nil))
+;                 ("else" obj))))
+;    (if (context? x) x nil)))
 (define (find-context obj)
-  "Return context named OBJ. If not found, then return nil."
-  (let ((x (cond ((string? obj) (eval-string obj MAIN nil))
-                 ((symbol? obj) (eval-string (term obj) MAIN nil))
-                 ("else" obj))))
-    (if (context? x) x nil)))
+ "Return context named OBJ. If not found, then return nil."
+ (let ((x (cond ((string? obj) (eval-string obj MAIN nil))
+                ((symbol? obj) (eval-string (term obj) MAIN nil))
+                ("else" obj))))
+   (if (context? x) x nil)))
 
 (define symbol-name term)
 (define context-name prefix)
 
 (define (emacs-new-package ctx)
   (send-to-emacs (list ":new-package"
-                       (context-name ctx)
+                       (string ctx)
                        (context-string-for-prompt ctx))))
 
 (define (encode-message message stream)
 (define (eval-string-for-emacs str)
   (let ((value
          ;; DO EVAL
-         (eval-string str *buffer-context* *error-object*)))
+         ;(eval-string str *buffer-context* *error-object*)))
+         (eval (read-expr str *buffer-context* *error-object*))))
     (prog1
         (cond
           ((error? value)
 
 (define (set-context-maybe str)
   (when (regex "\\(context '?(\\w+)\\)" str)
-    (let (cname (find-context (last (read-expr $0))))
+    ;(let (cname (find-context (last (read-expr $0))))
+    (let ((cname (find-context (read-expr $1))))
       (set-context cname)
       (emacs-new-package cname))))
 
 ;; snarf-string
 ;; call-compiler
 
-(defslimefun simple-completions (str package) '(nil nil))
+;(defslimefun simple-completions (str package) '(nil nil))
+(defslimefun simple-completions (str default-package-name &key limit time-limit-in-msec)
+  (list (filter (lambda (e) (regex (string "^" str) e)) 
+          (map string (symbols (eval-string default-package-name))))))
+
 (defslimefun list-all-package-names (str)
   (map name (list-all-contexts)))
 
 
 ;;;; Fuzzy Symbol Completion
 
-;; see: contrib/swank-fuzzy.lisp
+; see: contrib/swank-fuzzy.lisp
 (defslimefun fuzzy-completions
     (str default-package-name &key limit time-limit-in-msec)
   '(() nil) )