Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version 1.0: Documentation and GetLastestVimScripts support

  • Loading branch information...
commit 082d620124dde819918f3fa13fe72464dc3ce80f 0 parents
@dfishburn dfishburn authored committed
Showing with 876 additions and 0 deletions.
  1. +129 −0 README
  2. +203 −0 doc/WhatsMissing.txt
  3. +544 −0 plugin/WhatsMissing.vim
129 README
@@ -0,0 +1,129 @@
+This is a mirror of http://www.vim.org/scripts/script.php?script_id=1108
+
+This plugin contains functions/commands that will cycle through one
+buffer (the source) and compare the its contents against the contents of
+another buffer (the target).
+
+NOTE: This is not a poor man's 'diff', since the source and target must be
+ similar in appearance. See example below for a better understanding.
+
+Depending on the options specified and command chosen, it will open a split
+window (the result) and display either the entries that are:
+ - missing from the target buffer
+ or
+ - contained in both buffers
+
+The plugin has created a menu, Plugin->WhatMissing. There are two entries:
+ WhatsMissing
+ WhatsNotMissing
+
+These menu items are also available in visual mode. These menu items simply call the commands:
+ :WhatsMissing
+ :WhatsNotMissing
+
+The behavior of whatsmissing.vim are governed by several options. Options can be specified using the WMSetOption command. As mentioned above, the <Tab> button can be used for both option name and option value completion.
+
+You can check the value of a specific option by:
+ :WMGetOption option_name
+
+Here are the various options:
+ mode
+ - Values: "word" or "line".
+ - WhatsMissing will move through the source buffer one |word| at a
+ time, and checks this value against the target buffer. It will
+ also automatically escape the following characters:
+ '\\/.*$^~[]'
+ If the "line" mode is chosen the comparison between the source
+ and target buffer is performed a line at a time.
+
+ ignore_case
+ - Values: "0" or "1".
+ - The "default" for WhatsMissing is to use the |'ignorecase'| option
+ of the target buffer. Otherwise the user is allowed to override
+ it.
+
+ ignore_whitespace
+ - Values: "0" or "1".
+ - If in "line" mode, you can choose to ignore leading and trailing
+ whitespace for the comparison.
+
+
+Example
+------------
+Consider the case where you are maintaining a Vim syntax file. It has entries like this:
+*************
+syn keyword sqlFunction count sum avg min max debug_eng isnull
+syn keyword sqlFunction greater lesser argn string ymd todate
+syn keyword sqlFunction sp_addalias
+syn keyword sqlFunction sp_addauditrecord
+syn keyword sqlKeyword replicate rereceive resend reset
+syn keyword sqlKeyword resolve resource respect
+syn keyword sqlKeyword restrict result retain
+syn keyword sqlStatement allocate alter backup begin call case
+syn keyword sqlStatement checkpoint clear close commit configure connect
+syn keyword sqlStatement create deallocate declare delete describe
+syn keyword sqlType char long varchar text
+syn keyword sqlType bigint decimal double float int integer numeric
+*************
+
+In order to create the syntax file in the first place you had to find the above words from somewhere. In this case, I simply used grep against the source code to find various API method names, keywords, functions and so on.
+
+So in the end after running grep repeatedly and massaging the output, I end up with a file like this:
+**************
+abs
+absolute
+action
+activ
+expanded
+experience_estimate
+explanation
+explicit
+express
+exprtype
+remainder
+remote
+remove
+rename
+reorganize
+replicate
+rereceive
+resend
+reset
+value
+values
+varbinary
+varchar
+varexists
+**************
+
+At this point you want to update your Vim syntax file to include all the new method names, keywords, functions and so on that are missing from the existing syntax file.
+
+You cannot run Diff against this, since the lines are completely different, you need to compare the words.
+
+After running :WhatsMissing, you end up with a split buffer showing:
+***************
+(19 of 24) items missing from: syntax.vim
+----------
+abs
+absolute
+action
+activ
+expanded
+experience_estimate
+explanation
+explicit
+express
+exprtype
+remainder
+remote
+remove
+rename
+reorganize
+value
+values
+varbinary
+varexists
+----------
+WMOptions:
+mode=word ignore_case= ignore_whitespace=0
+***************
203 doc/WhatsMissing.txt
@@ -0,0 +1,203 @@
+*whatsmissing.txt* For Vim version 6.0.
+
+
+ VIM REFERENCE MANUAL
+ by
+ David Fishburn <fishburn@ianywhere.com>
+
+ Whatsmissing plugin (WhatsMissing.vim) Manual
+ WhatsMissing.vim version 1.00
+
+For instructions on installing this file, type
+ :help add-local-help
+|add-local-help| inside Vim.
+
+Homepage: http://vim.sourceforge.net/script.php?script_id=1108
+
+*WhatsMissing.vim* *whatsmissing* *whatsnotmissing*
+
+1. Overview |whatsmissing-overview|
+2. Installation |whatsmissing-install|
+3. Commands |whatsmissing-commands|
+4. Functions |whatsmissing-functions|
+5. Options |whatsmissing-options|
+
+{Vi does not have any of this}
+
+------------------------------------------------------------------------------
+What's New *whatsmissing-new*
+
+Version 1.00
+ - Initial Release
+
+------------------------------------------------------------------------------
+1. Overview *whatsmissing-overview*
+
+ This plugin contains functions/commands that will cycle through one
+ buffer (the source) and compare the its contents against the contents of
+ another buffer (the target).
+
+ Depending on the options specified and command chosen, it will open a split
+ window (the result) and display either the entries that are:
+ - missing from the target buffer
+ or
+ - contained in both buffers
+
+ The plugin has created a menu, Plugin->WhatMissing. There are two entries: >
+ WhatsMissing
+ WhatsNotMissing
+<
+ These menu items are also available in visual mode. These menu items simply
+ call the commands: >
+ :WhatsMissing
+ :WhatsNotMissing
+<
+ The commands will prompt the user for various options, see below in
+ the |whatsmissing-commands| section.
+
+
+------------------------------------------------------------------------------
+2. Installation *whatsmissing-install*
+
+ You can use this script as a plugin by copying it to your plugin directory.
+ See |add-global-plugin| for instructions.
+
+ 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)
+ :helptags $VIM/.vim/doc (Unix)
+
+
+------------------------------------------------------------------------------
+3. Commands *whatsmissing-commands*
+
+ If no parameters are supplied to the WhatsMissing and WhatsNotMissing
+ commands, you will be prompted for all parameters. This makes it very
+ easy to use the plugin. If you wish to call these commands from scripts
+ you can use the |call| syntax and supply all parameters (this will
+ suppress the prompting). >
+
+ WhatsMissing
+< Moves through the source buffer and checks to see if the entry exists
+ in the target buffer. If it does *not*, then it is considered missing
+ and the entry is added to the third buffer. >
+
+
+ WhatsNotMissing
+< Moves through the source buffer and checks to see if the entry exists
+ in the target buffer. If it *does *, then it is considered *not* missing
+ and the entry is added to the third buffer.
+
+>
+ WMSetOption
+< There are several options which can control the behaviour of the plugin.
+ WMSetOption supports command completion, so you can do the following: >
+ :WMSetOption <Tab>
+<
+ If you repeatedly press the <Tab> button, it will cycle through the
+ various options available. Once an option is available, if you add
+ and "=" sign, then you can also complete the values for the option: >
+ :WMSetOption mode=<Tab>
+<
+ Pressing <Tab> repeatedly will cycle through the values for this
+ option. >
+
+
+ WMGetOption
+< This command will display the value of the option supplied. Similar
+ to WMSetOption, this command also supports the <Tab> completion. >
+ :WMGetOption <Tab>
+ :WMGetOption mode
+<
+ This command will display the value of the option: >
+ :mode=word
+<
+
+
+
+------------------------------------------------------------------------------
+4. Functions *whatsmissing-functions*
+
+ There are four public functions available. >
+
+ WhatsMissing
+< - Optionally takes 3 parameters. >
+ - 1st parameter - target buffer
+< Can be any of the following:
+ - buffer #
+ - buffer name
+ - absolute / relative filename >
+ - 2nd parameter - Missing or NOT
+< Can be:
+ - 1 = Check for items missing from the target buffer
+ - 0 = Check for items NOT missing from the target buffer >
+ - 3rd parameter - No Prompt
+< Can be:
+ - 1 = Prompt for all options
+ - 0 = No prompting for options >
+< - Example calls: >
+ :%call WhatsMissing('syntax.sql', 1, 1)
+ :10,20call WhatsMissing('syntax.sql', 1, 0)
+
+
+ WhatsNotMissing
+< Takes the same parameters as WhatsMissing, but sets the 2nd
+ parameter to 0.
+
+>
+ WM_SetOption
+< - Takes 1 parameter of the form: >
+ option_name=option_value
+< - See |whatsmissing-options| for parameters.
+ - Example call: >
+ :call WM_SetOption('ignore_case=1')
+
+
+ WM_GetOption
+< - Takes 1 parameter of the form: >
+ option_name
+< - See |whatsmissing-options| for parameters.
+ - Example call, note the use of echo, not call: >
+ :echo WM_GetOption('ignore_case')
+<
+
+------------------------------------------------------------------------------
+5. Options *whatsmissing-options*
+
+ The behavior of WhatsMissing.vim are governed by several options. Options
+ can be specified using the WMSetOption command. As mentioned above, the
+ <Tab> button can be used for both option name and option value completion.
+
+ You can check the value of a specific option by: >
+ :WMGetOption option_name
+<
+ Here are the various options: >
+ mode
+< - Values: "word" or "line".
+ - WhatsMissing will move through the source buffer one |word| at a
+ time, and checks this value against the target buffer. It will
+ also automatically escape the following characters: >
+ '\\/.*$^~[]'
+< If the "line" mode is chosen the comparison between the source
+ and target buffer is performed a line at a time. >
+
+ ignore_case
+< - Values: "0" or "1".
+ - The "default" for WhatsMissing is to use the |'ignorecase'| option
+ of the target buffer. Otherwise the user is allowed to override
+ it. >
+
+ ignore_whitespace
+< - Values: "0" or "1".
+ - If in "line" mode, you can choose to ignore leading and trailing
+ whitespace for the comparison. >
+
+ debug
+< - Values: "0" or "1".
+ - Used internally to show search strings.
+
+
+------------------------------------------------------------------------------
+ vim:tw=78:fo=tcq2:ts=8:ft=help:norl:
544 plugin/WhatsMissing.vim
@@ -0,0 +1,544 @@
+" WhatMissing.vim - Shows what is missing between 2 buffers
+" ---------------------------------------------------------------
+" Version: 1.00
+" Authors: David Fishburn <fishburn@ianywhere.com>
+" Last Modified: Sun Oct 17 2004 10:25:19 PM
+" Homepage: http://vim.sourceforge.net/script.php?script_id=1108
+" GetLatestVimScripts: 1108 1 :AutoInstall: WhatsMissing.vim
+
+if exists('g:loaded_whatsmissing') || &cp
+ finish
+endif
+let g:loaded_whatsmissing = 100
+
+let s:wm_buffer_lines = 10
+let s:wm_matching_cnt = 0
+let s:wm_checked_cnt = 0
+let s:wm_org_bufnr = 0
+let s:wm_missing_bufnr = 0
+let s:wm_debug = 0
+let s:wm_find_bufnr = 0
+let s:wm_find_mode = 'word'
+let s:wm_find_filetype = ''
+let s:wm_filename = ''
+let s:wm_ignore_case = ''
+let s:wm_ignore_whitespace = ''
+let s:wm_unescaped_findstr = ''
+let s:wm_missing_buf_name = "WhatsMissing"
+let s:wm_options = "mode,ignore_case,ignore_whitespace,debug"
+let s:wm_modes = "word,line"
+
+function! WM_GetOption(option)
+ if s:wm_options !~? '\<'.a:option.'\>'
+ call s:WM_WarningMsg(
+ \ "Invalid option, choices are: " .
+ \ s:wm_options
+ \ )
+ return -1
+ endif
+
+ if a:option == 'mode'
+ let value = a:option.'='.s:wm_find_mode
+ elseif a:option == 'ignore_case'
+ let value = a:option.'='.
+ \ (s:wm_ignore_case ==# '' ? ' ' :
+ \ (s:wm_ignore_case ==# '\c' ? '1' : '0' ) )
+ elseif a:option == 'ignore_whitespace'
+ let value = a:option.'='.(s:wm_ignore_whitespace ==# '' ? '0' : '1' )
+ elseif a:option == 'debug'
+ let value = a:option.'='.s:wm_debug
+ else
+ let value = 'Unknown option: a:option'
+ endif
+
+ return value
+endfunction
+
+function! WM_SetOption(option)
+ let opt_name = matchstr(a:option, '^.\{-}\ze=' )
+ let opt_value = matchstr(a:option, '=\zs.\{-}\s*$' )
+
+ if s:wm_options !~? '\<'.opt_name.'\>'
+ call s:WM_WarningMsg(
+ \ "Invalid option, choices are: " .
+ \ s:wm_options
+ \ )
+ return -1
+ endif
+
+ if opt_name == 'mode'
+ if s:wm_modes !~? '\<'.opt_value.'\>'
+ call s:WM_WarningMsg(
+ \ "Invalid mode, choices are: " .
+ \ s:wm_modes
+ \ )
+ return -1
+ else
+ let s:wm_find_mode = opt_value
+ endif
+ elseif opt_name == 'ignore_case'
+ let s:wm_ignore_case = (opt_value ==# '1' ? '\c' : '\C' )
+ elseif opt_name == 'ignore_whitespace'
+ let s:wm_ignore_whitespace = (opt_value ==# '1' ? '\s*' : '' )
+ elseif opt_name == 'debug'
+ let s:wm_debug = opt_value
+ endif
+
+ return 1
+endfunction
+
+function! WhatsNotMissing(...) range
+ let compareTo = '""'
+ if a:0 > 0
+ let compareTo = a:1
+ endif
+
+ let askPrompt = '"1"'
+ if a:0 > 2
+ let askPrompt = a:3
+ endif
+
+ exec a:firstline.','.a:lastline.'WhatsMissing '.compareTo.' 0 '.askPrompt
+endfunction
+
+function! WhatsMissing(...) range
+ if &hidden == 0
+ call s:WM_WarningMsg(
+ \ "Cannot search other buffers with :set nohidden"
+ \ )
+ return -1
+ endif
+
+ let s:wm_org_bufnr = bufnr("%")
+ let rc = -1
+
+ let compareTo = ""
+ if a:0 > 0
+ let compareTo = a:1
+ endif
+
+ if strlen(substitute(compareTo, '"' ,'', 'g')) == 0
+ let response = 1
+ if has("browse")
+ let response = confirm("Do you want to use specify a file/buffer" .
+ \ " or browse for the file?",
+ \ "&File/Buffer\n&Browse",
+ \ 1
+ \ )
+ endif
+
+ if response == 1
+ let msg = "Enter one of the following:" .
+ \ "\n- buffer #" .
+ \ "\n- buffer name" .
+ \ "\n- filename (absolute|relative)\n"
+ let compareTo = inputdialog(msg)
+
+ if strlen(substitute(compareTo, '"' ,'', 'g')) == 0
+ call s:WM_WarningMsg(
+ \ "Invalid entry"
+ \ )
+ return -1
+ endif
+
+ elseif response == 2
+ if has("browse")
+ let compareTo = browse(0,"WhatsMissing Compare To", "", "")
+ endif
+ endif
+ endif
+
+ let compareTo = substitute(compareTo, '^\s*\(.\{-}\)\s*$', '\1', '')
+ if match(compareTo, '\D') == -1
+ let rc = s:WM_SetBufNbr( compareTo )
+ else
+ let rc = s:WM_SetFileName( compareTo )
+ endif
+
+ if rc == -1
+ return -1
+ endif
+
+ call s:WM_GetFindBufferOptions()
+
+ if a:0 > 1
+ let check_for_missing = a:2
+ else
+ let check_for_missing = 1
+ endif
+
+ let ask_prompt = 1
+ if a:0 > 2
+ if a:3 == '0'
+ let ask_prompt = 0
+ endif
+ endif
+
+ if ask_prompt == 1
+ call s:WM_PromptOptions()
+ endif
+
+ " Prevent the alternate buffer (<C-^>) from being set to this
+ " temporary file
+ let l:old_cpoptions = &cpoptions
+ setlocal cpo-=Aa
+ let saveReg = @"
+ " save previous search string
+ let saveSearch = @/
+ let saveZ = @z
+
+
+ " Disable all autocommands and events since we will be
+ " flipping between 3 buffers in rapid succession.
+ " If these events are not disabled, this can take
+ " a very long time
+ let l:old_eventignore = &eventignore
+ set eventignore+=BufNewFile,BufReadPre,BufRead,BufReadPost,BufReadCmd
+ set eventignore+=BufFilePre,BufFilePost,FileReadPre,FileReadPost
+ set eventignore+=FileReadCmd,FilterReadPre,FilterReadPost,FileType,Syntax
+ set eventignore+=StdinReadPre,StdinReadPost,BufWrite,BufWritePre
+ set eventignore+=BufWritePost,BufWriteCmd,FileWritePre,FileWritePost
+ set eventignore+=FileWriteCmd,FileAppendPre,FileAppendPost,FileAppendCmd
+ set eventignore+=FilterWritePre,FilterWritePost,FileChangedShell
+ set eventignore+=FileChangedRO,FocusGained,FocusLost,FuncUndefined
+ set eventignore+=CursorHold,BufEnter,BufLeave,BufWinEnter,BufWinLeave
+ set eventignore+=BufUnload,BufHidden,BufNew,BufAdd,BufCreate,BufDelete
+ set eventignore+=BufWipeout,WinEnter,WinLeave,CmdwinEnter,CmdwinLeave
+ set eventignore+=GUIEnter,VimEnter,VimLeavePre,VimLeave,EncodingChanged
+ set eventignore+=FileEncoding,RemoteReply,TermChanged,TermResponse,User
+
+ let title = '(!matching! of !checked!) items '
+ if check_for_missing == 1
+ let s:wm_missing_buf_name = "WhatsMissing"
+ let title = title . 'missing from: '
+ else
+ let s:wm_missing_buf_name = "WhatsNotMissing"
+ let title = title . 'found in both buffers: '
+ endif
+ let title = title . bufname(s:wm_find_bufnr) .
+ \ "\n----------"
+
+ call s:WM_AddToResultBuffer( title, "clear" )
+
+ " Put an extra newline at the start of the file
+ " It will be removed (undo) at the end of this, but
+ " this allows us to move through the file more consistently
+ " without having to deal with boundary cases
+ call cursor(a:firstline,1)
+ put! =''
+
+ let s:wm_matching_cnt = 0
+ let s:wm_checked_cnt = 0
+ let findstr = ''
+ while (1==1)
+ let org_curline = line(".")
+ let org_curcol = col(".")
+ let org_strlen = strlen(s:wm_unescaped_findstr)
+
+ let findstr = s:WM_GetNextFindStr(a:firstline)
+
+ " normal! w
+
+ if s:wm_find_mode == 'word'
+ " Check to see if we are on a character
+ " Since a user can specify a range, abort when we have passed it
+ " When hitting w (at the end of the file) the cursor
+ " will simply move to the end of the word, so we must
+ " check to ensure we have moved off of the previous word.
+ if (line(".") > (a:lastline+1)) ||
+ \ (line(".") == org_curline &&
+ \ col(".") < (org_curcol+org_strlen) )
+ " We have reached the end of the file
+ break
+ endif
+ elseif s:wm_find_mode == 'line'
+ " In line mode, just check if we are on the last
+ " line of the file
+ if (line(".") > (a:lastline+1)) ||
+ \ (org_curline == (a:lastline+1))
+ " We have reached the end of the file
+ break
+ endif
+ endif
+
+ if strlen(findstr) > 0
+ let s:wm_checked_cnt = s:wm_checked_cnt + 1
+
+ " Switch to the buffer we want to check this string for
+ silent! exec "buffer " . s:wm_find_bufnr
+
+ " ignore case
+ let srch_str = s:wm_ignore_case
+ if s:wm_find_mode == 'word'
+ if findstr =~? '^\w'
+ let srch_str = srch_str . '\<'
+ endif
+ let srch_str = srch_str . findstr
+ if findstr =~? '\w$'
+ let srch_str = srch_str . '\>'
+ endif
+ else
+ let srch_str = srch_str . '^' .
+ \ s:wm_ignore_whitespace .
+ \ findstr .
+ \ s:wm_ignore_whitespace .
+ \ '$'
+ endif
+
+ " Decho strftime("%X").' '.srch_str
+
+ " Mark the current line to return to
+ let find_curline = line(".")
+ let find_curcol = col(".")
+
+ if s:wm_debug == 1
+ call s:WM_AddToResultBuffer( 'Finding: [' .
+ \ srch_str . ']', "" )
+ endif
+ let found_line = search( srch_str, "w" )
+
+ if check_for_missing == 1 && found_line == 0
+ let s:wm_matching_cnt = s:wm_matching_cnt + 1
+ call s:WM_AddToResultBuffer( s:wm_unescaped_findstr, "" )
+ elseif check_for_missing == 0 && found_line > 0
+ let s:wm_matching_cnt = s:wm_matching_cnt + 1
+ call s:WM_AddToResultBuffer( s:wm_unescaped_findstr, "" )
+ endif
+
+ " Switch back to the original buffer
+ silent! exec "buffer " . s:wm_org_bufnr
+
+ " Return to previous location
+ " call cursor(org_curline, org_curcol)
+
+ endif
+
+ endwhile
+
+ silent! exec "buffer " . s:wm_org_bufnr
+ " Undo the put = we did above
+ undo
+
+ silent! exe 'noh'
+
+ " Restore previous cpoptions
+ let &cpoptions = l:old_cpoptions
+ let &eventignore = l:old_eventignore
+ let @" = saveReg
+ " restore previous search
+ let @/ = saveSearch
+ let @z = saveZ
+
+ call s:WM_SetSummary()
+ if s:wm_debug == 1
+ call s:WM_AddToResultBuffer( 'Start: ' .
+ \ a:firstline .
+ \ ' End: ' .
+ \ a:lastline,
+ \ "" )
+ endif
+
+ " call s:WM_AddToResultBuffer( "EI:".&eventignore, "" )
+endfunction
+
+function! s:WM_SetBufNbr( bufnr )
+ if a:bufnr == s:wm_org_bufnr
+ call s:WM_WarningMsg(
+ \ "Cannot choose the same buffer: " . a:bufnr
+ \ )
+ return -1
+ endif
+
+ if !bufexists(a:bufnr)
+ call s:WM_WarningMsg(
+ \ "Cannot find buffer #: " . a:bufnr
+ \ )
+ return -1
+ endif
+ let s:wm_find_bufnr = a:bufnr
+ return 1
+endfunction
+
+function! s:WM_SetFileName( filename )
+ if !bufexists(bufnr(a:filename))
+ if filereadable(a:filename)
+ " load the file into a new buffer
+ exec 'view ' . a:filename
+ if bufexists(bufnr(a:filename))
+ let s:wm_find_bufnr = bufnr(a:filename)
+ else
+ call s:WM_WarningMsg(
+ \ "Failed to load: " . a:filename
+ \ )
+ return -1
+ endif
+ else
+ call s:WM_WarningMsg(
+ \ "Cannot find: " . a:filename
+ \ )
+ return -1
+ endif
+ else
+ let s:wm_find_bufnr = bufnr(a:filename)
+ endif
+ let s:wm_filename = a:filename
+
+ return 1
+endfunction
+
+function! s:WM_AddToResultBuffer(output, do_clear)
+ " store current window number so we can return to it
+ let cur_winnr = winnr()
+
+ " do not use bufexists(s:wm_missing_buf_name), since it uses a fully
+ " qualified path name to search for the buffer, which in effect opens
+ " multiple buffers called "result" if the files that you are executing the
+ " commands from are in different directories.
+ let s:wm_missing_bufnr = bufnr(s:wm_missing_buf_name)
+
+ if s:wm_missing_bufnr == -1
+ " create the new buffer
+ silent exec 'belowright ' . s:wm_buffer_lines . 'new ' . s:wm_missing_buf_name
+ let s:wm_missing_bufnr = bufnr("%")
+ else
+ if bufwinnr(s:wm_missing_bufnr) == -1
+ " if the buffer is not visible, wipe it out and recreate it,
+ " this will position us in the new buffer
+ exec 'bwipeout! ' . s:wm_missing_bufnr
+ silent exec 'bot ' . s:wm_buffer_lines . 'new ' . s:wm_missing_buf_name
+ else
+ " if the buffer is visible, switch to it
+ exec bufwinnr(s:wm_missing_bufnr) . "wincmd w"
+ endif
+ endif
+ setlocal modified
+ " create a buffer mapping to clo this window
+ nnoremap <buffer> q :clo<cr>
+ " delete all the lines prior to this run
+ if a:do_clear == "clear"
+ %d
+ endif
+
+ if strlen(a:output) > 0
+ " add to end of buffer
+ silent! exec "$put =a:output"
+ endif
+
+ " since this is a small window, remove any blanks lines
+ silent %g/^\s*$/d
+ " fix the ^m characters, if any
+ silent execute "%s/\<c-m>\\+$//e"
+ " dont allow modifications, and do not wrap the text, since
+ " the data may be lined up for columns
+ setlocal nomodified
+ setlocal nowrap
+ " go to top of output
+ norm gg
+ " return to original window
+ exec cur_winnr."wincmd w"
+
+ return
+endfunction
+
+function! s:WM_GetNextFindStr(startline)
+ if s:wm_find_mode == 'word'
+ normal! wyiw
+ let s:wm_unescaped_findstr = @"
+ elseif s:wm_find_mode == 'line'
+ normal! j
+ let s:wm_unescaped_findstr = getline(".")
+ endif
+
+ " Escape various special characters
+ let findstr = escape(s:wm_unescaped_findstr, '\\/.*$^~[]' )
+ let findstr = substitute(
+ \ substitute(findstr, "\n$", "", ""),
+ \ "\n", '\\_[[:return:]]', "g")
+ return findstr
+endfunction
+
+function! s:WM_GetFindBufferOptions()
+ silent! exec "buffer " . s:wm_find_bufnr
+ let s:wm_find_filetype = &filetype
+ silent! exec "buffer " . s:wm_org_bufnr
+endfunction
+
+function! s:WM_PromptOptions()
+ " Mode
+ let response = (s:wm_find_mode == 'word' ? '1' : '2' )
+ let response = confirm("Choose compare method:",
+ \ "&Word\n&Line",
+ \ response
+ \ )
+ let s:wm_find_mode = (response == '1' ? 'word' : 'line' )
+
+ " Ignore Case
+ let response = (s:wm_ignore_case ==# '' ? '1' :
+ \ (s:wm_ignore_case ==# '\c' ? '3' : '2' ) )
+ let response = confirm("Do you want to ignore case?",
+ \ "&Default\n&Yes\n&No",
+ \ response
+ \ )
+ let s:wm_ignore_case = (response ==# '1' ? '' :
+ \ (response ==# '2' ? '\C' : '\c' ) )
+
+ " Ignore whitespace
+ let response = (s:wm_ignore_whitespace == '' ? '1' : '2' )
+ let response = confirm("Do you want to ignore whitespace?",
+ \ "&No\n&Yes",
+ \ response
+ \ )
+ let s:wm_ignore_whitespace = (response ==# '1' ? '' : '\s*' )
+endfunction
+
+function! s:WM_SetSummary()
+ let WMOptions = "----------\nWMOptions:\n" .
+ \ WM_GetOption('mode').' '.
+ \ WM_GetOption('ignore_case').' '.
+ \ WM_GetOption('ignore_whitespace')
+ call s:WM_AddToResultBuffer(WMOptions, '')
+
+ silent! exec "buffer " . s:wm_missing_bufnr
+ call cursor(1,1)
+ exec 's/!matching!/'.s:wm_matching_cnt.'/e'
+ exec 's/!checked!/'.s:wm_checked_cnt.'/e'
+ let &filetype = s:wm_find_filetype
+ setlocal nomodified
+ silent! exec "buffer " . s:wm_org_bufnr
+endfunction
+
+function! s:WM_CompleteOption(ArgLead, CmdLine, CursorPos)
+
+ if a:ArgLead =~? '^mode='
+ let cmd_options = a:ArgLead .
+ \ substitute(s:wm_modes, ',', "\n".a:ArgLead, 'g')
+ elseif a:ArgLead =~? '='
+ let cmd_options = a:ArgLead . "0\n" .
+ \ a:ArgLead . "1"
+ else
+ let cmd_options = substitute(s:wm_options, ',', "\n", 'g')
+ endif
+
+ return cmd_options
+endfunction
+
+function! s:WM_WarningMsg(msg)
+ echohl WarningMsg
+ echomsg "WM: " . a:msg
+ echohl None
+endfunction
+
+command! -range=% -nargs=* WhatsMissing <line1>,<line2>call WhatsMissing(<f-args>)
+command! -range=% -nargs=* WhatsNotMissing <line1>,<line2>call WhatsNotMissing(<f-args>)
+command! -nargs=1 -complete=custom,<SID>WM_CompleteOption WMGetOption :echo WM_GetOption(<q-args>)
+command! -nargs=1 -complete=custom,<SID>WM_CompleteOption WMSetOption :call WM_SetOption(<q-args>)
+
+if has("gui_running") && has("menu")
+ vnoremenu <script> Plugin.WhatsMissing.WhatsMissing :WhatsMissing<cr>
+ nnoremenu <script> Plugin.WhatsMissing.WhatsMissing :WhatsMissing<cr>
+ vnoremenu <script> Plugin.WhatsMissing.WhatsNotMissing :WhatsNotMissing<cr>
+ nnoremenu <script> Plugin.WhatsMissing.WhatsNotMissing :WhatsNotMissing<cr>
+endif
+
+
+" vim:fdm=marker:nowrap:ts=4:expandtab:
Please sign in to comment.
Something went wrong with that request. Please try again.