Commits

Tamas Kovacs committed 812a557

Version 0.6.2

Added support for Mac OS X via Terminal.app (on behalf of Vlad Hanciuta), added string "clj" as a detector for Clojure (by Vlad Hanciuta), bugfixes: paredit wrap function missed last character when 'selection' was not "exclusive" (thanks to Marcin Fatyga), input was stuck inside SBCL debugger (on behalf of Philipp Marek and Dmitry Petukhov), occasional error messages during REPL buffer update, REPL menu was sometimes missing, occasional command line color problems.

  • Participants
  • Parent commits 1d0faae

Comments (0)

Files changed (4)

-*slimv.txt*                    Slimv                 Last Change: 27 Apr 2010
+*slimv.txt*                    Slimv                 Last Change: 09 Jun 2010
 
 Slimv                                                                  *slimv*
-                               Version 0.6.1
+                               Version 0.6.2
 
 The Superior Lisp Interaction Mode for Vim.
 This plugin is aimed to help Lisp development by interfacing between Vim and
 the Lisp REPL, similarly to Emacs/SLIME.
-Slimv works on Windows and Linux, however the newly introduced paredit mode
-is operating system independent.
+Slimv works on Windows, Linux, and Mac OS X, however the newly introduced
+paredit mode is operating system independent.
 
 |slimv-installation|         Installation
 |slimv-customization|        Customization
 ===============================================================================
 CHANGE LOG                                                    *slimv-changelog*
 
+0.6.2  - Added support for Mac OS X via Terminal.app (on behalf of Vlad Hanciuta).
+       - Added string "clj" as a detector for Clojure (by Vlad Hanciuta).
+       - Bugfix: paredit wrap function missed last character when 'selection'
+         was not "exclusive" (thanks to Marcin Fatyga).
+       - Bugfix: input was stuck inside SBCL debugger
+         (on behalf of Philipp Marek and Dmitry Petukhov).
+       - Bugfix: occasional error messages during REPL buffer update.
+       - Bugfix: REPL menu was sometimes missing.
+       - Bugfix: occasional command line color problems.
+
 0.6.1  - Added Split, Join, Wrap, Splice functions to Paredit Mode.
        - Added g:paredit_shortmaps to select short/long paredit keymaps.
        - Bugfix: delete commands put erased characters into yank buffer.
 Also special thanks to Erik Naggum, Yuji Minejima and others for making the
 Common Lisp Hyperspec lookup packages for SLIME, and thanks to
 Taylor R. Campbell for the Emacs paredit.el script.
-Thanks to the Vim community for testing and commenting the script.
+Thanks to the Vim community for testing, commenting and patching the script,
+especially to Philipp Marek, Vlad Hanciuta, Marcin Fatyga, Dmitry Petukhov,
+Daniel Solano G�mez.
 Last but not least many thanks to my wife Andrea (for the Italians out there:
 hey, this is a female name in Hungary :) for her support and patience.
 

ftplugin/slimv.py

 #
 # Client/Server code for Slimv
 # slimv.py:     Client/Server code for slimv.vim plugin
-# Version:      0.5.5
-# Last Change:  08 Jan 2010
+# Version:      0.6.2
+# Last Change:  01 Jun 2010
 # Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 # License:      This file is placed in the public domain.
 #               No warranty, express or implied.
 
 newline     = '\n'
 
-# Are we running on Windows (otherwise assume Linux, sorry for other OS-es)
+# Check if we're running Windows or Mac OS X, otherwise assume Linux
 mswindows = (sys.platform == 'win32')
+darwin = (sys.platform == 'darwin')
 
+if not (mswindows or darwin):
+    import pty
 
 def log( s, level ):
     """Print diagnostic messages according to the actual debug level.
     """
     if run_cmd == '':
         # Complex run command not given, build it from the information available
-        if mswindows:
+        if mswindows or darwin:
             cmd = []
         else:
             cmd = ['xterm', '-T', 'Slimv', '-e']
     if mswindows:
         CREATE_NEW_CONSOLE = 16
         server = Popen( cmd, creationflags=CREATE_NEW_CONSOLE )
+    elif darwin:
+        from ScriptingBridge import SBApplication
+
+        term = SBApplication.applicationWithBundleIdentifier_("com.apple.Terminal")
+        term.doScript_in_(" ".join(cmd) + " ; exit", 0) 
     else:
         server = Popen( cmd )
 
                         # and also write it to the display (display queue buffer)
                         self.buffer.writebegin()
                         self.buffer.write_nolock( received )
-                        self.inp.write( received )
+                        os.write(self.inp.fileno(), received)
                         self.buffer.writeend()
 
             conn.close()
                             self.buffer.write( c2 )
                     else:
                         self.buffer.write( c )
-                else:
+                elif darwin:
                     c = self.out.read( 1 )
                     self.buffer.write( c )
+                else:
+                    c = self.out.read( 1 )
+                    if ord( c ) != 0x0D:
+                        self.buffer.write( c )
             except:
                 terminate = 1
 
     cmd = shlex.split( lisp_exp )
 
     # Start Lisp
-    repl = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT )
+    if mswindows or darwin:
+        repl = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT )
+        repl_stdin = repl.stdin
+        repl_stdout = repl.stdout
+        repl_pid = repl.pid
+    else:
+        repl_pid, repl_fd = pty.fork()
+        if repl_pid == 0:
+            os.execvp( cmd[0], cmd )
+            os._exit(1)
+        repl_stdin = repl_stdout = os.fdopen( repl_fd )
 
     buffer = repl_buffer( sys.stdout )
 
     # Create and start helper threads
-    sl = socket_listener( repl.stdin, buffer, repl.pid )
+    sl = socket_listener( repl_stdin, buffer, repl_pid )
     sl.start()
-    ol = output_listener( repl.stdout, buffer )
+    ol = output_listener( repl_stdout, buffer )
     ol.start()
 
     # Allow Lisp to start, confuse it with some fancy Slimv messages
             # Read input from the console and write it
             # to the stdin of REPL
             text = raw_input()
-            repl.stdin.write( text + newline )
+            os.write( repl_stdin.fileno(), text + newline )
             buffer.write( text + newline, True )
         except EOFError:
             # EOF (Ctrl+Z on Windows, Ctrl+D on Linux) pressed?
     # Send exit command to child process and
     # wake output listener up at the same time
     try:
-        repl.stdin.close()
+        repl_stdin.close()
     except:
         # We don't care if this above fails, we'll exit anyway
         pass

ftplugin/slimv.vim

 " slimv.vim:    The Superior Lisp Interaction Mode for VIM
-" Version:      0.6.1
-" Last Change:  26 Apr 2010
+" Version:      0.6.2
+" Last Change:  09 Jun 2010
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
         return &ft
     endif
 
-    if match( tolower( g:slimv_lisp ), 'clojure' ) >= 0
+    if match( tolower( g:slimv_lisp ), 'clojure' ) >= 0 || match( tolower( g:slimv_lisp ), 'clj' ) >= 0
         " Must be Clojure
         return 'clojure'
     endif
     endtry
     syntax on
     "TODO: use :read instead and keep only the delta in the readout file
-    if &endofline == 1
-        " Handle the situation when the last line is an empty line in REPL
-        " but Vim rejects to handle it as a separate line
-        try
-            call append( '$', "" )
-        catch /.*/
-            " OK, we cannot append right now, the server is probably busy with
-            " updating the REPL file. Just go on, it's not that important.
-        endtry
-    endif
     let insert = 0
     if mode() == 'i' || mode() == 'I'
         let insert = 1
     sleep 100m
     call SlimvRefreshReplBufferNow()
 
-    let save_ve = &ve
     if s:insertmode
         " We are in insert mode, let's fake a movement to the right
         " in order to display the cursor at the right place.
         " For this we need to set the virtualedit=all option temporarily
         echon '-- INSERT --'
-        set ve=all
-        normal! l
+        set nomodified
     else
         " Inform user that we are in running mode (waiting for REPL output)
         echon '-- RUNNING --'
         let c = getchar(0)
     endwhile
 
+    let m = '/\%#/'
     let interrupt = 0
     let wait = g:slimv_repl_wait * 10   " number of cycles to wait for refreshing the REPL buffer
     while wait > 0 || g:slimv_repl_wait == 0
         try
-            let m = '/\%#/'
-            silent! execute 'match Cursor ' . m
-            match Cursor /\%#/
+            silent! execute 'match SlimvCursor ' . m
             redraw
             if getchar(1)
                 break
             if ftime != lastftime || ftime == localtime() || ftime == localtime()-1
                 " REPL buffer file changed recently, reload it
                 call SlimvRefreshReplBufferNow()
-                if s:insertmode
-                    " We are in insert mode, let's fake a movement to the right
-                    " in order to display the cursor at the right place.
-                    normal! l
-                endif
             endif
             if g:slimv_repl_wait != 0
                 let wait = wait - 1
     endwhile
 
     " Restore everything
-    silent! execute 'match None ' . m
+    if synIDattr( synIDtrans( hlID( 'Normal' ) ), 'bg' ) != ''
+        silent! execute 'match Normal ' . m
+    else
+        silent! execute 'match SlimvNormal ' . m
+    endif
     echon '            '
-    let &ve = save_ve
 
     if wait == 0 && ftime != lastftime
         " Time is up and Lisp REPL still did not finish output
 
 " Called when entering REPL buffer
 function! SlimvReplEnter()
+    call SlimvAddReplMenu()
     if s:last_refresh < localtime()
-        call SlimvAddReplMenu()
         call SlimvRefreshReplBufferNow()
     endif
 endfunction
 function! SlimvReplLeave()
     try
         " Check if REPL menu exists, then remove it
-        silent amenu REPL
         aunmenu REPL
         unmap <Leader>\
     catch /.*/
         set wrap
     endif
 
+    hi SlimvNormal term=none cterm=none gui=none
+    hi SlimvCursor term=reverse cterm=reverse gui=reverse
+
     " Add autocommands specific to the REPL buffer
     execute "au FileChangedShell " . g:slimv_repl_file . " :call SlimvFileChangedShell()"
     execute "au FocusGained "      . g:slimv_repl_file . " :call SlimvFocusGained()"

plugin/paredit.vim

 " paredit.vim:
 "               Paredit mode for Slimv
-" Version:      0.6.1
-" Last Change:  27 Apr 2010
+" Version:      0.6.2
+" Last Change:  26 May 2010
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
 " Wrap current symbol in parens of the given kind
 " Stand on the opening paren (if not wrapping in "")
 function! PareditWrap( open, close )
+    let sel = &selection
+    let &selection = 'exclusive'
     execute "normal! " . "viw\<Esc>"
     call s:WrapSelection( a:open, a:close )
     if a:open != '"'
         normal! %
     endif
+    let &selection = sel
 endfunction
 
 " Splice current list into the containing list