Commits

lotabout committed 5f1e19f

fix simple-completions for newlisp.

  • Participants
  • Parent commits 5ece596

Comments (0)

Files changed (4)

File ftplugin/newlisp/slimv-newlisp.vim

 
 " Try to autodetect SWANK and build the command to load the SWANK server
 function! b:SlimvSwankLoader()
-    echom "SlimvSwankLoader: g:slimv_impl=" g:slimv_impl
     if g:slimv_impl == 'newlisp'
         let swanks = split( globpath( &runtimepath, 'swank-newlisp/swank-newlisp.lsp'), '\n' )
         if len( swanks ) == 0

File ftplugin/slimv.vim

     endif
     while s:swank_action == '' && localtime()-starttime < cmd_timeout
         python swank_output( 0 )
-        redir => msg
+        "redir => msg
+        "silent execute 'python swank_response("' . a:name . '")'
+        "redir END
         silent execute 'python swank_response("' . a:name . '")'
-        redir END
     endwhile
     let s:refresh_disabled = 0
     return msg

File ftplugin/swank.py

 sock            = None          # Swank socket object
 id              = 0             # Message id
 debug           = False
-log             = False         # Set this to True in order to enable logging
-logfile         = 'swank.log'   # Logfile name in case logging is on
+log             = True          # Set this to True in order to enable logging
+logfile         = '/home/ice/swank.log'   # Logfile name in case logging is on
 pid             = '0'           # Process id
 current_thread  = '0'
 use_unicode     = True          # Use unicode message length counting
 
                     if result == ':ok':
                         params = r[1][1]
-                        logprint('params: ' + str(params))
                         if type(params) == str:
                             element = params.lower()
                             to_ignore = [':frame-call', ':quit-inspector', ':kill-thread', ':debug-thread']
     #logtime('[-Response-]')
     for k,a in sorted(actions.items()):
         if not a.pending and (name == '' or name == a.name):
+            logprint("a.name="+a.name+"\ta.result="+a.result+"\n")
             vc = ":let s:swank_action='" + a.name + "'"
             vim.command(vc)
-            sys.stdout.write(a.result)
+            #sys.stdout.write(a.result)
+            # Note that stream catch might not work;
+            rc = ":let msg='" + a.result+ "'"
+            vim.command(rc)
             actions.pop(a.id)
             actions_pending()
             return
     vc = ":let s:swank_action=''"
     vim.command(vc)
     actions_pending()
-

File swank-newlisp/swank-newlisp.lsp

 (define (eval-string-for-emacs str)
   (let ((value
          ;; DO EVAL
-         ;(eval-string str *buffer-context* *error-object*)))
-         (eval (read-expr str *buffer-context* *error-object*))))
+         (eval-string str *buffer-context* *error-object*)))
+         ;(eval (read-expr str *buffer-context* *error-object*))))
     (prog1
         (cond
           ((error? value)
 ;; call-compiler
 
 ;(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 simple-completions (str default-package-name &key limit time-limit-in-msec) 
+  (letn ((idx (find ":" str))
+         (ctx-name (if idx (0 idx str) default-package-name))
+         (sym-name (if idx ((+ idx 1) str) str))
+         (completions (filter (lambda (e) (regex (string "^" ctx-name ":" sym-name) e)) 
+                        (map string (symbols (eval-string ctx-name)))))
+         (default-completions (filter (lambda (e) (regex (string "^" str) e)) 
+                                (map string (symbols MAIN)))))
+    (list (append (if idx completions (map (lambda (e) ((+ (length ctx-name) 1) e)) completions))
+            default-completions))
+    
+    ))
+;(defslimefun simple-completions (str default-package-name &key limit time-limit-in-msec)
+;  (append 
+;    (list (filter (lambda (e) (regex (string "^" default-package-name ":" str) e)) 
+;          (map string (symbols (eval-string default-package-name)))))  
+;    (list (filter (lambda (e) (regex (string "^" str) e)) 
+;          (map string (symbols MAIN))))))
 
 (defslimefun list-all-package-names (str)
   (map name (list-all-contexts)))