Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Support for Windows x64, improved error handling

Thanks to Stan Angeloff for getting me to build an x64 DLL
and helping me test the DLL and automatic bitness detection.
  • Loading branch information...
commit 669a9f2d5cce67b34599dc820abb471b2faeee2b 1 parent 281d77e
Peter Odding authored December 04, 2010
8  README.md
Source Rendered
@@ -8,11 +8,11 @@ This plug-in aims to improve the integration between [Vim][vim] and its environm
8 8
 
9 9
  * The `xolox#shell#execute()` function enables other Vim plug-ins (like my [easytags.vim] [easytags] plug-in) to execute external commands in the background (i.e. asynchronously) *without opening a command prompt window on Windows*.
10 10
 
11  
-A [Windows DLL][dll] is included to perform these functions on Windows, while on UNIX external commands are used.
  11
+Two [Windows DLL files][dll] are included to perform these functions on Windows, while on UNIX external commands are used.
12 12
 
13 13
 ## Usage
14 14
 
15  
-The below paragraphs document the functionality in the `shell.vim` plug-in. I'd be very grateful if people would test the plug-in in different environments and report their results by contacting the [vim-dev](http://vimdoc.sourceforge.net/htmldoc/intro.html#vim-dev) mailing-list or e-mailing me directly at <peter@peterodding.com>. You can test the DLL by unpacking the [ZIP archive from www.vim.org][download] in the `%USERPROFILE%\vimfiles` directory (on Windows) or the `~/.vim/` directory (on UNIX), restarting Vim and testing the three functions described above and documented below.
  15
+The below paragraphs document the functionality in the `shell.vim` plug-in. I'd be very grateful if people would test the plug-in in different environments and report their results by contacting the [vim-dev](http://vimdoc.sourceforge.net/htmldoc/intro.html#vim-dev) mailing-list or e-mailing me directly at <peter@peterodding.com>. You can test the plug-in by unpacking the [ZIP archive from www.vim.org][download] in the `%USERPROFILE%\vimfiles` directory (on Windows) or the `~/.vim/` directory (on UNIX), restarting Vim and checking whether the commands below work as documented.
16 16
 
17 17
 ### The `:Fullscreen` command
18 18
 
@@ -77,7 +77,7 @@ Vim has a limited ability to call external libraries using the Vim script functi
77 77
 
78 78
 Since then I switched to Linux and didn't look back, which meant the DLL sat in my `~/.vim/etc/` waiting to be revived. Now that I've published my [easytags.vim][easytags] plug-in and put a lot of effort into making it Windows compatible, the `execute()` function from the DLL would be very useful to run [Exuberant Ctags][ctags] in the background without stealing Vim's focus by opening a command prompt window. This is why I've decided to release the DLL. Because I switched to Linux I've also added an autoload script that wraps the DLL on Windows and calls out to external programs such as `wmctrl`, `gnome-open`, `kde-open`, and others on UNIX.
79 79
 
80  
-Before I go ahead and bundle the DLL with my [easytags.vim][easytags] plug-in I need to make sure that the DLL is compatible with as many Windows Vim installations out there as possible, e.g. XP/Vista/7, different service packs, 32/64 bits, etc. and I don't know where to start! I've uploaded a [ZIP archive including a compiled DLL][download] to the [Vim scripts page][vim_scripts_entry] for this plug-in (build using the latest Windows SDK but targeting Windows XP x86 DEBUG, should also work on Vista/7) and the source code is available in the [GitHub repository](http://github.com/xolox/vim-shell) (see the `NMAKE` [makefile](http://github.com/xolox/vim-shell/blob/master/dll/Makefile) for compile instructions).
  80
+Before I go ahead and bundle the DLL files with my [easytags.vim][easytags] plug-in I need to make sure they're compatible with as many Windows Vim installations out there as possible, e.g. XP/Vista/7, different service packs, 32/64 bits, etc. I've uploaded a [ZIP archive including two compiled DLL files][download] to the [Vim scripts page][vim_scripts_entry] for this plug-in (build using the latest Windows SDK but targeting Windows XP x86/x64 DEBUG, should also work on Vista/7) and the source code is available in the [GitHub repository](http://github.com/xolox/vim-shell) (see the `NMAKE` [makefile](http://github.com/xolox/vim-shell/blob/master/dll/Makefile) for compile instructions).
81 81
 
82 82
 ## Other full-screen implementations
83 83
 
@@ -85,7 +85,7 @@ After publishing this plug-in I found that the Vim plug-ins [VimTweak](http://ww
85 85
 
86 86
 ## Contact
87 87
 
88  
-If you have questions, bug reports, suggestions, etc. the author can be contacted at <peter@peterodding.com>. The latest version is available at <http://peterodding.com/code/vim/shell/> and <http://github.com/xolox/vim-shell>. If you like the plug-in please vote for it on [www.vim.org] [vim_scripts_entry].
  88
+If you have questions, bug reports, suggestions, etc. the author can be contacted at <peter@peterodding.com>. The latest version is available at <http://peterodding.com/code/vim/shell/> and <http://github.com/xolox/vim-shell>. If you like the plug-in please vote for it on [Vim Online] [vim_scripts_entry].
89 89
 
90 90
 ## License
91 91
 
35  autoload.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim auto-load script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: September 19, 2010
  3
+" Last Change: December 4, 2010
4 4
 " URL: http://peterodding.com/code/vim/shell/
5 5
 
6 6
 if !exists('s:script')
@@ -11,21 +11,25 @@ if !exists('s:script')
11 11
 endif
12 12
 
13 13
 function! xolox#shell#open_cmd(arg) " -- implementation of the :Open command {{{1
14  
-  if a:arg !~ '\S'
15  
-    if !s:open_at_cursor()
16  
-      call xolox#open#file(expand('%:p:h'))
17  
-    endif
18  
-  elseif a:arg =~ g:shell_patt_url || a:arg =~ g:shell_patt_mail
19  
-    call xolox#open#url(a:arg)
20  
-  else
21  
-    let arg = fnamemodify(a:arg, ':p')
22  
-    if isdirectory(arg) || filereadable(arg)
23  
-      call xolox#open#file(arg)
  14
+  try
  15
+    if a:arg !~ '\S'
  16
+      if !s:open_at_cursor()
  17
+        call xolox#open#file(expand('%:p:h'))
  18
+      endif
  19
+    elseif a:arg =~ g:shell_patt_url || a:arg =~ g:shell_patt_mail
  20
+      call xolox#open#url(a:arg)
24 21
     else
25  
-      let msg = "%s: I don't know how to open %s!"
26  
-      echoerr printf(msg, s:script, string(a:arg))
  22
+      let arg = fnamemodify(a:arg, ':p')
  23
+      if isdirectory(arg) || filereadable(arg)
  24
+        call xolox#open#file(arg)
  25
+      else
  26
+        let msg = "%s: I don't know how to open %s!"
  27
+        echoerr printf(msg, s:script, string(a:arg))
  28
+      endif
27 29
     endif
28  
-  endif
  30
+  catch
  31
+    call xolox#warning("%s at %s", v:exception, v:throwpoint)
  32
+  endtry
29 33
 endfunction
30 34
 
31 35
 function! s:open_at_cursor()
@@ -201,7 +205,8 @@ endfunction
201 205
 
202 206
 if xolox#is_windows()
203 207
 
204  
-  let s:library = expand('<sfile>:p:h') . '\shell.dll'
  208
+  let s:cpu_arch = has('win64') ? 'x64' : 'x86'
  209
+  let s:library = printf('%s\shell-%s.dll', expand('<sfile>:p:h'), s:cpu_arch)
205 210
 
206 211
   function! s:library_call(fn, arg) " {{{2
207 212
     return libcall(s:library, a:fn, a:arg)
8  dll/Makefile
... ...
@@ -1,7 +1,7 @@
1  
-# This is a makefile for NMAKE from the Windows SDK.
2  
-
3  
-install: shell.dll
4  
-	COPY shell.dll "%USERPROFILE%\vimfiles\autoload\xolox\shell.dll"
  1
+# This makefile for NMAKE from the Windows SDK will compile the DLL based on
  2
+# how you configured your Windows SDK build console using SetEnv. Make sure to
  3
+# rename the compiled DLL to shell-x86.dll or shell-x64.dll when you copy it to
  4
+# the %USERPROFILE\vimfiles\autoload\xolox directory.
5 5
 
6 6
 shell.dll: shell.c
7 7
 	CL /nologo /LD shell.c shell32.lib user32.lib
4  shell.vim
... ...
@@ -1,9 +1,9 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: September 19, 2010
  3
+" Last Change: December 1, 2010
4 4
 " URL: http://peterodding.com/code/vim/shell/
5 5
 " License: MIT
6  
-" Version: 0.8.2
  6
+" Version: 0.9
7 7
 
8 8
 " Support for automatic update using the GLVS plug-in.
9 9
 " GetLatestVimScripts: 3123 1 :AutoInstall: shell.zip

0 notes on commit 669a9f2

Please sign in to comment.
Something went wrong with that request. Please try again.