Skip to content
Browse files

Version 4.0

New Features
------------
- Updated documentation.  Added a troubleshooting section (Zsolt Botykai).
- Updated outlookvim.js to display a message if double clicked on to determine if Windows Script Host is correctly installed.
- Updated outlookvim.bas (the Outlook VBScript Macro) to show an error if it cannot access the file system.  Modified all the message boxes Outlook may display to indicate "OutlookVim:" is displaying the message.
- You can specify whether new emails should be opened in a new tab via the g:outlook_use_tabs configuration option (Zsolt Botykai).

After unzipping the contents into your vimfiles directory, copy and paste the outlookvim.bas file into your Outlook macro created earlier (ALT-F11 in Outlook).

Also from within Vim run (choose the location where the plugin was installed):
:helptags $VIM\vimfiles\doc
  • Loading branch information...
1 parent 31df3dd commit 5d0493699bca1f45f0c7c041a0b77557dbc7c9c3 @dfishburn dfishburn committed with
Showing with 280 additions and 145 deletions.
  1. +91 −25 doc/outlook.txt
  2. +31 −10 plugin/OutlookVim.bas
  3. +116 −88 plugin/outlook.vim
  4. +42 −22 plugin/outlookvim.js
View
116 doc/outlook.txt
@@ -1,15 +1,15 @@
-*outlook.txt* For Vim version 7.0. Last change: 2010 May 09
+*outlook.txt* For Vim version 7.0. Last change: 2010 May 25
- VIM REFERENCE MANUAL
+ VIM REFERENCE MANUAL
by
David Fishburn <dfishburn dot vim at gmail dot com>
- Outlook Vim Plugin
- outlook.vim version 3.0
+ Outlook Vim Plugin
+ outlook.vim version 4.0
For instructions on installing this file, type
- :help add-local-help
+ :help add-local-help
|add-local-help| inside Vim.
Homepage: http://vim.sourceforge.net/script.php?script_id=3087
@@ -17,16 +17,17 @@ Homepage: http://vim.sourceforge.net/script.php?script_id=3087
*outlook*
*outlookvim*
-1. Overview |outlook-overview|
-2. Whats New |outlook-new|
+1. Overview |outlook-overview|
+2. Whats New |outlook-new|
3. Installing the plugin |outlook-install|
4. Installing the Outlook macro |outlook-macro|
-5. Configuration |outlook-configuration|
+5. Configuration |outlook-configuration|
+6. Troubleshooting |outlook-troubleshooting|
{Vi does not have any of this}
==============================================================================
-1. Overview *outlook-overview*
+1. Overview *outlook-overview*
This plugin has two parts.
@@ -42,18 +43,23 @@ things:
Vim
---
The outlook.vim plugin is responsible for setting up some autocmds inside
-of Vim. These autocmds are responsible for updating Outlook when the
-buffer (email) is updated.
+of Vim. There are a number of configuration options which allows you to tweak
+the behaviour of the plugin. The autocmds also set the Vim filetype to "mail"
+which allows you to customize even further using the usual Vim filetype plugins.
+
+These autocmds are responsible for updating Outlook when the buffer (email) is
+updated. Communication with Outlook is via the Windows Script Host (WSH
+http://en.wikipedia.org/wiki/Windows_Script_Host) automation technology from
+Microsoft.
The autocmds will execute the outlookvim.js (javascript) file which uses
-the .outlook.ctl file to figure out which email to update and puts the
+the .outlook.ctl file to determine which email to update and places the
contents of the .outlook file into the body of the message in Outlook.
It then deletes these temporary files when finished.
-The autocmds also will delete these temporary files if you choose to abandon
+The autocmds also will delete the temporary files if you choose to abandon
the changes (in Vim) by using :bdelete, :bwipe or closing Vim.
-
After creating the Outlook macro and installing the Vim Outlook plugin, no
other changes are required except editing and saving your emails.
@@ -68,7 +74,21 @@ David Fishburn
==============================================================================
-2. What's New *outlook-new*
+2. What's New *outlook-new*
+
+Version 4.0
+
+ New Features
+ ------------
+ - Updated documentation. Added a troubleshooting section (Zsolt Botykai).
+ - Updated outlookvim.js to display a message if double clicked on to determine
+ if Windows Script Host is correctly installed.
+ - Updated outlookvim.bas (the Outlook VBScript Macro) to show an error if it
+ cannot access the file system. Modified all the message boxes to indicate
+ it is "OutlookVim:" which is displaying the message.
+ - You can specify whether new emails should be opened in a new tab via
+ the g:outlook_use_tabs configuration option (Zsolt Botykai).
+
Version 3.0
@@ -99,7 +119,7 @@ Version 1.0
==============================================================================
-3. Installing the plugin *outlook-install*
+3. Installing the plugin *outlook-install*
You can use this script as a plugin by copying it to your plugin directory.
See |add-global-plugin| for instructions.
@@ -107,8 +127,8 @@ Version 1.0
You can also |:source| it from your |.vimrc|.
To install this help file |add-local-help| inside Vim.
- :help add-local-help
- :helptags $VIM/vimfiles/doc (Windows)
+ :help add-local-help
+ :helptags $VIM/vimfiles/doc (Windows)
Files used by the plugin:
outlook.vim
@@ -129,9 +149,8 @@ Version 1.0
set nocompatible
<
-
==============================================================================
-4. Installing the Outlook macro *outlook-macro*
+4. Installing the Outlook macro *outlook-macro*
The macro is used to add a button in Outlook to lauch Vim. It is used to
create the files which Vim will edit. It will also add a shortcut key
@@ -196,11 +215,19 @@ Version 1.0
If you changed the Macro Security settings you must restart Outlook
- for these changes to be active.
-
+ for these changes to be active. If you are prompted when you restart Outlook
+ on whether it should enable Macros, these pages might be useful to figure out
+ how to sign your macro: >
+ Macro Security settings and creating digit certificates
+ http://www.pcreview.co.uk/forums/thread-854025.php
+<
+ I haven't tried the above. If you do manage to accomplish this, please email
+ the author with some instructions and I will include this in a future release.
+ NOTE: You are only prompted once per session if Macros should be enabled.
+
==============================================================================
-5. Configuration *outlook-configuration*
+5. Configuration *outlook-configuration*
The behavior of outlook.vim is governed by several variables. These variables
are used by the autocmds which are created by the plugin. These variables can
@@ -217,6 +244,10 @@ Version 1.0
let g:outlook_javascript = expand('$APPDATA\Microsoft\outlookvim.js')
let g:outlook_javascript = expand('$USERPROFILE\Application Data\Microsoft\outlookvim.js')
<
+ This setting (default = 0) will force all emails to be edited in a new
+ tab in Vim. >
+ let g:outlook_use_tabs = 1
+<
This setting (default = '') will force all emails to be edited in a particular
Vim instance. If the instance has not be started, a message is displayed
with an example command line to start an appropriate Vim. >
@@ -236,7 +267,9 @@ Version 1.0
When you save a file, by default, Outlook will be updated and the temporary
file you are editing will be deleted. Since the file has been deleted, you
are left editing a file that no longer exists. By default, the Vim buffer
- will be deleted automatically, unless this option (default = 1) is set. >
+ will be deleted automatically, unless this option (default = 1) is set.
+ If you want to be able to save the file multiple times before removing the
+ buffer from Vim, set the following: >
let g:outlook_nobdelete = 1
<
If you do not save the temporary file and instead decide to throw away your
@@ -256,6 +289,39 @@ Version 1.0
to update Outlook. This debugging output should help identify where
any problems may lie. >
let g:outlook_view_cscript_error = 1
+
+
+==============================================================================
+6. Troubleshooting (various versions of Windows) *outlook-troubleshooting*
+
+ If you're Outlook macro does not work at all (or opens a Vim (GUI) window
+ but without proper contents/filename), you should check your Internet
+ Explorer's security settings.
+
+ Go to IE => Tools => Options => Security tab => Custom level and check if the
+ various ActiveX components are allowed to run.
+
+ If they are enabled, and the Outlook macro still does not work, your Windows
+ Script Host (WSH) might not be installed correctly. To test this, open Windows
+ Explorer (not Internet Explorer) and navigate to where your Vim plugins
+ are installed. Find the plugin\OutlookVim.js file and double click on it.
+ This will launch the javascript file and a Message Box should popup saying: >
+ "Hello from OutlookVim!"
+<
+ If the Message Box is not displayed or some other error is displayed, your
+ Windows Script Host (WSH) might not be installed correctly. You may want to
+ reinstall WSH by following the Upgrade links found at the WSH home page. >
+ http://msdn.microsoft.com/en-us/library/9bbdkx3k.aspx
+<
+ The following has solved the problem for at least one user on a Windows XP
+ system using Outlook 2003. Re-registering the Windows Script Host's DLLs.
+ Hit the *Win+R* keyboard combination and run these 2 commands (separately): >
+ regsvr32 wshom.ocx
+ regsvr32 scrrun.dll
<
+ If the above does not help, or if you receive an error message when running
+ the two commands above, then you may need to contact Microsoft Support.
+
- vim:tw=78:fo=tcq2:ts=8:ft=help:norl:
+==============================================================================
+ vim:tw=78:fo=tcq2:ts=4:ft=help:norl:
View
41 plugin/OutlookVim.bas
@@ -1,3 +1,15 @@
+' OutlookVim.bas - Edit emails using Vim from Outlook
+' ---------------------------------------------------------------
+' Version: 4.0
+' Authors: David Fishburn <dfishburn dot vim at gmail dot com>
+' Last Modified: 2010 May 25
+' Homepage: http://vim.sourceforge.net/script.php?script_id=???
+'
+' This VBScript should be installed as a macro inside of Microsoft Outlook.
+' It will create two files and ask Vim to edit the file (body of the email)
+' and Vim with use the second file to update the body of the email in
+' Outlook with your changes.
+'
' This code came from here originally:
' http://barnson.org/node/295
' Some links might be useful
@@ -5,7 +17,7 @@
' Macro Security settings and creating digit certificates
' http://www.pcreview.co.uk/forums/thread-854025.php
'
-' Version 3.0
+' Version 4.0
Option Explicit
@@ -67,7 +79,8 @@ Sub Edit()
' Const VIMLocation = "C:\Vim\vim72\gvim.exe"
- Dim ol, insp, item, fso, tempfile, tfolder, tname, tfile, cfile, entryID, appRef, x, index, Vim, vimKeys, vimResponse, vimServerName
+ Dim ol, insp, item, fso, tempfile, tfolder, tname, tfile, cfile, entryID, appRef, x, index
+ Dim Vim, vimKeys, vimResponse, vimServerName
Dim overwrite As Boolean, unicode As Boolean
' MsgBox ("Just starting LaunchVim")
@@ -97,7 +110,7 @@ Sub Edit()
If Err.Number <> 0 Then
' Clear Err object fields.
' Err.Clear
- MsgBox ("Cannot edit with Vim, could not save item:" & vbCrLf & Err.Description)
+ MsgBox ("OutlookVim: Cannot edit with Vim, could not save item:" & vbCrLf & Err.Description)
Exit Sub
End If
End If
@@ -105,19 +118,19 @@ Sub Edit()
' Create an instance of Vim (if one does not already exist)
Set Vim = CreateObject("Vim.Application")
If Vim Is Nothing Then
- MsgBox ("Could not create a Vim OLE object, please ensure Vim has been installed." & vbCrLf & "Inside Vim, run this command, it should echo 1," & vbCrLf & " :echo has('ole')")
+ MsgBox ("OutlookVim: Could not create a Vim OLE object, please ensure Vim has been installed." & vbCrLf & "Inside Vim, run this command, it should echo 1," & vbCrLf & " :echo has('ole')")
Exit Sub
End If
vimResponse = Vim.Eval("(exists('g:loaded_outlook')?1:0)")
If vimResponse = 0 Then
- MsgBox ("Please install the plugin OutlookVim from www.vim.org to continue" & vbCrLf)
+ MsgBox ("OutlookVim: Please install the plugin OutlookVim from www.vim.org to continue" & vbCrLf)
Exit Sub
End If
vimResponse = Vim.Eval("(exists('g:outlook_servername')?1:0)")
If vimResponse = 0 Then
- MsgBox ("Please ensure g:outlook_servername is set in version 3.0 or above of OutlookVim" & vbCrLf)
+ MsgBox ("OutlookVim: Please ensure g:outlook_servername is set in version 3.0 or above of OutlookVim" & vbCrLf)
Exit Sub
End If
@@ -125,7 +138,7 @@ Sub Edit()
If vimServerName <> "" Then
vimResponse = Vim.Eval("match(serverlist(), '\<" & vimServerName & "\>')")
If vimResponse = -1 Then
- MsgBox ("There are no Vim instances running named: " & vbCrLf & vimServerName & vbCrLf & vbCrLf _
+ MsgBox ("OutlookVim: There are no Vim instances running named: " & vbCrLf & vimServerName & vbCrLf & vbCrLf _
& "Found these Vim instances: " & vbCrLf & Vim.Eval("serverlist()") & vbCrLf _
& "Please start a new Vim instance using " & vbCrLf & " 'gvim --servername " & vimServerName & "'" _
)
@@ -134,6 +147,15 @@ Sub Edit()
End If
Set fso = CreateObject("Scripting.FileSystemObject")
+ If Err.Number <> 0 Then
+ MsgBox ("OutlookVim: Could not create a file system object." & vbCrLf & _
+ "Please ensure the Windows Script Host utility has been installed and registered correctly." & vbCrLf & _
+ "You may want to follow the Upgrade links to correct the problem." & vbCrLf & _
+ "See http://msdn.microsoft.com/en-us/library/9bbdkx3k.aspx" _
+ )
+ Exit Sub
+ End If
+
Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
tname = fso.GetTempName
tname = Left(tname, (Len(tname) - 3)) & "outlook"
@@ -157,7 +179,7 @@ Sub Edit()
If Err.Number <> 0 Then
' Clear Err object fields.
' Err.Clear
- MsgBox ("Could not create email file [" & tfolder.ShortPath & "\\" & tname & "] " & vbCrLf & Err.Description)
+ MsgBox ("OutlookVim: Could not create email file [" & tfolder.ShortPath & "\\" & tname & "] " & vbCrLf & Err.Description)
tfile.Close
fso.DeleteFile (tfolder.ShortPath & "\\" & tname)
' Quit will close Outlook
@@ -183,7 +205,7 @@ Sub Edit()
If Err.Number <> 0 Then
' Clear Err object fields.
' Err.Clear
- MsgBox ("Could not create control file [" & tfolder.ShortPath & "\\" & tname & "] " & vbCrLf & Err.Description)
+ MsgBox ("OutlookVim: Could not create control file [" & tfolder.ShortPath & "\\" & tname & "] " & vbCrLf & Err.Description)
cfile.Close
fso.DeleteFile (tfolder.ShortPath & "\\" & tname)
fso.DeleteFile (tfolder.ShortPath & "\\" & tname & ".ctl")
@@ -235,4 +257,3 @@ Public Sub ExecCmd(cmdline$)
ReturnValue = CloseHandle(proc.hProcess)
End Sub
-
View
204 plugin/outlook.vim
@@ -1,8 +1,8 @@
" outlook.vim - Edit emails using Vim from Outlook
" ---------------------------------------------------------------
-" Version: 3.0
+" Version: 4.0
" Authors: David Fishburn <dfishburn dot vim at gmail dot com>
-" Last Modified: 2010 May 09
+" Last Modified: 2010 Jun 03
" Created: 2009 Jan 17
" Homepage: http://vim.sourceforge.net/script.php?script_id=???
" Help: :h outlook.txt
@@ -24,16 +24,29 @@ let g:outlook_save_cscript_output = 1
" View errors if updates fail
let g:outlook_view_cscript_error = 1
-" Default location for the outlookvim.js file.
-" This can be overridden in your vimrc via
-" g:outlook_javascript
-let s:outlook_javascript_default = expand('$VIM/vimfiles/plugin/outlookvim.js')
+" Whether to open the email in a new tab
+if !exists('g:outlook_use_tabs')
+ let g:outlook_use_tabs = 0
+endif
+
+" Whether to delete the buffer on save
+if !exists('g:outlook_nobdelete')
+ let g:outlook_nobdelete = 1
+endif
" autoindent - preserve indent level on new line
if !exists('g:outlook_noautoindent')
setlocal autoindent
endif
+" javascript - location of the outlookvim.js file
+if !exists('g:outlook_javascript')
+ " Default location for the outlookvim.js file.
+ " This can be overridden in your vimrc via
+ " g:outlook_javascript
+ let g:outlook_javascript = expand('$VIM/vimfiles/plugin/outlookvim.js')
+endif
+
" textwidth - automatically wrap at a column
if exists('g:outlook_textwidth')
let &textwidth = g:outlook_textwidth
@@ -60,11 +73,7 @@ endfunction
function! Outlook_ExecuteJS(filename)
let cmd = "let result = system('cscript \""
- if exists('g:outlook_javascript')
- let cmd = cmd . expand(g:outlook_javascript)
- else
- let cmd = cmd . s:outlook_javascript_default
- endif
+ let cmd = cmd . expand(g:outlook_javascript)
let cmd = cmd . '" "'.a:filename.'"'
let cmd = cmd . " ')"
exec cmd
@@ -73,22 +82,92 @@ function! Outlook_ExecuteJS(filename)
endfunction
function! Outlook_EditFile(filename, encoding)
- let cmd = ':e '.
- \ (a:encoding==''?'':'++enc='.a:encoding).
- \ ' '.a:filename.
- \ "\n"
- let g:outlook_last_cmd = cmd
if g:outlook_servername == '' || g:outlook_servername == v:servername
+ let remove_bufnr = -1
+ if !filereadable(a:filename)
+ call Outlook_ErrorMsg( 'Cannot find filename['.a:filename.']')
+ return
+ endif
+
+ if bufname('%') == '' && winnr('$') == 1 && &modified != 1
+ let remove_bufnr = bufnr('%')
+ let cmd = ':'.
+ \ 'new'.
+ \ (a:encoding==''?'':' ++enc='.a:encoding).
+ \ ' '.a:filename.
+ \ "\n"
+ else
+ let cmd = ':'.
+ \ (g:outlook_use_tabs == 1 ? 'tabnew' : 'e').' '.
+ \ (a:encoding==''?'':' ++enc='.a:encoding).
+ \ ' '.a:filename.
+ \ "\n"
+ endif
+ let g:outlook_last_cmd = cmd
exec cmd
+
+ if remove_bufnr != -1
+ exec remove_bufnr.'bw'
+ endif
else
if match( serverlist(), '\<'.g:outlook_servername.'\>' ) > -1
- call remote_send( g:outlook_servername, cmd )
+ call remote_send( g:outlook_servername, ":call Outlook_EditFile( '".a:filename."', '".a:encoding."' )\<CR>" )
+ " call remote_send( g:outlook_servername, cmd )
else
call Outlook_ErrorMsg( 'Please start a new Vim instance using "gvim --servername '.g:outlook_servername.'"')
endif
endif
endfunction
+function! Outlook_BufWritePost()
+ " autoread, prevents this message:
+ " "File has changed, do you want to Load"
+ if !exists('g:outlook_noautoread')
+ setlocal autoread
+ endif
+
+ let filename = expand("<afile>:p")
+ if filename == ''
+ let filename = expand("%:p")
+ echomsg 'filename was blank, using:'.filename
+ endif
+
+ let cmd = 'cscript "'. expand(g:outlook_javascript).
+ \ '" "'.
+ \ filename.
+ \ '" '.
+ \ g:outlook_nobdelete
+
+ let g:outlook_cscript_output = system(cmd)
+
+ if g:outlook_save_cscript_output == 1 && g:outlook_view_cscript_error
+ if g:outlook_cscript_output =~ '\(outlookvim:\|runtime error\)'
+ call Outlook_WarningMsg( substitute(g:outlook_cscript_output, '^.*\(outlookvim:.*\)', '\1', '') )
+ elseif g:outlook_nobdelete == 0
+ bdelete
+ endif
+ else
+ if g:outlook_nobdelete == 0
+ bdelete
+ endif
+ endif
+
+endfunction
+
+function! Outlook_BufUnload()
+ " This is necessary in case the buffer is not saved (:w), since
+ " the temporary files are (by default) deleted by outlookvim.js.
+ " But the javascript is only called if you save the buffer, if
+ " you choose to abandon your edits (:bw!), the temporary files are
+ " left over in the temporary directory.
+ if !exists('g:outlook_nodelete_unload') || g:outlook_nodelete_unload != 1
+ if expand('<afile>:e') == 'outlook'
+ call delete(expand('<afile>:p').'.ctl')
+ call delete(expand('<afile>:p'))
+ endif
+ endif
+endfunction
+
" Check is cscript.exe is already in the PATH
" Some path entries may end in a \ (c:\util\;), this must also be replaced
" or globpath fails to parse the directories
@@ -99,16 +178,14 @@ endif
if exists('g:outlook_javascript')
if !filereadable(expand(g:outlook_javascript))
- call Outlook_ErrorMsg("Cannot find javascript: " .
- \ expand(g:outlook_javascript) )
+ call Outlook_ErrorMsg("Cannot find javascript file[" .
+ \ expand(g:outlook_javascript) .
+ \ ']' )
finish
endif
else
- if !filereadable(expand(s:outlook_javascript_default))
- call Outlook_ErrorMsg("Cannot find javascript: " .
- \ expand(s:outlook_javascript_default) )
- finish
- endif
+ call Outlook_ErrorMsg("Cannot find the variable: g:outlook_javascript ")
+ finish
endif
" These autocommands only need to be created once,
@@ -117,76 +194,27 @@ if has('autocmd') && !exists("g:loaded_outlook")
" Save the current default register
let saveB = @"
- " Check to see if the BufWritePost autocommand already exists
- redir @"
- silent! exec 'augroup'
- redir END
-
- if @" !~? '\<outlook\>'
-
- " Create a group of the autocommands for outlook
- augroup outlook
- " Remove the previous group (if it existed)
- au!
-
- " Each time we enter this buffer, set the filetype to mail
- " which allows us to rely on each personal users mail preferences
- let cmd = 'autocmd BufEnter *.outlook setlocal filetype=mail '
- exec cmd
-
- " nested is required since we are issuing a bdelete, inside an autocmd
- " so we also need the required autocmd to fire for that command.
- " setlocal autoread, prevents this message:
- " "File has changed, do you want to Load"
-
- let cmd = 'autocmd BufWritePost *.outlook nested '
- if !exists('g:outlook_noautoread')
- let cmd = cmd . 'setlocal autoread | '
- endif
+ " Create a group of the autocommands for outlook
+ augroup outlook
+ " Remove the previous group (if it existed)
+ au!
- " silent! !start is to prevent the "Press any key to continue message"
- " This is behaviour I (dfishburn) prefer, when we write the file, the
- " buffer is deleted, and removed from the list of files in the Vim
- " session. outlookvim.js has already deleted the temporary file from the
- " filesystem.
- let cmd = cmd . "let g:outlook_cscript_output = system('cscript \""
- if exists('g:outlook_javascript')
- let cmd = cmd . expand(g:outlook_javascript)
- else
- let cmd = cmd . s:outlook_javascript_default
- endif
- let cmd = cmd . '" "'."'".'.expand("%").'."'".'"'
- let cmd = cmd . " ')"
+ " Each time we enter this buffer, set the filetype to mail
+ " which allows us to rely on each personal users mail preferences
+ autocmd BufEnter *.outlook setlocal filetype=mail
- if !exists('g:outlook_nobdelete')
- let cmd = cmd . "| bdelete "
- endif
- if g:outlook_save_cscript_output == 1 && g:outlook_view_cscript_error
- let cmd = cmd . "| if g:outlook_cscript_output =~ 'outlookvim:' | call Outlook_WarningMsg( substitute(g:outlook_cscript_output, '^.*\\(outlookvim:.*\\)', '\\1', '') ) | endif "
- endif
-
- exec cmd
+ " nested is required since we are issuing a bdelete, inside an autocmd
+ " so we also need the required autocmd to fire for that command.
+ " setlocal autoread, prevents this message:
+ " "File has changed, do you want to Load"
+ autocmd BufWritePost *.outlook nested call Outlook_BufWritePost()
- " This is necessary in case the buffer is not saved (:w), since
- " the temporary files are only deleted by outlookvim.js.
- " But the javascript is only called if you save the buffer, if
- " you choose to abandon your edits, the temporary files are left
- " over in the temporary directory.
- if !exists('g:outlook_nodelete_unload')
- let cmd = "autocmd BufUnload *.outlook " .
- \ "if expand('%:e') == 'outlook' " .
- \ "| call delete(expand('%:p').'.ctl') " .
- \ "| call delete(expand('%:p')) " .
- \ "| endif"
- exec cmd
- endif
+ autocmd BufUnload *.outlook call Outlook_BufUnload()
- augroup END
+ augroup END
- endif
-
" Don't re-run the script if already sourced
- let g:loaded_outlook = 1
+ let g:loaded_outlook = 4
let @"=saveB
endif
View
64 plugin/outlookvim.js
@@ -1,8 +1,8 @@
// outlookvim.js
//
// Author: David Fishburn
-// Version: 3.0
-// Last Modified: 2010 May 09
+// Version: 4.0
+// Last Modified: 2010 May 26
// Homepage: http://vim.sourceforge.net/script.php?script_id=???
//
// Purpose:
@@ -25,9 +25,8 @@
// http://msdn2.microsoft.com/en-us/library/yek4tbz0.aspx
//
var objArgs = WScript.Arguments;
-var emailfile = objArgs(0);
-function updateOutlook( emailfile )
+function updateOutlook( emailfile, persistfiles )
{
var ctlfile = emailfile + ".ctl";
var outlook = null;
@@ -43,6 +42,7 @@ function updateOutlook( emailfile )
var createNo = false;
var mixedMode = -2;
+ WScript.Echo("OutlookVim updateOutlook called with:" + persistfiles);
try
{
outlook = new ActiveXObject("Outlook.Application");
@@ -152,28 +152,48 @@ function updateOutlook( emailfile )
return;
}
- try
- {
- f = fs.GetFile(emailfile);
- f.Delete();
- }
- catch(err)
- {
- WScript.Echo("outlookvim: Failed to get and delete email file["+emailfile+"]:"+err.message);
- }
+ if( 1 == persistfiles )
+ {
+ WScript.Echo("OutlookVim persisting files:" + persistfiles);
+ }
+ else
+ {
+ WScript.Echo("OutlookVim deleting files:" + persistfiles);
+ try
+ {
+ f = fs.GetFile(emailfile);
+ f.Delete();
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Failed to get and delete email file["+emailfile+"]:"+err.message);
+ }
- try
- {
- fid = fs.GetFile(ctlfile);
- fid.Delete();
- }
- catch(err)
- {
- WScript.Echo("outlookvim: Failed to get and delete control file["+ctlfile+"]:"+err.message);
+ try
+ {
+ fid = fs.GetFile(ctlfile);
+ fid.Delete();
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Failed to get and delete control file["+ctlfile+"]:"+err.message);
+ }
}
WScript.Echo("Successfully updated Outlook, message ID:"+entryID);
}
-updateOutlook( emailfile );
+if( 0 == objArgs.length )
+{
+ WScript.Echo("Hello from OutlookVim!");
+} else {
+ var emailfile = objArgs(0);
+ var persistfiles = 0;
+ if( objArgs.length > 1 )
+ {
+ var persistfiles = objArgs(1);;
+ WScript.Echo("OutlookVim overriding to:" + persistfiles);
+ }
+ updateOutlook( emailfile, persistfiles );
+}

0 comments on commit 5d04936

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