Commits

Tamas Kovacs committed 57ab4b2

Version 0.8.0

Major update: added SWANK client (many thanks to Philipp Marek), additional changes: split documentation into three parts, added keymapping hints to GUI menu items, renamed Eval-Last-Expression to Eval-Current-Expression, REPL buffer is not syntax highlighted anymore, switch on filetype plugins, autodetection for Allegro CL, Lisp Cabinet and Leiningen, ask for save before compiling file, map <Tab> for completion, bugfixes: finding start of keyword in completion, deleting escaped " inside string, Up/Down/Enter handling in popup menu.

Comments (0)

Files changed (92)

 This is a mirror of http://www.vim.org/scripts/script.php?script_id=2531
 
-Slimv tries to mimic a subset of SLIME's (Superior Lisp Interaction Mode for Emacs) functionality inside Vim on Linux, Windows and Mac OS X. The script defines functions and keybindings to send s-expressions to a console mode Lisp or Clojure REPL (Read-Eval-Print Loop). Slimv runs its own REPL or connects to a running REPL started by a previous Slimv session, the connection is established when the first Slimv command is executed (e.g. an s-expression is evaluated).
+Slimv is a SWANK client for Vim, similarly to SLIME for Emacs. SWANK is a TCP server for Emacs, which runs a Common Lisp or Clojure REPL and provides a socket interface for evaluating, compiling, debugging, profiling lisp code. The SWANK server is embedded in Slimv, but you can also use your own SWANK installation.
 
-The Lisp REPL buffer can also be opened inside Vim as a Vim buffer with syntax highlighting and autoindenting, Lisp commands may be entered in the command line, just as in a regular REPL. The script also has a basic support for Clojure REPL.
+Slimv opens the lisp or clojure REPL (Read-Eval-Print Loop) inside a Vim buffer. Lisp commands may be entered and executed in the REPL buffer, just as in a regular REPL.
 
-Slimv supports the same profiling tool that comes with SLIME. The script also has a Common Lisp Hyperspec lookup feature and it is able to lookup symbols in the Clojure API, as well as in JavaDoc. Symbol name completion is supported via Vim's omni-completion based on the hyperspec symbol database.
+Slimv supports SLIME's debugger, profiler, cross reference, symbol name completion functions. The script also has a Common Lisp Hyperspec lookup feature and it is able to lookup symbols in the Clojure API, as well as in JavaDoc.
 
 Slimv comes with Paredit Mode, which is similar to the functionality of paredit.el in Emacs. Paredit Mode tries to maintain the balanced state of matched characters (parenthesis marks, square brackets, double quotes). Matched characters are inserted and removed in pairs, also when working with a block of text (well, mostly). Slimv also implements many paredit.el s-expression handling functions, like Split/Join/Wrap/Splice. Slurpage and Barfage known from Emacs is also possible but in a different fashion: you don't move the list element in or out of the list, rather you move the opening or closing parenthesis over the element or sub-list.
 
-Check out the screenshot of Slimv having a clisp REPL buffer:
-http://img6.imageshack.us/img6/5104/slimvscreenshotx.png
-
-Another screenshot of Slimv running the Clojure Ants demo:
-http://img21.imageshack.us/img21/3949/slimvants.png
-
-And this is the symbol name completion in action (no, the pink background is not done by Slimv, this is Vim's default):
-http://img18.imageshack.us/img18/5859/slimvcompl.png
+Please visit the Slimv Tutorial for a more complete introduction:
+http://kovisoft.bitbucket.org/tutorial.html
 
 Here follows a list of Slimv commands, any similarity with SLIME's menu is not coincidental. :)
-For a more complete description with keybindings see the included documentation.
 
 Edit commands:
     *  Close Form
 
 Evaluation commands:
     *  Eval Defun
-    *  Eval Last Expression
-    *  Pprint Eval Last Expression
+    *  Eval Current Expression
     *  Eval Region
     *  Eval Buffer
     *  Interactive Eval
 
 Debug commands:
     *  Macroexpand-1
-    *  Macroexpand
-    *  Trace
-    *  Untrace
+    *  Macroexpand All
+    *  Toggle Trace
+    *  Untrace All
     *  Disassemble
     *  Inspect
 
     *  Compile File
     *  Compile Region
 
+Cross Reference commands
+    *  Who Calls
+    *  Who References
+    *  Who Sets
+    *  Who Binds
+    *  Who Macroexpands
+    *  Who Specializes
+    *  List Callers
+    *  List Callees
+
 Profile commands:
-    *  Load Profiler
-    *  Profile
-    *  Unprofile
+    *  Toggle Profile
+    *  Profile By Substring
     *  Unprofile All
     *  Show Profiled
     *  Profile Report
 
 REPL commands:
     *  Connect to Server
-    *  Send Input
     *  Interrupt Lisp Process
+    *  Send Input
     *  Close and Send Input
+    *  Set Package
     *  Previous Input
     *  Next Input
 
-Many Slimv commands operate on s-expressions or symbols, just like in SLIME. Place the cursor at any location inside the s-expression or on the symbol's name then invoke the command. This builds a command specific form and sends it to the running REPL for evaluation.
-
-For more information see the documentation coupled with the script, please refer to section "External Utilities" for other useful Lisp editing tips not covered by Slimv.
+For more information see the included documentation.
+*paredit.txt*                    Slimv               Last Change: 25 Mar 2011
+
+Paredit mode for Slimv                                *paredit* *slimv-paredit*
+                               Version 0.8.0
+
+The paredit.vim plugin performs structured editing of s-expressions used in
+the Lisp or Clojure programming language.
+
+|paredit-mode|               Paredit mode
+|paredit-options|            Paredit options
+
+===============================================================================
+PAREDIT MODE                                                     *paredit-mode*
+
+Paredit mode is a special editing mode that keeps all matched characters
+(parentheses, square brackets, double quotes) balanced, i.e. all opening
+characters have a matching closing character. Most text entering and erasing
+commands try to maintain the balanced state, so no single matched character is
+added or deleted, they are entered or removed in pairs.
+The function takes care of strings and comments, so no parenthesis and square
+bracket balancing is performed inside a string or comment.
+
+The idea is taken from the paredit mode of Emacs, but not all paredit.el
+editing functions are implemented or behave exactly the same way as they do
+in Emacs.
+
+When you enter a '(' then a matching ')' is automatically inserted.
+If needed, spaces before and/or after the '()' pair are added.
+
+When you press ')' in insert mode then there's no need to insert a closing
+parenthesis mark (it is already there), so the cursor is simply advanced past
+the next closing parenthesis (then the next outer closing parenthesis, etc.).
+The result of this is however that when entering text with paredit mode
+you can use the same keystrokes as without paredit mode and you get the same
+result. Of course you can choose to not enter the closing parenthesis (as
+required without paredit mode), because it is already there.
+
+When you are trying to delete a ')' alone then it is not possible, the cursor
+is simply moved inside the list, where all regular characters can be deleted.
+When the list is finally empty: '()', then the deletion of the opening '('
+makes both parentheses erased at once, so the balanced state is maintained.
+
+All the above holds for [...] and "..." character pairs.
+
+When you are deleting multiple characters at once, e.g. deleting a whole line,
+or deleting till the end of the line, etc, then the deletion logic of a single
+character is iterated. This means that the whole line or the characters till
+the end of the line, etc are not necessarily deleted all. Depending on the
+number of open/close parentheses, square brackets, double quotes some of them
+might be kept in order to maintain the balanced state.
+For example if you press D in Normal mode to delete till the end of line
+between the a and b parameters of the following Clojure function definition:
+
+(defn myfunc [a b c] (+ a b c))
+               ^--- press D here
+
+then the closing ] as well as the last closing ) will not be deleted, because
+in the list you have an ( and a [ to be matched, so the result will be:
+
+(defn myfunc [a])
+
+If you are deleting multiple lines, then the above process is performed for
+all lines involved. If a line was not completely cleared, then it is joined
+with the next line and the process continues.
+
+
+Of course not all Vim commands are compatible with the paredit mode (e.g.
+you can yank and paste unbalanced code snippet, or comment out an asymmetrical
+part of the code), and there is also the possibility to edit the source code
+with paredit mode switched off or with another editor to make it unbalanced.
+When paredit mode detects that the underlying code is not balanced, then the
+paredit functionality is suspended until the top level form balance is fixed.
+As soon as all parens are matched, the paredit mode is automatically resumed.
+Paredit needs "syntax on" to identify the syntax elements of the underlying
+code, so if syntax is switched off, then paredit will not be suspended inside
+comments or strings.
+
+
+Slurpage and Barfage known from Emacs is also possible but in a different
+fashion: you don't move the symbols but move the opening or closing parenthesis
+over the symbol or a sub-list. This way you can move any symbol or sub-list
+into or out of the current list. It is not possible to move the parenthesis
+over its pair, so for example if you move the opening parenthesis to the right,
+then it will stop at the matched closing parenthesis.
+
+
+Paredit mode is set by default for .lisp and .clj files, but it is possible
+to switch it out by putting the following statement in the .vimrc file:
+
+    let g:paredit_mode = 0
+
+You can enable paredit mode for other file types as well. Here is how to set
+it for Scheme files (meant to be added to your .vimrc file):
+
+    au BufNewFile,BufRead *.scm call PareditInitBuffer()
+
+It is also possible to use the paredit mode alone, without the other parts of
+Slimv. The easiest way to do it is to delete all Slimv related files from the 
+ftplugin directory. If you don't intend to use Slimv's indentation and syntax
+files, then you need to keep only plugin/paredit.vim.
+Another way to prevent Slimv from loading by adding this to your .vimrc file:
+
+    let g:slimv_loaded = 1
+
+Slimv core will not be loaded but paredit will be loaded and assigned to
+.lisp and .clj files.
+
+
+Here follows a list of paredit keybindings:
+
+
+Insert Mode:
+
+    (              Inserts '()' and moves the cursor inside. Also adds leading
+                   or trailing spaces when needed.
+                   Inserts '(' when inside comment or string.
+
+    )              Moves the cursor to the next closing parenthesis mark of
+                   the current list. When pressed again then moves to the next
+                   outer closing parenthesis, etc, until the closing of the
+                   top level form is reached.
+                   Inserts ')' when inside comment or string.
+
+    [              Inserts '[]' and moves the cursor inside. Also adds leading
+                   or trailing spaces when needed.
+                   Inserts '[' when inside comment or string.
+
+    ]              Moves the cursor to the next closing square bracket of the
+                   current list. When pressed again then moves to the next
+                   outer closing square bracket, etc, until the closing of the
+                   top level form is reached.
+                   Inserts ']' when inside comment or string.
+
+    "              When outside of string, inserts '""' and moves the cursor
+                   inside. When inside string then moves to the closing '"'.                   
+                   Inserts '"' when inside comment. Also insert '"' when inside
+                   string and preceded by a '\'.
+
+    <BS>           When about to delete a (, ), [, ], or " and there are other
+                   characters inside, then just skip it to the left. When
+                   about to delete the opening part of the matched character
+                   with nothing inside, then the whole empty list is removed.
+
+    <Del>          When about to delete a (, ), [, ], or " and there are other
+                   characters inside, then just skip it to the right. When
+                   about to delete the closing part of the matched character
+                   with nothing inside, then the whole empty list is removed.
+
+
+Normal Mode:
+
+    (              Finds opening '(' of the current list. Can be pressed
+                   repeatedly until the opening of the top level form reached.
+
+    )              Finds closing ')' of the current list. Can be pressed
+                   repeatedly until the closing of the top level form reached.
+
+    <Leader><      If standing on a delimiter (parenthesis or square bracket)
+                   then moves it to the left by slurping or barfing the
+                   s-expression to the left, depending on the direction of the
+                   delimiter:
+                   Pressing '<' when standing on a ')' makes the s-expression
+                   to the left of the ')' going out of the current list.
+                   Pressing '<' when standing on a '(' makes the s-expression
+                   to the left of the '(' coming into the current list.
+                   For example pressing <Leader>< at position marked with |:
+                       (aaa bbb|)        --->    (aaa) bbb
+                       aaa |(bbb)        --->    (aaa bbb)
+
+    <Leader>>      If standing on a delimiter (parenthesis or square bracket)
+                   then moves it to the right by slurping or barfing the
+                   s-expression to the right, depending on the direction of the
+                   delimiter:
+                   Pressing '>' when standing on a '(' makes the s-expression
+                   to the right of the '(' going out of the current list.
+                   Pressing '>' when standing on a ')' makes the s-expression
+                   to the right of the ')' coming into the current list.
+                   For example pressing <Leader>< at position marked with |:
+                       (aaa|) bbb        --->    (aaa bbb)
+                       |(aaa bbb)        --->    aaa (bbb)
+
+    <Leader>J      Join two subsequent lists or strings. The first one must end
+                   before the cursor, the second one must start after the
+                   cursor position.
+                   For example pressing <Leader>J at position marked with |:
+                       (aaa)| (bbb)      --->    (aaa bbb)
+                       "aaa"| "bbb"      --->    "aaa bbb"
+
+    <Leader>O      Split ("Open") current list or string at the cursor position.
+                   Opposite of Join. Key O is selected because for the original
+                   Vim mapping J and O are also kind of opposites.
+                   For example pressing <Leader>O at position marked with |:
+                       (aaa |bbb)        --->    (aaa) (bbb)
+                       "aaa|bbb"         --->    "aaa" "bbb"
+
+    <Leader>W      Wrap the current symbol in a pair of parentheses. The cursor
+    <Leader>w(     is then positioned on the opening parenthesis, as wrapping
+                   is usually done because one wants to call a function with
+                   the symbol as parameter, so by pressing "a" one can enter
+                   the function name right after the newly inserted "(".
+                   For example pressing <Leader>W at position marked with |:
+                       (aaa b|bb ccc)    --->    (aaa (bbb) ccc)
+
+    <Leader>w[     Wrap the current symbol in a pair of square brackets,
+                   similarly to <Leader>W.
+                   For example pressing <Leader>w[ at position marked with |:
+                       (aaa b|bb ccc)    --->    (aaa [bbb] ccc)
+
+    <Leader>w"     Wrap the current symbol in a pair of double quotes,
+                   similarly to <Leader>W.
+                   For example pressing <Leader>w" at position marked with |:
+                       (aaa b|bb ccc)    --->    (aaa "bbb" ccc)
+
+    <Leader>S      Splice the current list into the containing list, i.e.
+                   remove the opening and closing parens. Opposite of wrap.
+                   For example pressing <Leader>S at position marked with |:
+                       (aaa (b|bb) ccc)  --->    (aaa bbb ccc)
+
+    x  or  <Del>   When about to delete a (, ), [, ], or " and there are other
+                   characters inside, then just skip it to the right. When
+                   about to delete the closing part of the matched character
+                   with nothing inside, then the whole empty list is removed.
+                   When preceded by a <count> value then delete this many
+                   characters.
+
+    X              When about to delete a (, ), [, ], or " and there are other
+                   characters inside, then just skip it to the left. When
+                   about to delete the opening part of the matched character
+                   with nothing inside, then the whole empty list is removed.
+
+    D              Keep deleting characters towards the end of line,
+                   maintaining the balanced state, i.e. keep the number of
+                   opening and closing parens the same.
+
+    C              Same as 'D' but go to insert mode at the end.
+
+    s              Same as 'x' but go to insert mode at the end.
+
+    dd             Delete whole line by keeping the balanced state, i.e.
+                   keep the number of opening and closing parens the same.
+                   When preceded by a <count> value then delete this many
+                   lines.
+
+    <Leader>S      Same as 'dd' but go to insert mode at the end.
+
+    d{motion}      Delete text till {motion}. Keeps text balanced, so if the
+                   surrounded text contains unpaired matched characters then
+                   they are not removed.
+
+    c{motion}      Delete text till {motion} and start insert mode. Keeps text
+                   balanced just like d{motion}.
+
+    p              Put the text after the cursor with all unbalanced matched
+                   characters removed.
+
+    P              Put the text before the cursor with all unbalanced matched
+                   characters removed.
+
+
+Visual Mode:
+
+    (              Finds opening '(' of the current list and selects the whole
+                   list. Can be pressed repeatedly until the top level form
+                   selected.
+
+    )              Finds closing ')' of the current list and selects the whole
+                   list. Can be pressed repeatedly until the top level form
+                   selected.
+
+    d              Delete the current visual selection. Keeps text balanced,
+    x              so the the selection contains unpaired matched characters
+    <Del>          then they are not removed.
+
+    c              Delete the current visual selection and start insert mode.
+                   Keeps text balanced just like the 'd' command.
+
+    <Leader>W      Wrap the current visual selection in a pair of parentheses.
+    <Leader>w(     The visual selection is kept.
+
+    <Leader>w[     Wrap the current visual selection in a pair of square
+                   brackets. The visual selection is kept.
+
+    <Leader>w"     Wrap the current visual selection in a pair of double
+                   quotes. The visual selection is kept.
+
+
+Please note that if variable |g:paredit_shortmaps| is nonzero then the
+following normal mode mappings don't get a <Leader> prefix, they are mapped
+to existing (but infrequently used) Vim functions and instead the original Vim
+functions are mapped with the <Leader> prefix:
+
+                   <, >, J, O, W, S
+
+
+===============================================================================
+PAREDIT OPTIONS                                               *paredit-options*
+
+|g:paredit_matchlines|       Number of lines to look backward and forward
+                             when checking if the current form is balanced.
+
+|g:paredit_mode|             If nonzero, paredit mode is switched on.
+
+|g:paredit_shortmaps|        If nonzero, paredit is remapping some one-letter
+                             Vim commands that are not frequently used.
+
+
+                                                         *g:paredit_matchlines*
+Number of lines to look backward and forward when checking if the current
+top level form is balanced in paredit mode. Default is 100.
+
+                                                               *g:paredit_mode*
+If nonzero then paredit mode is switched on, i.e. Slimv tries to keep the
+balanced state of parens.
+
+                                                          *g:paredit_shortmaps*
+If nonzero, paredit is remapping some one-letter normal mode Vim commands that
+are not frequently used. These are <, >, J, O, W, S. The original function of
+these maps then can be reached via the <Leader> prefix (which is the ","
+character by default in Slimv).
+Otherwise these paredit functions can be reached via the <Leader> prefix.
+
+
+===============================================================================
+vim:tw=80:noet:wrap:ts=8:ft=help:norl:
-*slimv.txt*                    Slimv                 Last Change: 17 Feb 2011
+*slimv.txt*                    Slimv                 Last Change: 14 Apr 2011
 
 Slimv                                                                  *slimv*
-                               Version 0.7.7
+                               Version 0.8.0
 
 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, Linux, and Mac OS X, however the newly introduced
-paredit mode is operating system independent.
+Paredit mode is operating system independent. Please visit |paredit.txt| for
+additional information on Paredit mode.
+The current version of Slimv contains a SWANK (TCP server for Emacs) client.
+Please visit |swank.txt| for additional information on the SWANK client.
 
 |slimv-installation|         Installation
 |slimv-customization|        Customization
+|slimv-swank|                SWANK client
 |slimv-usage|                Usage
 |slimv-repl|                 Lisp REPL inside Vim
 |slimv-clojure|              Clojure support
 
 Prerequisites:
 
+  Note: the system requirements are different for the SWANK client, please find
+  details in |swank-installation|.
+
   Required components:
   - Lisp (any console Common Lisp implementation should be OK) or
     Clojure installed.
-  - Python 2.4 or later installed. Please note that due to a Popen bug in the
-    Cygwin Python implementation Cygwin users should install Windows Python,
+  - Python 2.4 or later installed. When using the SWANK client the same Python
+    version is needed that Vim is compiled against.
+    When not using the SWANK client then due to a Popen bug in the Cygwin
+    Python implementation Cygwin users should install Windows Python,
     which is autodetected by the script.
 
   Optional components:
-  - The interrupt functionality needs the pywin32 extension on Windows.
+  - The interrupt functionality needs the pywin32 extension on Windows, but
+    only when not using the SWANK server.
   - "Exuberant ctags" for tags file generation (if not bundled with Vim
     already). See |slimv-ctags|.
 
 To install the script:
 
-  - Download the slimv.zip.
+  - Install all required components described above.
+  - Download slimv.zip.
   - Extract the zip archive into your vimfiles or runtime directory.
     See Vim help file |usr_05.txt| for details on adding a plugin.
     The archive contains the following files:
 
+       doc/paredit.txt
        doc/slimv.txt
+       doc/swank.txt
        ftdetect/clojure.vim
-       ftplugin/metering.lisp
        ftplugin/slimv.py
        ftplugin/slimv.vim
        ftplugin/slimv-clhs.vim
        ftplugin/slimv-cljapi.vim
        ftplugin/slimv-javadoc.vim
+       ftplugin/swank.py
        ftplugin/clojure/slimv-clojure.vim
        ftplugin/lisp/slimv-lisp.vim
        indent/clojure.vim
        plugin/paredit.vim
+       slime/*
+       swank-clojure/*
        syntax/clojure/slimv-syntax-clojure.vim
 
     You might already have an ftdetect/clojure.vim file if you already use
     another Clojure filetype plugin. In this case just keep the original file.
-    If you intend to use the script only for Lisp programming, then most of
-    the files may be skipped, in this case it is enough to copy the following
-    files:
-
-       doc/slimv.txt
-       ftplugin/metering.lisp
-       ftplugin/slimv.py
-       ftplugin/slimv.vim
-       ftplugin/slimv-clhs.vim
-       ftplugin/lisp/slimv-lisp.vim
 
   - Start Vim or goto an existing instance of Vim.
   - Execute the following command:
     This will generate all the help tags for any file located in the doc
     directory.
   - Enter path definitions into your vimrc (if the default values are not
-    valid for your Vim/Python/Lisp installation, which is highly probable).
+    valid for your Vim/Python/Lisp installation).
     See |slimv-customization| below on how to do this.
   - On Linux some login shells (like fish) might be incompatible with the Vim
     temporary file generation, which results in getting random E484 errors.
         endif
 
 
-Upgrade from previous script versions:
-
-0.1   - 0.4.x    The project went through a major reorganization, so users
-                 who already installed previous versions of the plugin should
-                 first delete the old files. These are: plugin/slimv.vim,
-                 plugin/slimv.py, plugin/metering.lisp and doc/slimv.txt
-                 in the vimfiles directory.
-0.1   - 0.2.x    Users having a custom |g:slimv_repl_file| setting should
-                 consider attaching the .lisp or .clj extension to the name
-                 of the REPL buffer, in order to have syntax highlighting
-                 and autoindenting in the REPL buffer.
-                 Users who already have done this are smarter than me :)
-
 Uninstallation:
 
   - Exit all Vim instances and exit from the REPL server terminal window.
   - Delete the files that were copied to the vimfiles directory during
-    installation:
-
-       doc/slimv.txt
-       ftdetect/clojure.vim
-       ftplugin/metering.*
-       ftplugin/slimv.py
-       ftplugin/slimv.vim
-       ftplugin/slimv-clhs.vim
-       ftplugin/slimv-cljapi.vim
-       ftplugin/slimv-javadoc.vim
-       ftplugin/clojure/slimv-clojure.vim
-       ftplugin/lisp/slimv-lisp.vim
-       indent/clojure.vim
-       plugin/paredit.vim
-       syntax/clojure/slimv-syntax-clojure.vim
-
-    (Special note on metering.lisp: if the profiler was compiled, then the
-    compiled files should be deleted as well, hence the metering.* above.)
+    installation (see list of files above).
 
 
 ===============================================================================
 
 The list below contains an alphabetical collection of Slimv options.
 Below that list follows the detailed explanation on each option.
-
-|g:paredit_matchlines|       Number of lines to look backward and forward
-                             when checking if the current form is balanced.
-
-|g:paredit_mode|             If nonzero, paredit mode is switched on.
-
-|g:paredit_shortmaps|        If nonzero, paredit is remapping some one-letter
-                             Vim commands that are not frequently used.
+For the Paredit options please visit |paredit-options|.
+For the Swank options plese visit |swank-configuration|.
 
 |g:slimv_browser_cmd|        If nonempty, this command is used to open the
                              Common Lisp Hyperspec. 
 |g:slimv_repl_split|         Open the Lisp REPL buffer in a split window
                              or in a separate buffer.
 
+|g:slimv_repl_syntax|        Enable syntax coloring for the REPL buffer.
+
 |g:slimv_repl_wrap|          Set wrap mode for the REPL buffer.
 
+|g:slimv_swank|              Indicates the usage of the SWANK client.
+                             Please find additional SWANK related options
+                             in |swank.txt|.
+
 |g:slimv_updatetime|         Alternative value for 'updatetime' during REPL
                              refresh.
 
 Example:
     let g:slimv_port = 10101
 
+There is a separate port definition in Slimv which sets the port number to
+use for the SWANK server, see |g:swank_port| for details.
+
                                                                *g:slimv_client*
+Note: Used only when SWANK client is not enabled.
+
 You may want to use a shell frontend other then the default one (cmd.exe
 on Windows, xterm on Linux) or put additional command line parameters
 for starting the server.
 If nonzero then the Slimv menu is added to the end of the global menu.
 Also the Slimv menu can be shown by pressing <Leader>, (defaults to ,,).
 
-                                                         *g:paredit_matchlines*
-Number of lines to look backward and forward when checking if the current
-top level form is balanced in paredit mode. Default is 100.
-
-                                                               *g:paredit_mode*
-If nonzero then paredit mode is switched on, i.e. Slimv tries to keep the
-balanced state of parens. See |g:slimv-paredit|.
-
-                                                          *g:paredit_shortmaps*
-If nonzero, paredit is remapping some one-letter normal mode Vim commands that
-are not frequently used. These are <, >, J, O, W, S. The original function of
-these maps then can be reached via the <Leader> prefix (which is the ","
-character by default in Slimv).
-Otherwise these paredit functions can be reached via the <Leader> prefix.
-
                                                           *g:slimv_browser_cmd*
 Specifies the command to start the browser in order to display the Common Lisp
 Hyperspec or the Clojure API. If the command contains spaces then enclose the
 If nonzero then Slimv package/namespace handling is switched on. Please find
 details in the |slimv-package| section.
 
+                                                          *g:slimv_repl_syntax*
+Enables syntax highlighting for the REPL buffer. Switched off by default for
+two reasons:
+  1. The REPL buffer also contains the REPL output, which is generally not
+     related to s-expressions, therefore may confuse syntax coloring.
+  2. REPL output may contain very long lines, which significantly slows down
+     syntax coloring in Vim. If you really want to enable syntax highlighting
+     for the REPL buffer, then it is recommended to adjust the |synmaxcol|
+     parameter to a relatively low value in order to increase syntax coloring
+     speed.
+
                                                             *g:slimv_repl_wrap*
 Set wrap mode for the REPL buffer, which means the lines longer than the
 window width will not be hidden to the right. Instead they will be continued
     let g:slimv_template_pprint = '(dolist (o %1)(pprint o))'
 
                                                     *g:slimv_template_undefine*
+Note: Used only when SWANK client is not enabled.
+
 Lisp form built when issuing the 'Undefine' command.
 Example:
     let g:slimv_template_undefine = '(fmakunbound (read-from-string "%1"))'
 
                                                     *g:slimv_template_describe*
+Note: Used only when SWANK client is not enabled.
+
 Lisp form built when issuing the 'Describe' command.
 Example:
     let g:slimv_template_describe = '(describe (read-from-string "%1"))'
 
                                                        *g:slimv_template_trace*
+Note: Used only when SWANK client is not enabled.
+
 Lisp form built when issuing the 'Trace' command.
 Example:
     let g:slimv_template_trace = "(trace %1)"
 
                                                      *g:slimv_template_untrace*
+Note: Used only when SWANK client is not enabled.
+
 Lisp form built when issuing the 'Untrace' command.
 Example:
     let g:slimv_template_untrace = "(untrace %1)"
     let g:slimv_template_disassemble = "(disassemble #'%1)"
 
                                                      *g:slimv_template_inspect*
+Note: Used only when SWANK client is not enabled.
+
 Lisp form built when issuing the 'inspect' command.
 Example:
     let g:slimv_template_inspect = "(inspect %1)"
     let g:slimv_template_apropos = '(apropos "%1")'
 
                                                  *g:slimv_template_macroexpand*
+Note: Used only when SWANK client is not enabled.
+
 Lisp form built when issuing the 'macroexpand-1' command, after "defmacro"
 string is replaced with "macroexpand-1".
 Example:
     let g:slimv_template_macroexpand = '(pprint %1)'
 
                                              *g:slimv_template_macroexpand_all*
+Note: Used only when SWANK client is not enabled.
+
 Lisp form built when issuing the 'macroexpand-all' command, after "defmacro"
 string is replaced with "macroexpand".
 Example:
                                                                *slimv_keyboard*
 
 The default keybindings (|g:slimv_keybindings|=1) and another easy to remember
-built in keybinding set (|g:slimv_keybindings|=2) for Slimv are the following.
+built-in keybinding set (|g:slimv_keybindings|=2) for Slimv are the following.
 Please note that the leading ',' key below refers to <Leader>, which is set
 by Slimv to ',' by default.
+In the graphical menu the currently active keyboard shortcuts are displayed
+beside the menu item names, so one can refer to the GUI menu as a quick
+reference for the keymappings.
 Vim defines timeout values for mapped key sequences. If you find that Vim does
 not allow you enough time between pressing ',' and the last key(s) of the
 sequence, then you may want to fine tune these Vim options:
 
     Evaluation commands:
     ,d      ,ed      Eval Defun (current top level form)
-    ,e      ,ee      Eval Last Expression (current subform)
-    ,E      ,ep      Pprint Eval Last Expression
+    ,e      ,ee      Eval Current Expression (current subform)
+    ,E      ,ep      Pprint Eval Current Expression
     ,r      ,er      Eval Region (visual selection)
     ,b      ,eb      Eval Buffer
     ,v      ,ei      Interactive Eval
 
     Debug commands:
     ,1      ,m1      Macroexpand-1
-    ,m      ,ma      Macroexpand
+    ,m      ,ma      Macroexpand All
     ,t      ,dt      Trace
     ,T      ,du      Untrace
     ,l      ,dd      Disassemble
 
     Repl commands:
     ,c      ,rc      Connect to Server
+    ,y      ,ri      Interrupt Lisp Process
 
 
     Set#1   Set#2    Command
     REPL menu commands:
     ,.      ,rs      Send Input
     ,/      ,ro      Close and Send Input
+    ,g      ,rp      Set Package (only when using SWANK client)
     <C-C>   <C-C>    Interrupt Lisp Process
     ,<Up>   ,rp      Previous Input
     ,<Down> ,rn      Next Input
 
 
 Also see |slimv-repl| for additional keybindings valid only in the REPL buffer.
+Some menu items or Slimv commands may differ in case Slimv uses the SWANK
+client, please find details in |swank.txt|.
 
 
 ===============================================================================
 ===============================================================================
 PROFILING                                                     *slimv-profiling*
 
-Slimv is capable of utilizing SBCL's built-in profiler, and also the same
-monitoring/profiling package (metering.lisp) that is used by SLIME, at least
-for CLISP and maybe for some other Common Lisp implementations.
-Fortunately SLIME's metering.lisp is in public domain, so its current version
-(at the time of writing this document) is included in Slimv.
-The most recent version can be extracted from the main directory of SLIME.
-SLIME can be downloaded from http://common-lisp.net/project/slime/
+The SWANK client has the same profiler support as SLIME.
+
+If not using the SWANK client, then Slimv is still capable of utilizing SBCL's
+built-in profiler, and also the same monitoring/profiling package
+(metering.lisp) that is used by SLIME.
 
 SBCL's profiler is ready to use by just starting the Lisp REPL.
 In order to use SLIME's profiler with CLISP it first must be compiled and
 Vim's omni-completion feature (if it is enabled and 'omnifunc' is not
 defined already to something else).
 Start to enter the symbol in Insert mode, then at some point press the
-<C-X> <C-O> (omni-complete) key combination or select the 'Complete Symbol'
+<C-X><C-O> (omni-complete) key combination or select the 'Complete Symbol'
 function. The first match in the symbol database is inserted at the cursor
 position and a list of matching symbols is displayed in a submenu.
 Use <C-N> to select the next match, <C-P> to select the previous match.
 
 
 ===============================================================================
-PAREDIT MODE                                          *paredit* *slimv-paredit*
-
-Paredit mode is a special editing mode that keeps all matched characters
-(parentheses, square brackets, double quotes) balanced, i.e. all opening
-characters have a matching closing character. Most text entering and erasing
-commands try to maintain the balanced state, so no single matched character is
-added or deleted, they are entered or removed in pairs.
-The function takes care of strings and comments, so no parenthesis and square
-bracket balancing is performed inside a string or comment.
-
-The idea is taken from the paredit mode of Emacs, but not all paredit.el
-editing functions are implemented or behave exactly the same way as they do
-in Emacs.
-
-When you enter a '(' then a matching ')' is automatically inserted.
-If needed, spaces before and/or after the '()' pair are added.
-
-When you press ')' in insert mode then there's no need to insert a closing
-parenthesis mark (it is already there), so the cursor is simply advanced past
-the next closing parenthesis (then the next outer closing parenthesis, etc.).
-The result of this is however that when entering text with paredit mode
-you can use the same keystrokes as without paredit mode and you get the same
-result. Of course you can choose to not enter the closing parenthesis (as
-required without paredit mode), because it is already there.
-
-When you are trying to delete a ')' alone then it is not possible, the cursor
-is simply moved inside the list, where all regular characters can be deleted.
-When the list is finally empty: '()', then the deletion of the opening '('
-makes both parentheses erased at once, so the balanced state is maintained.
-
-All the above holds for [...] and "..." character pairs.
-
-When you are deleting multiple characters at once, e.g. deleting a whole line,
-or deleting till the end of the line, etc, then the deletion logic of a single
-character is iterated. This means that the whole line or the characters till
-the end of the line, etc are not necessarily deleted all. Depending on the
-number of open/close parentheses, square brackets, double quotes some of them
-might be kept in order to maintain the balanced state.
-For example if you press D in Normal mode to delete till the end of line
-between the a and b parameters of the following Clojure function definition:
-
-(defn myfunc [a b c] (+ a b c))
-               ^--- press D here
-
-then the closing ] as well as the last closing ) will not be deleted, because
-in the list you have an ( and a [ to be matched, so the result will be:
-
-(defn myfunc [a])
-
-If you are deleting multiple lines, then the above process is performed for
-all lines involved. If a line was not completely cleared, then it is joined
-with the next line and the process continues.
-
-
-Of course not all Vim commands are compatible with the paredit mode (e.g.
-you can yank and paste unbalanced code snippet, or comment out an asymmetrical
-part of the code), and there is also the possibility to edit the source code
-with paredit mode switched off or with another editor to make it unbalanced.
-When paredit mode detects that the underlying code is not balanced, then the
-paredit functionality is suspended until the top level form balance is fixed.
-As soon as all parens are matched, the paredit mode is automatically resumed.
-Paredit needs "syntax on" to identify the syntax elements of the underlying
-code, so if syntax is switched off, then paredit will not be suspended inside
-comments or strings.
-
-
-Slurpage and Barfage known from Emacs is also possible but in a different
-fashion: you don't move the symbols but move the opening or closing parenthesis
-over the symbol or a sub-list. This way you can move any symbol or sub-list
-into or out of the current list. It is not possible to move the parenthesis
-over its pair, so for example if you move the opening parenthesis to the right,
-then it will stop at the matched closing parenthesis.
-
-
-Paredit mode is set by default for .lisp and .clj files, but it is possible
-to switch it out by putting the following statement in the .vimrc file:
-
-    let g:paredit_mode = 0
-
-You can enable paredit mode for other file types as well. Here is how to set
-it for Scheme files (meant to be added to your .vimrc file):
-
-    au BufNewFile,BufRead *.scm call PareditInitBuffer()
-
-It is also possible to use the paredit mode alone, without the other parts of
-Slimv. The easiest way to do it is to delete all Slimv related files from the 
-ftplugin directory. If you don't intend to use Slimv's indentation and syntax
-files, then you need to keep only plugin/paredit.vim.
-Another way to prevent Slimv from loading by adding this to your .vimrc file:
-
-    let g:slimv_loaded = 1
-
-Slimv core will not be loaded but paredit will be loaded and assigned to
-.lisp and .clj files.
-
-
-Here follows a list of paredit keybindings:
-
-
-Insert Mode:
-
-    (              Inserts '()' and moves the cursor inside. Also adds leading
-                   or trailing spaces when needed.
-                   Inserts '(' when inside comment or string.
-
-    )              Moves the cursor to the next closing parenthesis mark of
-                   the current list. When pressed again then moves to the next
-                   outer closing parenthesis, etc, until the closing of the
-                   top level form is reached.
-                   Inserts ')' when inside comment or string.
-
-    [              Inserts '[]' and moves the cursor inside. Also adds leading
-                   or trailing spaces when needed.
-                   Inserts '[' when inside comment or string.
-
-    ]              Moves the cursor to the next closing square bracket of the
-                   current list. When pressed again then moves to the next
-                   outer closing square bracket, etc, until the closing of the
-                   top level form is reached.
-                   Inserts ']' when inside comment or string.
-
-    "              When outside of string, inserts '""' and moves the cursor
-                   inside. When inside string then moves to the closing '"'.                   
-                   Inserts '"' when inside comment. Also insert '"' when inside
-                   string and preceded by a '\'.
-
-    <BS>           When about to delete a (, ), [, ], or " and there are other
-                   characters inside, then just skip it to the left. When
-                   about to delete the opening part of the matched character
-                   with nothing inside, then the whole empty list is removed.
-
-    <Del>          When about to delete a (, ), [, ], or " and there are other
-                   characters inside, then just skip it to the right. When
-                   about to delete the closing part of the matched character
-                   with nothing inside, then the whole empty list is removed.
-
-
-Normal Mode:
-
-    (              Finds opening '(' of the current list. Can be pressed
-                   repeatedly until the opening of the top level form reached.
-
-    )              Finds closing ')' of the current list. Can be pressed
-                   repeatedly until the closing of the top level form reached.
-
-    <Leader><      If standing on a delimiter (parenthesis or square bracket)
-                   then moves it to the left by slurping or barfing the
-                   s-expression to the left, depending on the direction of the
-                   delimiter:
-                   Pressing '<' when standing on a ')' makes the s-expression
-                   to the left of the ')' going out of the current list.
-                   Pressing '<' when standing on a '(' makes the s-expression
-                   to the left of the '(' coming into the current list.
-                   For example pressing <Leader>< at position marked with |:
-                       (aaa bbb|)        --->    (aaa) bbb
-                       aaa |(bbb)        --->    (aaa bbb)
-
-    <Leader>>      If standing on a delimiter (parenthesis or square bracket)
-                   then moves it to the right by slurping or barfing the
-                   s-expression to the right, depending on the direction of the
-                   delimiter:
-                   Pressing '>' when standing on a '(' makes the s-expression
-                   to the right of the '(' going out of the current list.
-                   Pressing '>' when standing on a ')' makes the s-expression
-                   to the right of the ')' coming into the current list.
-                   For example pressing <Leader>< at position marked with |:
-                       (aaa|) bbb        --->    (aaa bbb)
-                       |(aaa bbb)        --->    aaa (bbb)
-
-    <Leader>J      Join two subsequent lists or strings. The first one must end
-                   before the cursor, the second one must start after the
-                   cursor position.
-                   For example pressing <Leader>J at position marked with |:
-                       (aaa)| (bbb)      --->    (aaa bbb)
-                       "aaa"| "bbb"      --->    "aaa bbb"
-
-    <Leader>O      Split ("Open") current list or string at the cursor position.
-                   Opposite of Join. Key O is selected because for the original
-                   Vim mapping J and O are also kind of opposites.
-                   For example pressing <Leader>O at position marked with |:
-                       (aaa |bbb)        --->    (aaa) (bbb)
-                       "aaa|bbb"         --->    "aaa" "bbb"
-
-    <Leader>W      Wrap the current symbol in a pair of parentheses. The cursor
-    <Leader>w(     is then positioned on the opening parenthesis, as wrapping
-                   is usually done because one wants to call a function with
-                   the symbol as parameter, so by pressing "a" one can enter
-                   the function name right after the newly inserted "(".
-                   For example pressing <Leader>W at position marked with |:
-                       (aaa b|bb ccc)    --->    (aaa (bbb) ccc)
-
-    <Leader>w[     Wrap the current symbol in a pair of square brackets,
-                   similarly to <Leader>W.
-                   For example pressing <Leader>w[ at position marked with |:
-                       (aaa b|bb ccc)    --->    (aaa [bbb] ccc)
-
-    <Leader>w"     Wrap the current symbol in a pair of double quotes,
-                   similarly to <Leader>W.
-                   For example pressing <Leader>w" at position marked with |:
-                       (aaa b|bb ccc)    --->    (aaa "bbb" ccc)
-
-    <Leader>S      Splice the current list into the containing list, i.e.
-                   remove the opening and closing parens. Opposite of wrap.
-                   For example pressing <Leader>S at position marked with |:
-                       (aaa (b|bb) ccc)  --->    (aaa bbb ccc)
-
-    x  or  <Del>   When about to delete a (, ), [, ], or " and there are other
-                   characters inside, then just skip it to the right. When
-                   about to delete the closing part of the matched character
-                   with nothing inside, then the whole empty list is removed.
-                   When preceded by a <count> value then delete this many
-                   characters.
-
-    X              When about to delete a (, ), [, ], or " and there are other
-                   characters inside, then just skip it to the left. When
-                   about to delete the opening part of the matched character
-                   with nothing inside, then the whole empty list is removed.
-
-    D              Keep deleting characters towards the end of line,
-                   maintaining the balanced state, i.e. keep the number of
-                   opening and closing parens the same.
-
-    C              Same as 'D' but go to insert mode at the end.
-
-    s              Same as 'x' but go to insert mode at the end.
-
-    dd             Delete whole line by keeping the balanced state, i.e.
-                   keep the number of opening and closing parens the same.
-                   When preceded by a <count> value then delete this many
-                   lines.
-
-    <Leader>S      Same as 'dd' but go to insert mode at the end.
-
-    d{motion}      Delete text till {motion}. Keeps text balanced, so if the
-                   surrounded text contains unpaired matched characters then
-                   they are not removed.
-
-    c{motion}      Delete text till {motion} and start insert mode. Keeps text
-                   balanced just like d{motion}.
-
-    p              Put the text after the cursor with all unbalanced matched
-                   characters removed.
-
-    P              Put the text before the cursor with all unbalanced matched
-                   characters removed.
-
-
-Visual Mode:
-
-    (              Finds opening '(' of the current list and selects the whole
-                   list. Can be pressed repeatedly until the top level form
-                   selected.
-
-    )              Finds closing ')' of the current list and selects the whole
-                   list. Can be pressed repeatedly until the top level form
-                   selected.
-
-    d              Delete the current visual selection. Keeps text balanced,
-    x              so the the selection contains unpaired matched characters
-    <Del>          then they are not removed.
-
-    c              Delete the current visual selection and start insert mode.
-                   Keeps text balanced just like the 'd' command.
-
-    <Leader>W      Wrap the current visual selection in a pair of parentheses.
-    <Leader>w(     The visual selection is kept.
-
-    <Leader>w[     Wrap the current visual selection in a pair of square
-                   brackets. The visual selection is kept.
-
-    <Leader>w"     Wrap the current visual selection in a pair of double
-                   quotes. The visual selection is kept.
-
-
-Please note that if variable |g:paredit_shortmaps| is nonzero then the
-following normal mode mappings don't get a <Leader> prefix, they are mapped
-to existing (but infrequently used) Vim functions and instead the original Vim
-functions are mapped with the <Leader> prefix:
-
-                   <, >, J, O, W, S
-
-
-
-===============================================================================
 EXTERNAL UTILITIES                                             *slimv-external*
 
 This section is about utilities, settings, etc., not related strongly to Slimv,
 - Q: Why is this plugin called 'Slimv'?
 - A: Because it is trying to mimic the popular Emacs extension 'SLIME'.
      In SLIME 'E' stands for 'Emacs', so here it is replaced with 'V' as Vim.
+     The most recent plugin version also contains a SWANK client, so Slimv's
+     functionality is getting closer to SLIME.
      To tell the truth, first I gave the name 'Slimvim' to the plugin but
      then I found an (already abandoned) project called 'Slim-Vim' and I did
      not want to interfere with it.
      in Vim, but this may change in the future.
 
 - Q: How does Slimv work?
-- A: Slimv consists of three parts: Vim plugin, client and server.
-     The Slimv server is a swank server that embeds a console Lisp REPL
+- A: Slimv consists of three parts by the original concept:
+     Vim plugin, client and server.
+     The Slimv server is a swank-like server that embeds a console Lisp REPL
      via pipes, catching all REPL input/output.
      The Slimv client interfaces with the server and is responsible
      for sending Lisp commands to the Lisp REPL.
      The plugin resides in 'slimv.vim', the client and the server both
      located in 'slimv.py'.
 
+     Slimv also contains a SWANK client that is able to communicate a
+     running SWANK server, just as it is done by Emacs with SLIME.
+     The SWANK output is regularly polled via the socket connection.
+     The SWANK client is located in 'swank.py'.
+
 - Q: There is no Slimv server opened when I evaluate a form in Vim.
 - A: There may be many reasons for that. Try to run the server manually by
      opening a new terminal console window and running this command:
         functionality requires that Slimv reads data from REPL, then
         currently it is not possible to implement it.
      2. It is possible to implement it, but I did not (yet) do it.
-        Maybe future releases will contain it.
+        Maybe future releases will contain it. All feature requests are
+        welcome.
 
-- Q: Why is the default port number 5151?
+- Q: Why is the default Slimv port number 5151?
 - A: Hint: what roman numerals are 5,1,5,1? Bingo: VI, doubled.
 
 - Q: What is the version numbering concept?
      it a try.
 
 - Q: Why using Python for the client/server code? Why not Lisp?
-- A: This is for historical reasons and may change in the future.
-     Preliminary versions used Vim's built-in Python support.
-     Later on the client/server code was separated from Vim but still remained
-     written in Python. On Linux this should not be a problem, most Linux
-     distributions contain a Python interpreter with high enough version.
-     On Windows this means, you need to install Python, if you don't have
-     one (at least version 2.4). Anyway, Python is a nice language and
-     also a perfect replacement for calculator.exe :)
+- A: It is needed to use one of Vim's embedded languages for maintaining a
+     permanent socket connection from within Vim. There aren't too many choices,
+     and Lisp is not (yet?) embedded into Vim.
 
 ===============================================================================
 CHANGE LOG                                                    *slimv-changelog*
 
+0.8.0  - Major update: added SWANK client (many thanks to Philipp Marek).
+       - Split documentation into three parts.
+       - Added keymapping hints to GUI menu items.
+       - Renamed Eval-Last-Expression to Eval-Current-Expression.
+       - REPL buffer is not syntax highlighted anymore.
+       - Switch on filetype plugins.
+       - Autodetection for Allegro CL, Lisp Cabinet and Leiningen.
+       - Ask for save before compiling file.
+       - Map <Tab> for symbol name completion.
+       - Bugfix: finding start of keyword in completion.
+       - Bugfix: deleting escaped " inside string.
+       - Bugfix: Up/Down/Enter handling in popup menu.
+
 0.7.7  - Paredit: find next closing paren when using ,< or ,> and not standing
          on a paren.
        - Open REPL buffer upon connecting server.
 ===============================================================================
 ISSUES, LIMITATIONS, KNOWN BUGS                                  *slimv-issues*
 
-- Works only with the console Lisp and Python versions, does not work with the
-  GUI Lisp versions or with a Python IDE (like IDLE).
 - Vim register "s is used for all form selections, so its original content is
   destroyed.
 - Vim mark 's is used to mark the end of the REPL buffer, i.e. the beginning
   of the "command line".
-- Limited profiling support: does not work for all Lisp implementations.
 - Needs Vim version 7.0 or above, because of the intensive use of lists.
-- Needs Python 2.4 or higher (uses the subprocess module)
-- Sometimes a Python exception happens after a CTRL-C inside the REPL buffer
-  followed by an EOF (CTRL-Z or CTRL-D) in the external REPL window.
-- Interruption (Ctrl-C) does not work with all Lisp implementations.
-  For example SBCL exits on Windows when receiving Ctrl-C.
-  It does not work in Clojure.
-  In these cases use the Interrupt-Lisp-Process menu command.
-- There are some functions that are not compatible or simply not working for
-  Clojure.
+- Needs the same Python version that Vim is compiled against
 - It is not possible to run separate Lisp and Clojure REPL in the same
-  Slimv session. Also some other features cannot switch language in the same
-  session, e.g. profiling.
+  Slimv session.
 
 
 ===============================================================================
 TODO                                                               *slimv-todo*
 
-- Add Swank support, i.e. send commands to SLIME's Swank server.
+- Add missing SLIME functions to the SWANK client.
+- Separate SLDB/Inspector/etc buffers from the REPL buffer.
+- Allow connecting remote SWANK server (outside of localhost).
 
 ===============================================================================
 CREDITS                                                         *slimv-credits*
 Please send comments, bug reports, suggestions, etc. to the e-mail address
 above.
 
+Slimv is free software, you can redistribute it and/or modify it any way you
+like, except the embedded SLIME and Swank Clojure.
+
+SLIME is distributed under the terms of the GNU General Public License as
+published by the Free Software Foundation. See the included slime/README file
+or http://common-lisp.net/project/slime/ for details.
+
+Swank Clojure is licensed under the Eclipse Public License. See the file
+swank-clojure/COPYING or https://github.com/technomancy/swank-clojure for
+details.
+
 Credit must go out to Bram Moolenaar and all the Vim developers for making
 the world's (one of the) best editor.
-Thanks to Eric Marsden and all the Emacs/SLIME developers for making SLIME.
-Special thanks to Mark Kantrowitz, Chris McConnell, Skef Wholey and
-Rob MacLachlan for creating the Metering System.
+
+Thanks to Eric Marsden, Luke Gorrie, Helmut Eller, Luke Gorrie, Helmut Eller,
+Tobias C. Rittweiler and all the Emacs/SLIME developers for making SLIME.
 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 Jeffrey Chu, Phil Hagelberg, Hugo Duncan for making Swank Clojure.
+
 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, Brian Kropf, Len Weincier, Andreas Salwasser, Jon Thacker,
-Andrew Hills, Jerome Baum, John Obbele.
+especially to Philipp Marek for his great number of contributions, patches,
+ideas, suggestions on the SWANK integration.
+
+Also thanks to Vlad Hanciuta, Marcin Fatyga, Dmitry Petukhov,
+Daniel Solano G�mez, Brian Kropf, Len Weincier, Andreas Salwasser,
+Jon Thacker, Andrew Hills, Jerome Baum, John Obbele for additional notes and
+contributions.
+
 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.
 
+*swank.txt*                    Slimv                 Last Change: 14 Apr 2011
+
+SWANK client for Slimv                                    *swank* *slimv-swank*
+                               Version 0.8.0
+
+The Superior Lisp Interaction Mode for Vim.
+Slimv contains a SWANK client that can communicate with a running SWANK server
+the same way as done by Emacs with SLIME.
+The SWANK client is part of Slimv, please find additional general purpose
+information about the plugin, like FAQ, changelog, credits, etc in |slimv.txt|.
+
+|swank-installation|         Installation
+|swank-configuration|        Configuration
+|swank-features|             Features
+|swank-functions|            SWANK functions implemented
+
+===============================================================================
+INSTALLATION                                               *swank-installation*
+
+  Required components:
+
+  - Vim 7.0 or newer installed with Python feature enabled.
+    This can be verified by the :ver command, look for the +python string.
+    It is recommended to have also the +balloon_eval feature for displaying
+    symbol descriptions in tooltip.
+  - Python installed.
+    Must be the same Python version that was Vim compiled against.
+    This can also be verified by the :ver command, look for the
+    -DDYNAMIC_PYTHON_DLL=\"pythonXX\" string, where XX is the required
+    Python version.
+  - Lisp or Clojure installed.
+    Any Lisp implementation is OK that has SLIME support.
+
+  The bundle version of Slimv also contains SLIME (in fact the SWANK server
+  part of SLIME) and Swank Clojure. If you intend to use your own version of
+  SLIME, then you need to have your own SWANK server installed.
+  For example Clojure users might consider installing Leiningen and run the
+  SWANK server via 'lein swank'.
+
+
+===============================================================================
+CONFIGURATION                                             *swank-configuration*
+
+                                                            *g:slimv_swank_cmd*
+                                                        *g:slimv_swank_clojure*
+  Slimv tries to autodetect your Python/Lisp/SWANK installation (please find
+  more details about the Python and Lisp autodetection and configuration in
+  |slimv-options|).
+  If the location for the SWANK server is not identified by the script, or you
+  want to use a different command for starting the SWANK server, then you may
+  want to customize the g:slimv_swank_cmd (general) and g:slimv_swank_clojure
+  (Clojure specific) options in your .vimrc file.
+  Enter a Vim command here that spawns a detached process that runs the SWANK
+  server of your choice. It is important to use a Vim command here that returns
+  immediately and does not wait for the termination of the detached process,
+  so begin the command with !start on Windows...:
+
+    let g:slimv_swank_cmd = '!start "c:\Program Files\Lisp Cabinet\bin\ccl\wx86cl.exe" -l "c:\Program Files\Lisp Cabinet\site\lisp\slime\start-swank.lisp"'
+    let g:slimv_swank_clojure = '!start "c:\clojurebox\swank-clojure\src\start-swank.bat"'
+
+  ...and end the command with an & on Linux:
+
+    let g:slimv_swank_cmd = '! xterm -e sbcl --load /usr/share/common-lisp/source/slime/start-swank.lisp &'
+    let g:slimv_swank_clojure = '! xterm -e lein swank &'
+
+  It is also possible to run the SWANK server manually prior running Vim.
+  Slimv detects if a SWANK server is running and connects to it at the first
+  evaluation request.
+
+  Note: It is recommended to pass
+    :dont-close t
+  for the swank:create-server function call in the SWANK startup procedure.
+  This makes a permanent SWANK server that listens continuously. Otherwise
+  each time the SWANK connection is lost, the SWANK server needs to be
+  restarted again.
+  Some SWANK features (like Xref) require the load of the contributed modules,
+  so it is recommended to pass
+    :load-contribs t
+  for the swank-loader:init function call in the SWANK strartup procedure.
+  Example startup script:
+
+(load (merge-pathnames "swank-loader.lisp" *load-truename*))
+
+(swank-loader:init :delete nil
+                   :reload nil
+                   :load-contribs t)
+
+(swank:create-server :port 4005
+                     :coding-system "iso-latin-1-unix"
+                     :dont-close t)
+ 
+
+                                                                 *g:swank_port*
+  The SWANK server is connected to port 4005 by default. This can be changed
+  using the g:swank_port option.
+
+                                                              *g:slimv_timeout*
+  There is a 20 second timeout defined for starting up or connecting to the
+  SWANK server. This timeout can be changed via the g:slimv_timeout option.
+  Please note that the very first startup of the SWANK server may take more
+  time than the subsequent startups, so it is not recommended to make this
+  timeout too low.
+
+
+                                                              *g:slimv_balloon*
+  Specifies if tooltips are on (see |swank-describe|).
+
+
+===============================================================================
+FEATURES                                                       *swank-features*
+
+The following major SLIME (SWANK) features are implemented in Slimv.
+For a complete reference of SWANK functions implemented see |swank-functions|.
+
+|swank-eval|                 Evaluation
+|swank-interrupt|            Interrupt Lisp process
+|swank-restarts|             SLDB: Invoke restarts
+|swank-backtrace|            SLDB: Display backtrace with locals
+|swank-arglist|              Function argument list in status line
+|swank-describe|             Describe symbol in tooltip
+|swank-completions|          List of possible symbol completions
+|swank-inspect|              Inspector
+|swank-trace|                Trace function
+|swank-profile|              Profiler
+|swank-xref|                 Cross Reference
+
+-------------------------------------------------------------------------------
+EVALUATION                                                         *swank-eval*
+
+  There are various methods for evaluating an s-expression in the SWANK server.
+  It is possible to eval the current top level form, the current subform, the
+  visually selected area, or the whole buffer. Consult the "Evaluation commands"
+  section in |slimv_keyboard| for the possible functions with their respective
+  keyboard shortcuts.
+
+
+-------------------------------------------------------------------------------
+INTERRUPT LISP PROCESS                                        *swank-interrupt*
+
+  It is possible to interrupt a running Lisp or Clojure process by selecting
+  the Interrupt-Lisp-Process menu item in the REPL or Slimv/Repl submenu,
+  or by pressing the keyboard shortcut <Leader>i.
+  It is also possible to map the Ctrl-C shortcut in normal mode to perform the
+  interrupt, but this may interfere with the "Copy to clipboard" function
+  especially on Windows. Here is how to do it:
+
+    noremap  <silent> <C-C>      :call SlimvInterrupt()<CR> 
+
+  When a Lisp process is interrupted, we are dropped in SLDB (SLime DeBugger)
+  and the list of restarts (see |swank-restarts|) and calling frame stack
+  (see |swank-backtrace|) is displayed.
+  It is possible to inspect variables (see |swank-inspect|) and continue
+  or break program execution by selecting the appropriate restart.
+  It is also possible to change the value of variables or redefine functions
+  before resuming execution.
+
+
+-------------------------------------------------------------------------------
+INVOKE RESTARTS                                                *swank-restarts*
+
+  In case of an error or when the Lisp process is interrupted SLDB displays
+  the condition and the list of possible restarts, each line startin with the
+  restart identifier, for example:
+
+DIVISION-BY-ZERO detected
+   [Condition of type DIVISION-BY-ZERO]
+
+Restarts:
+  0: [RETRY] Retry SLIME REPL evaluation request.
+  1: [*ABORT] Return to SLIME's top level.
+  2: [ABORT-BREAK] Reset this thread
+  3: [ABORT] Kill this thread
+
+
+  If you press Enter in normal mode on a restart line then the given restart
+  is invoked.
+
+
+-------------------------------------------------------------------------------
+DISPLAY BACKTRACE                                             *swank-backtrace*
+
+  SLDB displays the backtrace for the calling frames, each line starting with
+  the frame identifier, for example:
+
+Backtrace:
+  0: (CCL::%FIXNUM-TRUNCATE #<Unknown Arguments>)
+  1: (/ 1 0)
+  2: (NIL #<Unknown Arguments>)
+  3: (CCL::CALL-CHECK-REGS / 1 0)
+  4: (CCL::CHEAP-EVAL (/ 1 0))
+  5: (SWANK::EVAL-REGION "(/ 1 0)")
+
+
+  If you press Enter in normal mode on a frame line then the local variable
+  bindings for that frame are displayed at the bottom of the SLDB printout.
+
+
+-------------------------------------------------------------------------------
+FUNCTION ARGUMENT LIST                                          *swank-arglist*
+
+  When entering an s-expressin in insert mode, each time a space is pressed
+  after a non-whitespace character, then SWANK is requested for the function
+  argument list for the current function. If the function is known by SWANK
+  then the function prototype is displayed in the status line.
+
+  Note: the function argument list is not displayed when Slimv is not
+  connected to the SWANK server.
+
+
+-------------------------------------------------------------------------------
+DESCRIBE SYMBOL                                                *swank-describe*
+
+  When you hover your mouse over a symbol's name then the symbol description
+  is requested from SWANK and displayed in a tooltip, called balloonexpr in
+  Vim terms. This functionality requires that Vim is compiled with the
+  +balloon_eval feature enabled.
+
+  If you don't have +balloon_eval then it is possible to select the
+  Describe-Symbol menu item from the Slimv/Documentation submenu, or press
+  the <Leader>s keyboard shortcut, which then displays the symbol description
+  in the REPL buffer.
+
+  Note: the symbol description is not displayed when Slimv is not connected
+  to the SWANK server.
+
+
+-------------------------------------------------------------------------------
+COMPLETIONS                                                 *swank-completions*
+
+  The Vim omni-completion function requests the possible completions for the
+  symbol currently being entered from the SWANK server. The completion list
+  is displayed in a popup menu.
+  The keyboard shortcut for completion is <Tab>. This brings up the completions
+  popup menu if there are multiple choices. In the popup menu subsequent <Tab>
+  keypresses select the next possible completion.
+
+  Note: completions are not displayed when Slimv is not connected to the
+  SWANK server.
+
+
+-------------------------------------------------------------------------------
+INSPECTOR                                                       *swank-inspect*
+
+  The Enter key is remapped in normal mode for traversing the inspector output.
+
+  When pressing Enter on the top line starting with 'Inspecting' then the
+  currently inspected value is reloaded.
+
+  When pressing Enter on a line starting with [nn] (where nn is the part
+  identifier) then nn-th part is inspected.
+
+  When pressing Enter on the last line starting with [<<] then the inspector
+  is popped up one level.
+
+
+-------------------------------------------------------------------------------
+TRACE                                                             *swank-trace*
+
+  It is possible to tell the SWANK server to trace or untrace functions.
+  There are some subtle differences in the trace handling with or
+  without SWANK.
+
+  For the trace handling without SWANK please check options
+  |g:slimv_template_trace| and |g:slimv_template_untrace|.
+
+  When using the SWANK server the Trace command toggles tracing for the
+  selected function. In this case there is no Untrace command, but there is
+  an Untrace-All command, which completely switches off tracing.
+  This complies with the SWANK tracing functionality.
+
+
+-------------------------------------------------------------------------------
+PROFILER                                                        *swank-profile*
+
+  Slimv supports SLIME's profiler. It is possible to toggle profiling on a
+  function, on a set of functions whose name contains a given substring, or
+  unprofile all functions. You may query the profiler for the list of profiled
+  functions. After the profiling session it is possible to display the profiler
+  report. Upon selecting Reset all counters are cleared, so that a new
+  profiling session may be started.
+
+
+-------------------------------------------------------------------------------
+CROSS REFERENCE                                                    *swank-xref*
+
+  SLIME's cross reference functionality can be used to list the functions
+  calling a specific function, the list of functions called from a specific
+  function, and other variable, macro, etc. references.
+  Please note that not all Lisp implementations support the xref functionality.
+
+
+===============================================================================
+FUNCTIONS                                                     *swank-functions*
+
+This section contains a reference for the Emacs/SLIME/SWANK functions
+currently implemented in the Slimv SWANK client.
+
+  :emacs-interrupt
+  :emacs-pong
+  :emacs-return-string
+  swank:compile-file-for-emacs
+  swank:compile-string-for-emacs
+  swank:connection-info
+  swank:create-repl
+  swank:describe-function
+  swank:disassemble-form
+  swank:frame-locals-and-catch-tags
+  swank:init-inspector
+  swank:inspect-nth-part
+  swank:inspector-pop
+  swank:invoke-nth-restart-for-emacs
+  swank:listener-eval
+  swank:load-file
+  swank:operator-arglist
+  swank:profile-by-substring
+  swank:profile-report
+  swank:profile-reset
+  swank:profiled-functions
+  swank:set-package
+  swank:simple-completions
+  swank:sldb-abort
+  swank:sldb-continue
+  swank:swank-macroexpand-1
+  swank:swank-macroexpand-all
+  swank:swank-toggle-trace
+  swank:throw-to-toplevel
+  swank:toggle-profile-fdefinition
+  swank:undefine-function
+  swank:unprofile-all
+  swank:untrace-all
+  swank:xref
+
+===============================================================================
+vim:tw=80:noet:wrap:ts=8:ft=help:norl:

ftplugin/clojure/slimv-clojure.vim

 " slimv-clojure.vim:
 "               Clojure filetype plugin for Slimv
-" Version:      0.7.4
-" Last Change:  13 Dec 2010
+" Version:      0.8.0
+" Last Change:  10 Apr 2011
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
 
 let g:slimv_clojure_loaded = 1
 
+" Transform filename so that it will not contain spaces
+function! s:TransformFilename( name )
+    if match( a:name, ' ' ) >= 0
+        return fnamemodify( a:name , ':8' )
+    else
+        return a:name
+    endif
+endfunction
+
 " Build a Clojure startup command by adding
 " all clojure*.jar files found to the classpath
 function! b:SlimvBuildStartCmd( lisps )
-    let cp = a:lisps[0]
+    let cp = s:TransformFilename( a:lisps[0] )
     let i = 1
     while i < len( a:lisps )
-        let cp = cp . ';' . a:lisps[i]
+        let cp = cp . ';' . s:TransformFilename( a:lisps[i] )
         let i = i + 1
     endwhile
-    return ['"java -cp ' . cp . ' clojure.main"', 'clojure']
+    if g:slimv_swank
+        " Try to find swank-clojure and add it to classpath
+        let swanks = split( globpath( &runtimepath, 'swank-clojure'), '\n' )
+        if len( swanks ) > 0
+            let cp = cp . ';' . s:TransformFilename( swanks[0] )
+        endif
+    endif
+    return ['java -cp ' . cp . ' clojure.main', 'clojure']
 endfunction
 
 " Try to autodetect Clojure executable
 " Returns list [Clojure executable, Clojure implementation]
 function! b:SlimvAutodetect()
     " Firts try the most basic setup: everything in the path
+    if executable( 'lein' )
+        return ['"lein repl"', 'clojure']
+    endif
     if executable( 'clojure' )
         return ['clojure', 'clojure']
     endif
         return b:SlimvBuildStartCmd( lisps )
     endif
 
+    if g:slimv_swank
+        " Check if Clojure is bundled with Slimv
+        let lisps = split( globpath( &runtimepath, 'swank-clojure/clojure*.jar'), '\n' )
+        if len( lisps ) > 0
+            return b:SlimvBuildStartCmd( lisps )
+        endif
+    endif
+
     " Try to find Clojure in the PATH
     let path = substitute( $PATH, ';', ',', 'g' )
     let lisps = split( globpath( path, 'clojure*.jar' ), '\n' )
 
     if g:slimv_windows
         " Try to find Clojure on the standard installation places
-        let lisps = split( globpath( 'c:/*clojure*', 'clojure*.jar' ), '\n' )
+        let lisps = split( globpath( 'c:/*clojure*,c:/*clojure*/lib', 'clojure*.jar' ), '\n' )
         if len( lisps ) > 0
             return b:SlimvBuildStartCmd( lisps )
         endif

ftplugin/lisp/slimv-lisp.vim

 " slimv-lisp.vim:
 "               Lisp filetype plugin for Slimv
-" Version:      0.6.0
-" Last Change:  12 Apr 2010
+" Version:      0.8.0
+" Last Change:  02 Apr 2011
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
 " Returns list [Lisp executable, Lisp implementation]
 function! b:SlimvAutodetect()
     " Check the easy cases
+    if executable( 'sbcl' )
+        " Steel Bank Common Lisp
+        return ['sbcl', 'sbcl']
+    endif
     if executable( 'clisp' )
         " Common Lisp
         return ['clisp', 'clisp']
         " Carnegie Mellon University Common Lisp
         return ['cmucl', 'cmu']
     endif
-    if executable( 'sbcl' )
-        " Steel Bank Common Lisp
-        return ['sbcl', 'sbcl']
-    endif
     if executable( 'ecl' )
         " Embeddable Common Lisp
         return ['ecl', 'ecl']
         " Allegro Common Lisp
         return ['acl', 'allegro']
     endif
+    if executable( 'mlisp' )
+        " Allegro Common Lisp
+        return ['mlisp', 'allegro']
+    endif
+    if executable( 'mlisp8' )
+        " Allegro Common Lisp
+        return ['mlisp8', 'allegro']
+    endif
+    if executable( 'alisp' )
+        " Allegro Common Lisp
+        return ['alisp', 'allegro']
+    endif
+    if executable( 'alisp8' )
+        " Allegro Common Lisp
+        return ['alisp8', 'allegro']
+    endif
     if executable( 'lwl' )
         " LispWorks
         return ['lwl', 'lispworks']
 
     if g:slimv_windows
         " Try to find Lisp on the standard installation places
-        let lisps = split( globpath( 'c:/*lisp*,c:/Program Files/*lisp*', '*lisp.exe' ), '\n' )
-        if len( lisps ) > 0
-            return [lisps[0], 'clisp']
-        endif
-        let lisps = split( globpath( 'c:/*lisp*/*,c:/Program Files/*lisp*/*', '*lisp.exe' ), '\n' )
-        if len( lisps ) > 0
-            return [lisps[0], 'clisp']
-        endif
-        let lisps = split( globpath( 'c:/*lisp*/**,c:/Program Files/*lisp*/**', '*lisp.exe' ), '\n' )
+        let lisps = split( globpath( 'c:/*lisp*,c:/*lisp*/*,c:/*lisp*/bin/*,c:/Program Files/*lisp*,c:/Program Files/*lisp*/*,c:/Program Files/*lisp*/bin/*', '*lisp.exe' ), '\n' )
         if len( lisps ) > 0
             return [lisps[0], 'clisp']
         endif
         if len( lisps ) > 0
             return [lisps[0], 'cmu']
         endif
-        let lisps = split( globpath( 'c:/sbcl*,c:/Program Files/sbcl*', 'sbcl.exe' ), '\n' )
+        let lisps = split( globpath( 'c:/sbcl*,c:/Program Files/sbcl*,c:/Program Files/*lisp*/bin/sbcl*', 'sbcl.exe' ), '\n' )
         if len( lisps ) > 0
             return [lisps[0], 'sbcl']
         endif
+        let lisps = split( globpath( 'c:/acl*,c:/Program Files/acl*,c:/Program Files/*lisp*/bin/acl*', '*lisp*.exe' ), '\n' )
+        if len( lisps ) > 0
+            return [lisps[0], 'allegro']
+        endif
         let lisps = split( globpath( 'c:/ecl*,c:/Program Files/ecl*', 'ecl.exe' ), '\n' )
         if len( lisps ) > 0
             return [lisps[0], 'ecl']
         endif
-        let lisps = split( globpath( 'c:/ccl*,c:/Program Files/ccl*', 'wx86cl.exe' ), '\n' )
+        let lisps = split( globpath( 'c:/ccl*,c:/Program Files/ccl*,c:/Program Files/*lisp*/bin/ccl*', 'wx86cl.exe' ), '\n' )
         if len( lisps ) > 0
             return [lisps[0], 'clozure']
         endif

ftplugin/metering.lisp

-;;; -*- Mode: LISP; Package: monitor; Syntax: Common-lisp; Base: 10.;  -*-
-;;; Tue Jan 25 18:32:28 1994 by Mark Kantrowitz <mkant@GLINDA.OZ.CS.CMU.EDU>
-
-;;; ****************************************************************
-;;; Metering System ************************************************
-;;; ****************************************************************
-;;;
-;;; The Metering System is a portable Common Lisp code profiling tool.
-;;; It gathers timing and consing statistics for specified functions
-;;; while a program is running.
-;;;
-;;; The Metering System is a combination of
-;;;   o  the Monitor package written by Chris McConnell
-;;;   o  the Profile package written by Skef Wholey and Rob MacLachlan
-;;; The two systems were merged and extended by Mark Kantrowitz.
-;;;
-;;; Address: Carnegie Mellon University
-;;;          School of Computer Science
-;;;          Pittsburgh, PA 15213
-;;;
-;;; This code is in the public domain and is distributed without warranty
-;;; of any kind.
-;;;
-;;; This copy is from SLIME, http://www.common-lisp.net/project/slime/
-;;;
-;;;
-
-;;; ********************************
-;;; Change Log *********************
-;;; ********************************
-;;;
-;;; 26-JUN-90  mk       Merged functionality of Monitor and Profile packages.
-;;; 26-JUN-90  mk       Now handles both inclusive and exclusive statistics
-;;;                     with respect to nested calls. (Allows it to subtract
-;;;                     total monitoring overhead for each function, not just
-;;;                     the time spent monitoring the function itself.)
-;;; 26-JUN-90  mk       The table is now saved so that one may manipulate
-;;;                     the data (sorting it, etc.) even after the original
-;;;                     source of the data has been cleared.
-;;; 25-SEP-90  mk       Added get-cons functions for Lucid 3.0, MACL 1.3.2
-;;;                     required-arguments functions for Lucid 3.0,
-;;;                     Franz Allegro CL, and MACL 1.3.2.
-;;; 25-JAN-91  mk       Now uses fdefinition if available.
-;;; 25-JAN-91  mk       Replaced (and :allegro (not :coral)) with :excl.
-;;;                     Much better solution for the fact that both call
-;;;                     themselves :allegro.
-;;;  5-JUL-91 mk        Fixed warning to occur only when file is loaded
-;;;                     uncompiled.
-;;;  5-JUL-91 mk        When many unmonitored functions, print out number
-;;;                     instead of whole list.
-;;; 24-MAR-92 mk        Updated for CLtL2 compatibility. space measuring
-;;;                     doesn't work in MCL, but fixed so that timing
-;;;                     statistics do.
-;;; 26-MAR-92 mk        Updated for Lispworks. Replaced :ccl with
-;;;                     (and :ccl (not :lispworks)).
-;;; 27-MAR-92 mk        Added get-cons for Allegro-V4.0.
-;;; 01-JAN-93 mk  v2.0  Support for MCL 2.0, CMU CL 16d, Allegro V3.1/4.0/4.1,
-;;;                     Lucid 4.0, ibcl
-;;; 25-JAN-94 mk  v2.1  Patches for CLISP from Bruno Haible.
-;;; 01-APR-05 lgorrie   Removed support for all Lisps except CLISP and OpenMCL.
-;;;                     Purely to cut down on stale code (e.g. #+cltl2) in this
-;;;                     version that is bundled with SLIME.
-;;; 22-Aug-08 stas      Define TIME-TYPE for Clozure CL.
-;;;
-
-;;; ********************************
-;;; To Do **************************
-;;; ********************************
-;;;
-;;;    - Need get-cons for Allegro, AKCL.
-;;;    - Speed up monitoring code. Replace use of hash tables with an embedded
-;;;      offset in an array so that it will be faster than using gethash.
-;;;      (i.e., svref/closure reference is usually faster than gethash).
-;;;    - Beware of (get-internal-run-time) overflowing. Yikes!
-;;;    - Check robustness with respect to profiled functions.
-;;;    - Check logic of computing inclusive and exclusive time and consing.
-;;;      Especially wrt incf/setf comment below. Should be incf, so we
-;;;      sum recursive calls.
-;;;    - Add option to record caller statistics -- this would list who
-;;;      called which functions and how often.
-;;;    - switches to turn timing/CONSING statistics collection on/off.
-
-
-;;; ********************************
-;;; Notes **************************
-;;; ********************************
-;;;
-;;;    METERING has been tested (successfully) in the following lisps:
-;;;       CMU Common Lisp (16d, Python Compiler 1.0 ) :new-compiler
-;;;       CMU Common Lisp (M2.9 15-Aug-90, Compiler M1.8 15-Aug-90)
-;;;       Macintosh Allegro Common Lisp (1.3.2)
-;;;       Macintosh Common Lisp (2.0)
-;;;       ExCL (Franz Allegro CL 3.1.12 [DEC 3100] 11/19/90)   :allegro-v3.1
-;;;       ExCL (Franz Allegro CL 4.0.1 [Sun4] 2/8/91)          :allegro-v4.0
-;;;       ExCL (Franz Allegro CL 4.1 [SPARC R1] 8/28/92 14:06) :allegro-v4.1
-;;;       ExCL (Franz ACL 5.0.1 [Linux/X86] 6/29/99 16:11)     :allegro-v5.0.1
-;;;       Lucid CL (Version 2.1 6-DEC-87)
-;;;       Lucid Common Lisp (3.0)
-;;;       Lucid Common Lisp (4.0.1 HP-700 12-Aug-91)
-;;;       AKCL (1.86, June 30, 1987 or later)
-;;;       Ibuki Common Lisp (Version 2, release 01.027)
-;;;       CLISP (January 1994)
-;;;
-;;;    METERING needs to be tested in the following lisps:
-;;;       Symbolics Common Lisp (8.0)
-;;;       KCL (June 3, 1987 or later)
-;;;       TI (Release 4.1 or later)
-;;;       Golden Common Lisp (3.1 IBM-PC)
-;;;       VAXLisp (2.0, 3.1)
-;;;       Procyon Common Lisp
-
-
-;;; ****************************************************************
-;;; Documentation **************************************************
-;;; ****************************************************************
-;;;
-;;; This system runs in any valid Common Lisp. Four small
-;;; implementation-dependent changes can be made to improve performance
-;;; and prettiness. In the section labelled "Implementation Dependent
-;;; Changes" below, you should tailor the functions REQUIRED-ARGUMENTS,
-;;; GET-CONS, GET-TIME, and TIME-UNITS-PER-SECOND to your implementation
-;;; for the best results. If GET-CONS is not specified for your
-;;; implementation, no consing information will be reported. The other
-;;; functions will default to working forms, albeit inefficient, in
-;;; non-CMU implementations. If you tailor these functions for a particular
-;;; version of Common Lisp, we'd appreciate receiving the code.
-;;;
-
-;;; ****************************************************************
-;;; Usage Notes ****************************************************
-;;; ****************************************************************
-;;;
-;;; SUGGESTED USAGE:
-;;;
-;;; Start by monitoring big pieces of the program, then carefully choose
-;;; which functions close to, but not in, the inner loop are to be
-;;; monitored next. Don't monitor functions that are called by other
-;;; monitored functions: you will only confuse yourself.
-;;;
-;;; If the per-call time reported is less than 1/10th of a second, then
-;;; consider the clock resolution and profiling overhead before you believe
-;;; the time. It may be that you will need to run your program many times
-;;; in order to average out to a higher resolution.
-;;;
-;;; The easiest way to use this package is to load it and execute either
-;;;     (mon:with-monitoring (names*) ()
-;;;         your-forms*)
-;;; or
-;;;     (mon:monitor-form your-form)
-;;; The former allows you to specify which functions will be monitored; the
-;;; latter monitors all functions in the current package. Both automatically
-;;; produce a table of statistics. Other variants can be constructed from
-;;; the monitoring primitives, which are described below, along with a
-;;; fuller description of these two macros.
-;;;
-;;; For best results, compile this file before using.
-;;;
-;;;
-;;; CLOCK RESOLUTION:
-;;;
-;;; Unless you are very lucky, the length of your machine's clock "tick" is
-;;; probably much longer than the time it takes a simple function to run.
-;;; For example, on the IBM RT, the clock resolution is 1/50th of a second.
-;;; This means that if a function is only called a few times, then only the
-;;; first couple of decimal places are really meaningful.
-;;;
-;;;
-;;; MONITORING OVERHEAD:
-;;;
-;;; The added monitoring code takes time to run every time that the monitored
-;;; function is called, which can disrupt the attempt to collect timing
-;;; information. In order to avoid serious inflation of the times for functions
-;;; that take little time to run, an estimate of the overhead due to monitoring
-;;; is subtracted from the times reported for each function.
-;;;
-;;; Although this correction works fairly well, it is not totally accurate,
-;;; resulting in times that become increasingly meaningless for functions
-;;; with short runtimes. For example, subtracting the estimated overhead
-;;; may result in negative times for some functions. This is only a concern
-;;; when the estimated profiling overhead is many times larger than
-;;; reported total CPU time.
-;;;
-;;; If you monitor functions that are called by monitored functions, in
-;;; :inclusive mode the monitoring overhead for the inner function is
-;;; subtracted from the CPU time for the outer function. [We do this by
-;;; counting for each function not only the number of calls to *this*
-;;; function, but also the number of monitored calls while it was running.]
-;;; In :exclusive mode this is not necessary, since we subtract the
-;;; monitoring time of inner functions, overhead & all.
-;;;
-;;; Otherwise, the estimated monitoring overhead is not represented in the
-;;; reported total CPU time. The sum of total CPU time and the estimated
-;;; monitoring overhead should be close to the total CPU time for the
-;;; entire monitoring run (as determined by TIME).
-;;;
-;;; A timing overhead factor is computed at load time. This will be incorrect
-;;; if the monitoring code is run in a different environment than this file
-;;; was loaded in. For example, saving a core image on a high performance
-;;; machine and running it on a low performance one will result in the use
-;;; of an erroneously small overhead factor.
-;;;
-;;;
-;;; If your times vary widely, possible causes are:
-;;;    - Garbage collection.  Try turning it off, then running your code.
-;;;      Be warned that monitoring code will probably cons when it does
-;;;      (get-internal-run-time).
-;;;    - Swapping.  If you have enough memory, execute your form once
-;;;      before monitoring so that it will be swapped into memory. Otherwise,
-;;;      get a bigger machine!
-;;;    - Resolution of internal-time-units-per-second.  If this value is
-;;;      too low, then the timings become wild. You can try executing more
-;;;      of whatever your test is, but that will only work if some of your
-;;;      paths do not match the timer resolution.
-;;;      internal-time-units-per-second is so coarse -- on a Symbolics it is
-;;;      977, in MACL it is 60.
-;;;
-;;;
-
-;;; ****************************************************************
-;;; Interface ******************************************************
-;;; ****************************************************************
-;;;
-;;; WITH-MONITORING (&rest functions)                         [Macro]
-;;;                 (&optional (nested :exclusive)
-;;;                            (threshold 0.01)
-;;;                            (key :percent-time))
-;;;                 &body body
-;;; The named functions will be set up for monitoring, the body forms executed,
-;;; a table of results printed, and the functions unmonitored. The nested,
-;;; threshold, and key arguments are passed to report-monitoring below.
-;;;
-;;; MONITOR-FORM form                                         [Macro]
-;;;               &optional (nested :exclusive)
-;;;                         (threshold 0.01)
-;;;                         (key :percent-time)
-;;; All functions in the current package are set up for monitoring while
-;;; the form is executed, and automatically unmonitored after a table of
-;;; results has been printed. The nested, threshold, and key arguments
-;;; are passed to report-monitoring below.
-;;;
-;;; *MONITORED-FUNCTIONS*                                     [Variable]
-;;; This holds a list of all functions that are currently being monitored.
-;;;
-;;; MONITOR &rest names                                       [Macro]
-;;; The named functions will be set up for monitoring by augmenting
-;;; their function definitions with code that gathers statistical information
-;;; about code performance. As with the TRACE macro, the function names are
-;;; not evaluated. Calls the function MON::MONITORING-ENCAPSULATE on each
-;;; function name. If no names are specified, returns a list of all
-;;; monitored functions.
-;;;
-;;; If name is not a symbol, it is evaled to return the appropriate
-;;; closure. This allows you to monitor closures stored anywhere like
-;;; in a variable, array or structure. Most other monitoring packages
-;;; can't handle this.
-;;;
-;;; MONITOR-ALL &optional (package *package*)                 [Function]
-;;; Monitors all functions in the specified package, which defaults to
-;;; the current package.
-;;;
-;;; UNMONITOR &rest names                                     [Macro]
-;;; Removes monitoring code from the named functions. If no names are
-;;; specified, all currently monitored functions are unmonitored.
-;;;
-;;; RESET-MONITORING-INFO name                                [Function]
-;;; Resets the monitoring statistics for the specified function.
-;;;
-;;; RESET-ALL-MONITORING                                      [Function]
-;;; Resets the monitoring statistics for all monitored functions.
-;;;
-;;; MONITORED name                                            [Function]
-;;; Predicate to test whether a function is monitored.
-;;;
-;;; REPORT-MONITORING &optional names                         [Function]
-;;;                             (nested :exclusive)
-;;;                             (threshold 0.01)
-;;;                             (key :percent-time)
-;;; Creates a table of monitoring information for the specified list
-;;; of names, and displays the table using display-monitoring-results.
-;;; If names is :all or nil, uses all currently monitored functions.
-;;; Takes the following arguments:
-;;;    - NESTED specifies whether nested calls of monitored functions
-;;;      are included in the times for monitored functions.
-;;;      o  If :inclusive, the per-function information is for the entire