Tamas Kovacs avatar Tamas Kovacs committed 9340a95

Version 0.5.6

Improved REPL buffer response time, added debug log flushing frequency, bugfix: early exit of REPL refresh mode on some machines.

Comments (0)

Files changed (2)

-*slimv.txt*                    Slimv                 Last Change: 08 Jan 2010
+*slimv.txt*                    Slimv                 Last Change: 15 Feb 2010
 
 Slimv                                                                  *slimv*
-                               Version 0.5.5
+                               Version 0.5.6
 
 The Superior Lisp Interaction Mode for Vim.
 This plugin is aimed to help Lisp development by interfacing between Vim and
 |g:slimv_logfile|            Name of the logfile to use for debug messages.
                              Also see |g:slimv_debug|.
 
+|g:slimv_logfreq|            Flushing frequency to logfile.
+
 |g:slimv_menu|               If nonzero, Slimv menu is added to the Vim menu.
 
 |g:slimv_port|               TCP/IP port number to use in the Slimv client-
 Name of the Slimv logfile. Defaults to slimv.log.
 Used only when |g:slimv_debug| level is nonzero.
 
+                                                              *g:slimv_logfreq*
+Flushing frequency to logfile.
+Writing to logfile generates extra Vim messages, so setting a relatively high
+flush frequency helps to get rid of them. The log messages are flushed when
+exiting Vim.
+
                                                                 *g:slimv_ctags*
 It is possible to generate tags file from within Vim. By default Slimv assumes
 that ctags.exe is stored somewhere along with the standard Vim path designated
 It is possible to interrupt a running Lisp program by pressing Ctrl-C,
 at least in some Lisp implementations, like CLISP (does not work for example
 with SBCL).
+In Clojure Ctrl-C exits the REPL by default, but it is possible to change this
+behaviour via the add-break-thread! function:
+    user=> (use 'clojure.contrib.repl-utils)
+    nil
+    user=> (add-break-thread!)
+Then pressing Ctrl-C results in a SIGINT exception in the current thread.
+This may however make bad things to your JVM, so use it with caution.
 
 To end the Lisp session press EOF (Ctrl-D on Linux, Ctrl-Z on Windows)
 in the Lisp REPL window. After exiting the REPL it is possible to open
 ===============================================================================
 CHANGE LOG                                                    *slimv-changelog*
 
+0.5.6  - Improved REPL buffer response time.
+       - Added debug log flushing frequency.
+       - Bugfix: early exit of REPL refresh mode on some machines.
+
 0.5.5  - Updated Clojure API to 1.1.
        - Expand tilde-prefix to home directory on Linux.
        - Autodetect Clojure in the user home directory on Linux.

ftplugin/slimv.vim

 " slimv.vim:    The Superior Lisp Interaction Mode for VIM
-" Version:      0.5.5
-" Last Change:  08 Jan 2010
+" Version:      0.5.6
+" Last Change:  08 Feb 2010
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
 "  Functions used by global variable definitions
 " =====================================================================
 
-" Write debug message to logile (message must be a list)
-function! SlimvWriteLog( level, message )
-    if exists( 'g:slimv_debug' ) && exists( 'g:slimv_logfile' ) && g:slimv_debug >= a:level
+" Flush log message buffer to logfile
+function! SlimvLogFlush()
+    if exists( 'g:slimv_debug' ) && exists( 'g:slimv_logfile' ) && s:debug_list != []
         " We need to make a hack: write things into a temporary file
         " then append temp file contents to the logfile
         let tmp = tempname()
         try
-            call writefile( a:message, tmp )
+            call writefile( s:debug_list, tmp )
         finally
             if g:slimv_windows
                 silent execute '!type ' . tmp . ' >> ' . g:slimv_logfile
         endtry
         " Unfortunately I know no way to tell writefile to append the text
         "call writefile( a:message, g:slimv_logfile )
+        let s:debug_list = []
+    endif
+endfunction
+
+" Write debug message to logfile (message must be a list)
+function! SlimvLogWrite( level, message, immediate )
+    if exists( 'g:slimv_debug' ) && exists( 'g:slimv_logfile' ) && g:slimv_debug >= a:level
+        let s:debug_list = s:debug_list + a:message
+        if len( s:debug_list ) >= g:slimv_logfreq || a:immediate
+            call SlimvLogFlush()
+        endif
     endif
 endfunction
 
-" Write debug message to logile with a timestamp
+" Write debug message to logfile with a timestamp
 function! SlimvLog( level, message )
     if exists( '*strftime' )
         let time = strftime( '%Y %b %d %X' )
     else
         let time = localtime()
     endif
-    call SlimvWriteLog( a:level, ['***** ' . time] + a:message + [''] )
+    call SlimvLogWrite( a:level, ['***** ' . time] + a:message + [''], 0 )
 endfunction
 
 " Try to autodetect Python executable
 
 au VimEnter,BufNewFile,BufRead *.lisp call SlimvLogGlobals()
 au VimEnter,BufNewFile,BufRead *.clj  call SlimvLogGlobals()
+au VimLeave *.lisp call SlimvLogFlush()
+au VimLeave *.clj  call SlimvLogFlush()
 
 
 " =====================================================================
     let g:slimv_logfile = 'slimv.log'
 endif
 
+" Flushing frequency into debug logfile
+if !exists( 'g:slimv_logfreq' )
+    let g:slimv_logfreq = 1
+endif
+
 " TCP port number to use
 if !exists( 'g:slimv_port' )
     let g:slimv_port = 5151
 " The current mode when REPL refresh was started
 let s:insertmode = 0
 
+" The last refresh time of the REPL buffer
+let s:last_refresh = 0
+
+" Debug log buffer
+let s:debug_list = []
+
 
 " =====================================================================
 "  General utility functions
 
 " Reload the contents of the REPL buffer from the output file immediately
 function! SlimvRefreshReplBufferNow()
+    let s:last_refresh = localtime()
     if !g:slimv_repl_open
         " User does not want to display REPL in Vim
         return
     call SlimvEndOfReplBuffer( 1, insert )
 endfunction
 
+function! SlimvFileChangedShell()
+    call SlimvRefreshReplBufferNow()
+endfunction
+
+function! SlimvFocusGained()
+    if s:last_refresh < localtime()
+        call SlimvRefreshReplBufferNow()
+    endif
+endfunction
+
 " Send interrupt command to REPL
 function! SlimvInterrupt()
     call SlimvSend( ['SLIMV::INTERRUPT'], 0 )
         " Inform user that we are in running mode (waiting for REPL output)
         echon '-- RUNNING --'
     endif
+
+    " For some reason sometimes a getchar comes with 128 followed by 0.
+    " This is meant to swallow it.
+    while getchar(1) == 128
+        let c = getchar(0)
+    endwhile
+
     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
 
 " Called when entering REPL buffer
 function! SlimvReplEnter()
-    call SlimvAddReplMenu()
-    call SlimvRefreshReplBufferNow()
+    if s:last_refresh < localtime()
+        call SlimvAddReplMenu()
+        call SlimvRefreshReplBufferNow()
+    endif
 endfunction
 
 " Called when leaving REPL buffer
     endif
 
     " Add autocommands specific to the REPL buffer
-    execute "au FileChangedShell " . g:slimv_repl_file . " :call SlimvRefreshReplBufferNow()"
-    execute "au FocusGained "      . g:slimv_repl_file . " :call SlimvRefreshReplBufferNow()"
+    execute "au FileChangedShell " . g:slimv_repl_file . " :call SlimvFileChangedShell()"
+    execute "au FocusGained "      . g:slimv_repl_file . " :call SlimvFocusGained()"
     execute "au BufEnter "         . g:slimv_repl_file . " :call SlimvReplEnter()"
     execute "au BufLeave "         . g:slimv_repl_file . " :call SlimvReplLeave()"
 
         " Find all symbols starting with "a:base"
         let res = []
         let symbol = b:SlimvHyperspecLookup( a:base, 0, 1 )
-	call sort( symbol )
+        call sort( symbol )
         for m in symbol
             if m =~ '^' . a:base
                 call add( res, m )
     amenu &Slimv.&Documentation.&Hyperspec             :call SlimvHyperspec()<CR>
     imenu &Slimv.&Documentation.&Complete-Symbol       <C-X><C-O>
     amenu &Slimv.&Documentation.Generate-&Tags         :call SlimvGenerateTags()<CR>
-    
+
     amenu &Slimv.&Repl.&Connect-Server                 :call SlimvConnectServer()<CR>
 endif
 
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.