Tamas Kovacs avatar Tamas Kovacs committed 0503dc2

Version 0.2.2

Fixed REPL input and output mix-up problems, evaluation performance enhancement, corrected some more macroexpand problems.

Comments (0)

Files changed (3)

-*slimv.txt*                    Slimv                 Last Change: 04 Mar 2009
+*slimv.txt*                    Slimv                 Last Change: 08 Mar 2009
 
 Slimv                                                                  *slimv*
-                               Version 0.2.1
+                               Version 0.2.2
 
 The Superior Lisp Interaction Mode for Vim.
 This plugin is aimed to help Lisp development by interfacing between Vim and
 INSTALLATION                                               *slimv-installation*
 
 Prerequisites:
-  - Lisp (any Common Lisp implementation should be OK) installed.
+  - Lisp (any Common Lisp implementation should be OK) or Clojure installed.
   - Python 2.4 or later installed.
   - The interrupt functionality needs the pywin32 extension on Windows.
 
 ===============================================================================
 CHANGE LOG                                                    *slimv-changelog*
 
+0.2.2  - Fixed REPL input and output mix-up problems.
+       - Evaluation performance enhancement.
+       - Corrected some more macroexpand problems.
+
 0.2.1  - Added basic Clojure support.
        - Corrected some macroexpand problems.
        - Fixed a REPL buffer refresh bug.
 #
 # Client/Server code for Slimv
 # slimv.py:     Client/Server code for slimv.vim plugin
-# Version:      0.2.1
-# Last Change:  04 Mar 2009
+# Version:      0.2.2
+# Last Change:  08 Mar 2009
 # Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 # License:      This file is placed in the public domain.
 #               No warranty, express or implied.
 import time
 import shlex
 import socket
+import traceback
 from subprocess import Popen, PIPE, STDOUT
 from threading import Thread, BoundedSemaphore
 
     server.send( lstr )     # send message length first
     server.send( line )     # then the message itself
 
-    time.sleep(0.01)        # give a little chance to receive some output from the REPL before the next query
-                            #TODO: synchronize it correctly
-
 
 def client_file( input_filename ):
     """Main client routine - input file version:
         file = open( input_filename, 'rt' )
         try:
             # Send contents of the file to the server
+            lines = ''
             for line in file:
-                send_line( s, line.rstrip( '\n' ) )
+                lines = lines + line
+            send_line( s, lines )
         finally:
             file.close()
     except:
                             # Semaphore to synchronize access to the global display queue
 
     def setfile( self, filename ):
+        """Set output filename
+        """
         self.sema.acquire()
         self.filename = filename
         self.sema.release()
 
-    def write( self, text, fileonly=False ):
-        """Write text into the global display queue buffer.
+    def writebegin( self ):
+        """Begin the writing process. The process is protected by a semaphore.
         """
         self.sema.acquire()
+
+    def writeend( self ):
+        """Finish the writing process. Release semaphore
+        """
+        self.sema.release()
+
+    def write_nolock( self, text, fileonly=False ):
+        """Write text into the global display queue buffer.
+           The writing process is not protected.
+        """
         if not fileonly:
             try:
                 # Write all lines to the display
                         file.close()
                     tries = 0
                 except:
+                    #traceback.print_exc()
                     tries = tries - 1
         elif len( self.buffer ) < 2000:
             # No filename supplied, collect output info a buffer until filename is given
             # We collect only some bytes, then probably no filename will be given at all
             self.buffer = self.buffer + text
-        self.sema.release()
+
+    def write( self, text, fileonly=False ):
+        """Write text into the global display queue buffer.
+           The writing process is protected by a semaphome.
+        """
+        self.writebegin()
+        self.write_nolock( text, fileonly )
+        self.writeend()
 
 
 class socket_listener( Thread ):
                                 # Go on without interruption
                                 pass
                         if len(command) >= 8 and command[0:8] == 'OUTPUT::':
-                            output_filename = command[8:]
+                            output_filename = command[8:].rstrip( '\n' )
                             self.buffer.setfile( output_filename )
                     else:
                         # Fork here: write message to the stdin of REPL
                         # and also write it to the display (display queue buffer)
-                        self.inp.write   ( received + newline )
-                        self.buffer.write( received + newline )
+                        self.buffer.writebegin()
+#                        self.buffer.write_nolock( received + newline )
+#                        self.inp.write( received + newline )
+                        self.buffer.write_nolock( received )
+                        self.inp.write( received )
+                        self.buffer.writeend()
 
             conn.close()
 
 " slimv.vim:    The Superior Lisp Interaction Mode for VIM
-" Version:      0.2.1
-" Last Change:  04 Mar 2009
+" Version:      0.2.2
+" Last Change:  08 Mar 2009
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
 " Lisp prompt in the last line
 let s:prompt = ''
 
+" The current mode when REPL refresh was started
+let s:insertmode = 0
+
 
 " =====================================================================
 "  General utility functions
     call SlimvSend( a:args, g:slimv_repl_open )
 endfunction
 
-" Recall command from the command history at the marked position
+" Set command line after the prompt
 function! SlimvSetCommandLine( cmd )
     normal `s
     let line = getline( "." )
     else
         " The form is a 'defmacro', so do a macroexpand from the macro name and parameters
         if SlimvGetFiletype() == 'clojure'
-            normal vt[%"sy
+	    " Some Vim configs (e.g. matchit.vim) include the trailing ']' after '%' in Visual mode
+            normal vt[%ht]"sy
         else
-            normal vt(%"sy
-        endif
-        let m = SlimvGetSelection()
-        if m[ len(m) - 1 ] == ']' || m[ len(m) - 1 ] == ')'
-            " Some Vim configs include the trailing ']' here, others don't
-            " TODO: check out why
-            let m = strpart( m, 0, len(m) - 1 )
+            normal vt(])"sy
         endif
-        let m = m . '))'
+        let m = SlimvGetSelection() . '))'
         let m = substitute( m, "defmacro\\s*", a:command . " '(", 'g' )
         if SlimvGetFiletype() == 'clojure'
             " Remove opening bracket from the parameter list
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.