Patch for Vim 7

The patch adds some functions to the Vim Python interface. The functions enable a Python script to write directly into the Vim's internal representation of the screen and read some information that isn't (always) exposed in unpatched Vim. A patched, configured and compiled version of Vim will have the feature "+python_screen" enabled.

The patch modifies the following Vim 7.2 files: if_python.c, eval.c, version.c, configure.in, config.h.in. The patch for Vim 7.3 modifies additional files: if_python3.c and if_py_both.h.

The features provided by the patch are enabled with the configure option --enable-pythonscreen.

Applying the patch

Linux:

  • Copy the file pythonscreen_XXX.patch into the directory vim/src

  • Apply the patch:

    cd vim/src
    patch < pythonscreen_XXX.patch
    
  • Update configure script

    make autoconf
    

This step will create a new auto/configure script. Check the warnings in Makefile comments.

  • Configure Vim for building:

    # Example bash script. Notice --enable-pythonscreen option.
    export CONF_OPT_PYTHON='--enable-pythoninterp --enable-pythonscreen'
    export CONF_OPT_GUI='--enable-gnome-check'
    export CONF_OPT_PERL='--enable-perlinterp'
    export CONF_OPT_TCL='--enable-tclinterp --with-tcl=tclsh8.4'
    export CONF_OPT_RUBY='--enable-rubyinterp'
    export CONF_OPT_MZSCHEME='--disable-mzschemeinterp'
    export CONF_OPT_CSCOPE='--enable-cscope'
    export CONF_OPT_MULTIBYTE='--enable-multibyte'
    export CONF_OPT_FEAT='--with-features=huge'
    export CONF_OPT_COMPBY='"--with-compiledby=Me"'
    export CONF_ARGS='--prefix=/usr'
    export CONF_ARGS="$CONF_ARGS "'--with-vim-name=vim.gnome --with-modified-by="Me"'
    
  • Build Vim:

    make reconfig
    

If all went well, vim.gnome was created in the directory vim/src.

Windows:

  • Copy the file pythonscreen_XXX.patch into the directory vimsrc

  • Apply the patch:

    cd vim\src
    patch < pythonscreen\_XXX.patch
    

    The following links may be useful (you may need to convert EOLs in all vim files and the patch to CR-LF with unix2dos): http://gnuwin32.sourceforge.net/packages/patch.htm http://gnuwin32.sourceforge.net/packages/cygutils.htm

  • Build vim

    GUI version (all on one line):

     nmake -f Make_mvc.mak FEATURES=HUGE GUI=yes
         PYTHON=c:\python26 DYNAMIC_PYTHON=yes PYTHON_VER=26
         IME=yes CSCOPE=yes "DEFINES=-DFEAT_PYTHON_SCREEN"
    

    Console version (all on one line):

     nmake -f Make_mvc.mak FEATURES=HUGE GUI=no
         PYTHON=c:\python26 DYNAMIC_PYTHON=yes PYTHON_VER=26
         IME=yes CSCOPE=yes "DEFINES=-DFEAT_PYTHON_SCREEN"
    

    Make sure there is the correct path in PYTHON and the correct version in PYTHON_VER. You may have to run 'nmake -f Make_mvc.mak clean' between the above builds.