2 " @Author: Thomas Link (micathom AT gmail com?subject=[vim])
3 " @Website: http://www.vim.org/account/profile.php?user_id=4037
4 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5 " @Created: 2007-09-03.
6 " @Last Change: 2007-11-15.
9 if &cp || exists("loaded_viki_viki")
12 let loaded_viki_viki = 1
19 " Prepare a buffer for use with viki.vim. Setup all buffer-local
21 " This also sets up the rx for the different viki name types.
22 " viki_viki#SetupBuffer(state, ?dontSetup='')
23 function! viki_viki#SetupBuffer(state, ...) "{{{3
27 " TLogDBG expand('%') .': '. (exists('b:vikiFamily') ? b:vikiFamily : 'default')
29 let dontSetup = a:0 > 0 ? a:1 : ""
32 if exists("b:vikiNoSimpleNames") && b:vikiNoSimpleNames
33 let b:vikiNameTypes = substitute(b:vikiNameTypes, '\Cs', '', 'g')
35 if exists("b:vikiDisableType") && b:vikiDisableType != ""
36 let b:vikiNameTypes = substitute(b:vikiNameTypes, '\C'. b:vikiDisableType, '', 'g')
39 call viki#SetBufferVar("vikiAnchorMarker")
40 call viki#SetBufferVar("vikiSpecialProtocols")
41 call viki#SetBufferVar("vikiSpecialProtocolsExceptions")
42 call viki#SetBufferVar("vikiMarkInexistent")
43 call viki#SetBufferVar("vikiTextstylesVer")
44 " call viki#SetBufferVar("vikiTextstylesVer")
45 call viki#SetBufferVar("vikiLowerCharacters")
46 call viki#SetBufferVar("vikiUpperCharacters")
47 call viki#SetBufferVar("vikiFeedbackMin")
50 call viki#SetBufferVar("vikiCommentStart",
51 \ "b:commentStart", "b:ECcommentOpen", "b:EnhCommentifyCommentOpen",
52 \ "*matchstr(&commentstring, '^\\zs.*\\ze%s')")
53 call viki#SetBufferVar("vikiCommentEnd",
54 \ "b:commentEnd", "b:ECcommentClose", "b:EnhCommentifyCommentClose",
55 \ "*matchstr(&commentstring, '%s\\zs.*\\ze$')")
56 elseif !exists('b:vikiCommentStart')
57 " This actually is an error.
59 echom "Viki: FTPlugin wasn't loaded. Viki requires :filetype plugin on"
61 let b:vikiCommentStart = '%'
62 let b:vikiCommentEnd = ''
65 let b:vikiSimpleNameQuoteChars = '^][:*/&?<>|\"'
67 let b:vikiSimpleNameQuoteBeg = '\[-'
68 let b:vikiSimpleNameQuoteEnd = '-\]'
69 let b:vikiQuotedSelfRef = "^". b:vikiSimpleNameQuoteBeg . b:vikiSimpleNameQuoteEnd ."$"
70 let b:vikiQuotedRef = "^". b:vikiSimpleNameQuoteBeg .'.\+'. b:vikiSimpleNameQuoteEnd ."$"
72 let b:vikiAnchorNameRx = '['. b:vikiLowerCharacters .']['.
73 \ b:vikiLowerCharacters . b:vikiUpperCharacters .'_0-9]*'
75 let interviki = '\<['. b:vikiUpperCharacters .']\+::'
77 " if viki#IsSupportedType("sSc") && !(dontSetup =~? "s")
78 if viki#IsSupportedType("s") && !(dontSetup =~? "s")
79 if viki#IsSupportedType("S") && !(dontSetup =~# "S")
80 let quotedVikiName = b:vikiSimpleNameQuoteBeg
81 \ .'['. b:vikiSimpleNameQuoteChars .']'
82 \ .'\{-}'. b:vikiSimpleNameQuoteEnd
84 let quotedVikiName = ""
86 if viki#IsSupportedType("c") && !(dontSetup =~# "c")
87 let simpleWikiName = viki#GetSimpleRx4SimpleWikiName()
88 if quotedVikiName != ""
89 let quotedVikiName = quotedVikiName .'\|'
92 let simpleWikiName = '\(\)'
94 let simpleHyperWords = ''
95 if v:version >= 700 && viki#IsSupportedType('w') && !(dontSetup =~# 'w')
96 let b:vikiHyperWordTable = {}
97 if viki#IsSupportedType('f') && !(dontSetup =~# 'f')
98 call viki#CollectFileWords(b:vikiHyperWordTable, simpleWikiName)
100 call viki#CollectHyperWords(b:vikiHyperWordTable)
101 let hyperWords = keys(b:vikiHyperWordTable)
102 if !empty(hyperWords)
103 let simpleHyperWords = join(map(hyperWords, '"\\<".tlib#rx#Escape(v:val)."\\>"'), '\|') .'\|'
104 let simpleHyperWords = substitute(simpleHyperWords, ' \+', '\\s\\+', 'g')
107 let b:vikiSimpleNameRx = '\C\(\('. interviki .'\)\?'.
108 \ '\('. simpleHyperWords . quotedVikiName . simpleWikiName .'\)\)'.
109 \ '\(#\('. b:vikiAnchorNameRx .'\)\>\)\?'
110 let b:vikiSimpleNameSimpleRx = '\C\(\<['.b:vikiUpperCharacters.']\+::\)\?'.
111 \ '\('. simpleHyperWords . quotedVikiName . simpleWikiName .'\)'.
112 \ '\(#'. b:vikiAnchorNameRx .'\>\)\?'
113 let b:vikiSimpleNameNameIdx = 1
114 let b:vikiSimpleNameDestIdx = 0
115 let b:vikiSimpleNameAnchorIdx = 6
116 let b:vikiSimpleNameCompound = 'let erx="'. escape(b:vikiSimpleNameRx, '\"')
117 \ .'" | let nameIdx='. b:vikiSimpleNameNameIdx
118 \ .' | let destIdx='. b:vikiSimpleNameDestIdx
119 \ .' | let anchorIdx='. b:vikiSimpleNameAnchorIdx
121 let b:vikiSimpleNameRx = noMatch
122 let b:vikiSimpleNameSimpleRx = noMatch
123 let b:vikiSimpleNameNameIdx = 0
124 let b:vikiSimpleNameDestIdx = 0
125 let b:vikiSimpleNameAnchorIdx = 0
128 if viki#IsSupportedType("u") && !(dontSetup =~# "u")
129 let urlChars = 'A-Za-z0-9.,:%?=&_~@$/|+-'
130 let b:vikiUrlRx = '\<\(\('.b:vikiSpecialProtocols.'\):['. urlChars .']\+\)'.
131 \ '\(#\([A-Za-z0-9]*\)\)\?'
132 let b:vikiUrlSimpleRx = '\<\('. b:vikiSpecialProtocols .'\):['. urlChars .']\+'.
133 \ '\(#[A-Za-z0-9]*\)\?'
134 let b:vikiUrlNameIdx = 0
135 let b:vikiUrlDestIdx = 1
136 let b:vikiUrlAnchorIdx = 4
137 let b:vikiUrlCompound = 'let erx="'. escape(b:vikiUrlRx, '\"')
138 \ .'" | let nameIdx='. b:vikiUrlNameIdx
139 \ .' | let destIdx='. b:vikiUrlDestIdx
140 \ .' | let anchorIdx='. b:vikiUrlAnchorIdx
142 let b:vikiUrlRx = noMatch
143 let b:vikiUrlSimpleRx = noMatch
144 let b:vikiUrlNameIdx = 0
145 let b:vikiUrlDestIdx = 0
146 let b:vikiUrlAnchorIdx = 0
149 if viki#IsSupportedType("x") && !(dontSetup =~# "x")
150 " let vikicmd = '['. b:vikiUpperCharacters .']\w*'
151 let vikicmd = '\(IMG\|Img\|INC\%[LUDE]\)\>'
152 let vikimacros = '\(img\|ref\)\>'
153 let b:vikiCmdRx = '\({'. vikimacros .'\|#'. vikicmd .'\)\(.\{-}\):\s*\(.\{-}\)\($\|}\)'
154 let b:vikiCmdSimpleRx = '\({'. vikimacros .'\|#'. vikicmd .'\).\{-}\($\|}\)'
155 let b:vikiCmdNameIdx = 1
156 let b:vikiCmdDestIdx = 5
157 let b:vikiCmdAnchorIdx = 4
158 let b:vikiCmdCompound = 'let erx="'. escape(b:vikiCmdRx, '\"')
159 \ .'" | let nameIdx='. b:vikiCmdNameIdx
160 \ .' | let destIdx='. b:vikiCmdDestIdx
161 \ .' | let anchorIdx='. b:vikiCmdAnchorIdx
163 let b:vikiCmdRx = noMatch
164 let b:vikiCmdSimpleRx = noMatch
165 let b:vikiCmdNameIdx = 0
166 let b:vikiCmdDestIdx = 0
167 let b:vikiCmdAnchorIdx = 0
170 if viki#IsSupportedType("e") && !(dontSetup =~# "e")
171 let b:vikiExtendedNameRx =
172 \ '\[\[\(\('.b:vikiSpecialProtocols.'\)://[^]]\+\|[^]#]\+\)\?'.
173 \ '\(#\([^]]*\)\)\?\]\(\[\([^]]\+\)\]\)\?\([!~*$\-]*\)\]'
174 " \ '\(#\('. b:vikiAnchorNameRx .'\)\)\?\]\(\[\([^]]\+\)\]\)\?[!~*\-]*\]'
175 let b:vikiExtendedNameSimpleRx =
176 \ '\[\[\('. b:vikiSpecialProtocols .'://[^]]\+\|[^]#]\+\)\?'.
177 \ '\(#[^]]*\)\?\]\(\[[^]]\+\]\)\?[!~*$\-]*\]'
178 " \ '\(#'. b:vikiAnchorNameRx .'\)\?\]\(\[[^]]\+\]\)\?[!~*\-]*\]'
179 let b:vikiExtendedNameNameIdx = 6
180 let b:vikiExtendedNameModIdx = 7
181 let b:vikiExtendedNameDestIdx = 1
182 let b:vikiExtendedNameAnchorIdx = 4
183 let b:vikiExtendedNameCompound = 'let erx="'. escape(b:vikiExtendedNameRx, '\"')
184 \ .'" | let nameIdx='. b:vikiExtendedNameNameIdx
185 \ .' | let destIdx='. b:vikiExtendedNameDestIdx
186 \ .' | let anchorIdx='. b:vikiExtendedNameAnchorIdx
188 let b:vikiExtendedNameRx = noMatch
189 let b:vikiExtendedNameSimpleRx = noMatch
190 let b:vikiExtendedNameNameIdx = 0
191 let b:vikiExtendedNameDestIdx = 0
192 let b:vikiExtendedNameAnchorIdx = 0
195 let b:vikiInexistentHighlight = "vikiInexistentLink"
199 call viki#SetAnchorMarks()
201 if g:vikiNameSuffix != ''
202 exec 'setlocal suffixesadd+='. g:vikiNameSuffix
204 if exists('b:vikiNameSuffix') && b:vikiNameSuffix != '' && b:vikiNameSuffix != g:vikiNameSuffix
205 exec 'setlocal suffixesadd+='. b:vikiNameSuffix
207 if exists('g:loaded_hookcursormoved') && g:loaded_hookcursormoved >= 3 && exists('b:vikiMarkInexistent') && b:vikiMarkInexistent
208 let b:hookcursormoved_syntaxleave = ['vikiLink', 'vikiExtendedLink', 'vikiURL', 'vikiOkLink', 'vikiInexistentLink']
209 for cond in g:vikiHCM
210 call hookcursormoved#Register(cond, function('viki#HookCheckPreviousPosition'))
217 " Define viki core syntax groups for hyperlinks
218 function! viki_viki#DefineMarkup(state) "{{{3
219 if viki#IsSupportedType("sS") && b:vikiSimpleNameSimpleRx != ""
220 exe "syntax match vikiLink /" . b:vikiSimpleNameSimpleRx . "/"
222 if viki#IsSupportedType("e") && b:vikiExtendedNameSimpleRx != ""
223 exe "syntax match vikiExtendedLink '" . b:vikiExtendedNameSimpleRx . "' skipnl"
225 if viki#IsSupportedType("u") && b:vikiUrlSimpleRx != ""
226 exe "syntax match vikiURL /" . b:vikiUrlSimpleRx . "/"
231 " Define the highlighting of the core syntax groups for hyperlinks
232 function! viki_viki#DefineHighlighting(state) "{{{3
233 exec 'hi vikiInexistentLink '. g:viki_highlight_inexistent_{&background}
234 exec 'hi vikiHyperLink '. g:viki_highlight_hyperlink_{&background}
236 if viki#IsSupportedType("sS")
237 hi def link vikiLink vikiHyperLink
238 hi def link vikiOkLink vikiHyperLink
239 hi def link vikiRevLink Normal
241 if viki#IsSupportedType("e")
242 hi def link vikiExtendedLink vikiHyperLink
243 hi def link vikiExtendedOkLink vikiHyperLink
244 hi def link vikiRevExtendedLink Normal
246 if viki#IsSupportedType("u")
247 hi def link vikiURL vikiHyperLink
252 " Define viki-related key maps
253 function! viki_viki#MapKeys(state) "{{{3
254 if exists('b:vikiDidMapKeys')
258 if exists('b:vikiMapFunctionalityMinor') && b:vikiMapFunctionalityMinor
259 let mf = b:vikiMapFunctionalityMinor
261 let mf = g:vikiMapFunctionalityMinor
263 elseif exists('b:vikiMapFunctionality') && b:vikiMapFunctionality
264 let mf = b:vikiMapFunctionality
266 let mf = g:vikiMapFunctionality
269 " if !hasmapto('viki#MaybeFollowLink')
270 if viki#MapFunctionality(mf, 'c')
271 nnoremap <buffer> <silent> <c-cr> :call viki#MaybeFollowLink(0,1)<cr>
272 inoremap <buffer> <silent> <c-cr> <c-o>:call viki#MaybeFollowLink(0,1)<cr>
273 " nnoremap <buffer> <silent> <LocalLeader><c-cr> :call viki#MaybeFollowLink(0,1,-1)<cr>
275 if viki#MapFunctionality(mf, 'f')
276 " nnoremap <buffer> <silent> <c-cr> :call viki#MaybeFollowLink(0,1)<cr>
277 " inoremap <buffer> <silent> <c-cr> <c-o>:call viki#MaybeFollowLink(0,1)<cr>
278 " nnoremap <buffer> <silent> <LocalLeader><c-cr> :call viki#MaybeFollowLink(0,1,-1)<cr>
279 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'f :call viki#MaybeFollowLink(0,1)<cr>'
280 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'s :call viki#MaybeFollowLink(0,1,-1)<cr>'
281 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'v :call viki#MaybeFollowLink(0,1,-2)<cr>'
282 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'1 :call viki#MaybeFollowLink(0,1,1)<cr>'
283 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'2 :call viki#MaybeFollowLink(0,1,2)<cr>'
284 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'3 :call viki#MaybeFollowLink(0,1,3)<cr>'
285 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'4 :call viki#MaybeFollowLink(0,1,4)<cr>'
286 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'t :call viki#MaybeFollowLink(0,1,"tab")<cr>'
288 if viki#MapFunctionality(mf, 'mf')
289 " && !hasmapto("viki#MaybeFollowLink")
290 nnoremap <buffer> <silent> <m-leftmouse> <leftmouse>:call viki#MaybeFollowLink(0,1)<cr>
291 inoremap <buffer> <silent> <m-leftmouse> <leftmouse><c-o>:call viki#MaybeFollowLink(0,1)<cr>
295 " if !hasmapto('VikiMarkInexistent')
296 if viki#MapFunctionality(mf, 'i')
297 exec 'noremap <buffer> <silent> '. g:vikiMapLeader .'d :call viki#MarkInexistentInElement("Document")<cr>'
298 exec 'noremap <buffer> <silent> '. g:vikiMapLeader .'p :call viki#MarkInexistentInElement("Paragraph")<cr>'
300 if viki#MapFunctionality(mf, 'I')
301 if g:vikiMapInexistent
303 let m = strlen(g:vikiMapKeys)
305 let k = g:vikiMapKeys[i]
306 call viki#MapMarkInexistent(k, "LineQuick")
310 let m = strlen(g:vikiMapQParaKeys)
312 let k = g:vikiMapQParaKeys[i]
313 call viki#MapMarkInexistent(k, "ParagraphVisible")
320 if viki#MapFunctionality(mf, 'e')
321 " && !hasmapto("viki#Edit")
322 exec 'noremap <buffer> '. g:vikiMapLeader .'e :VikiEdit '
325 if viki#MapFunctionality(mf, 'q') && exists("*VEnclose")
326 " && !hasmapto("VikiQuote")
327 exec 'vnoremap <buffer> <silent> '. g:vikiMapLeader .'q :VikiQuote<cr><esc>:call viki#MarkInexistentInElement("LineQuick")<cr>'
328 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'q viw:VikiQuote<cr><esc>:call viki#MarkInexistentInElement("LineQuick")<cr>'
329 exec 'inoremap <buffer> <silent> '. g:vikiMapLeader .'q <esc>viw:VikiQuote<cr>:call viki#MarkInexistentInElement("LineQuick")<cr>i'
332 if viki#MapFunctionality(mf, 'p')
333 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'<bs> :call viki#GoParent()<cr>'
334 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'<up> :call viki#GoParent()<cr>'
337 if viki#MapFunctionality(mf, 'b')
338 " && !hasmapto("VikiGoBack")
339 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'b :call viki#GoBack()<cr>'
340 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'<left> :call viki#GoBack()<cr>'
342 if viki#MapFunctionality(mf, 'mb')
343 nnoremap <buffer> <silent> <m-rightmouse> <leftmouse>:call viki#GoBack(0)<cr>
344 inoremap <buffer> <silent> <m-rightmouse> <leftmouse><c-o>:call viki#GoBack(0)<cr>
347 if viki#MapFunctionality(mf, 'F')
348 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'n :VikiFindNext<cr>'
349 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'N :VikiFindPrev<cr>'
350 exec 'nmap <buffer> <silent> '. g:vikiMapLeader .'F '. g:vikiMapLeader .'n'. g:vikiMapLeader .'f'
352 if viki#MapFunctionality(mf, 'tF')
353 nnoremap <buffer> <silent> <c-tab> :VikiFindNext<cr>
354 nnoremap <buffer> <silent> <c-s-tab> :VikiFindPrev<cr>
356 if viki#MapFunctionality(mf, 'Files')
357 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'u :VikiFilesUpdate<cr>'
358 exec 'nnoremap <buffer> <silent> '. g:vikiMapLeader .'U :VikiFilesUpdateAll<cr>'
359 exec 'nnoremap <buffer> '. g:vikiMapLeader .'x :VikiFilesExec '
360 exec 'nnoremap <buffer> '. g:vikiMapLeader .'X :VikiFilesExec! '
362 let b:vikiDidMapKeys = 1
366 " Initialize viki as minor mode (add-on to some buffer filetype)
367 "state ... no-op:0, minor:1, major:2
368 function! viki_viki#MinorMode(state) "{{{3
375 let state = a:state < 0 ? -a:state : a:state
376 let vf = viki#Family(1)
378 " s ... Simple viki name
379 " S ... Simple quoted viki name
380 " e ... Extended viki name
383 " call viki#SetBufferVar('vikiNameTypes', 'g:vikiNameTypes', "*'csSeui'")
384 call viki#SetBufferVar('vikiNameTypes')
385 call viki#DispatchOnFamily('SetupBuffer', vf, state)
386 call viki#DispatchOnFamily('DefineMarkup', vf, state)
387 call viki#DispatchOnFamily('DefineHighlighting', vf, state)
388 call viki#DispatchOnFamily('MapKeys', vf, state)
389 if !exists('b:vikiEnabled') || b:vikiEnabled < state
390 let b:vikiEnabled = state
392 " call viki#DispatchOnFamily('VikiDefineMarkup', vf, state)
393 " call viki#DispatchOnFamily('VikiDefineHighlighting', vf, state)
399 function! viki_viki#FindAnchor(anchor) "{{{3
401 if a:anchor == g:vikiDefNil || a:anchor == ''
404 let mode = matchstr(a:anchor, '^\(l\(ine\)\?\|rx\|vim\)\ze=')
405 if exists('*VikiAnchor_'. mode)
406 let arg = matchstr(a:anchor, '=\zs.\+$')
407 call VikiAnchor_{mode}(arg)
411 let anchorRx = viki#GetAnchorRx(a:anchor)
414 let found = search(anchorRx, 'Wc')
419 call search('\c\V'. escape(a:anchor, '\'), 'w')
423 exec g:vikiPostFindAnchor
427 " Complete missing information in the definition of an extended viki name
428 function! viki_viki#CompleteExtendedNameDef(def) "{{{3
430 exec viki#SplitDef(a:def)
431 if v_dest == g:vikiDefNil
432 if v_anchor == g:vikiDefNil
433 throw "Viki: Malformed extended viki name (no destination): ". string(a:def)
435 let v_dest = g:vikiSelfRef
437 elseif viki#IsInterViki(v_dest)
438 let useSuffix = viki#InterVikiSuffix(v_dest)
439 let v_dest = viki#InterVikiDest(v_dest)
441 if v_dest != g:vikiDefNil
442 let v_dest = viki#ExpandSimpleName('', v_dest, useSuffix)
446 if v_dest =~? '^[a-z]:' " an absolute dos path
447 elseif v_dest =~? '^\/' " an absolute unix path
448 elseif v_dest =~? '^'.b:vikiSpecialProtocols.':' " some protocol
449 elseif v_dest =~ '^\~' " user home
450 " let v_dest = $HOME . strpart(v_dest, 1)
451 let v_dest = fnamemodify(v_dest, ':p')
452 let v_dest = viki#CanonicFilename(v_dest)
453 else " a relative path
454 let v_dest = expand("%:p:h") .g:vikiDirSeparator. v_dest
455 let v_dest = viki#CanonicFilename(v_dest)
457 if v_dest != '' && v_dest != g:vikiSelfRef && !viki#IsSpecial(v_dest)
458 let mod = viki#ExtendedModifier(v_part)
459 if fnamemodify(v_dest, ':e') == '' && mod !~# '!'
460 let v_dest = viki#WithSuffix(v_dest)
464 if v_name == g:vikiDefNil
465 let v_name = fnamemodify(v_dest, ':t:r')
467 let v_type = v_type == g:vikiDefNil ? 'e' : v_type
468 " TLogVAR v_name, v_dest, v_anchor, v_part, v_type
469 return viki#MakeDef(v_name, v_dest, v_anchor, v_part, v_type)
473 " Complete missing information in the definition of a command viki name
474 function! viki_viki#CompleteCmdDef(def) "{{{3
476 exec viki#SplitDef(a:def)
477 " TLogVAR v_name, v_dest, v_anchor
479 let v_anchor = g:vikiDefNil
480 if v_name ==# "#IMG" || v_name =~# "{img"
481 let v_dest = viki#FindFileWithSuffix(v_dest, viki#GetSpecialFilesSuffixes())
483 elseif v_name ==# "#Img"
484 let id = matchstr(args, '\sid=\zs\w\+')
486 let v_dest = viki#FindFileWithSuffix(id, viki#GetSpecialFilesSuffixes())
488 elseif v_name =~ "^#INC"
489 " <+TBD+> Search path?
490 elseif v_name =~ '^{ref\>'
491 let v_anchor = v_dest
492 let v_name = g:vikiSelfRef
493 let v_dest = g:vikiSelfRef
494 " TLogVAR v_name, v_anchor, v_dest
496 " throw "Viki: Unknown command: ". v_name
497 let v_name = g:vikiDefNil
498 let v_dest = g:vikiDefNil
499 " let v_anchor = g:vikiDefNil
501 let v_type = v_type == g:vikiDefNil ? 'cmd' : v_type
502 let vdef = viki#MakeDef(v_name, v_dest, v_anchor, v_part, v_type)
508 " Complete missing information in the definition of a simple viki name
509 function! viki_viki#CompleteSimpleNameDef(def) "{{{3
511 exec viki#SplitDef(a:def)
512 if v_name == g:vikiDefNil
513 throw "Viki: Malformed simple viki name (no name): ". string(a:def)
516 if !(v_dest == g:vikiDefNil)
517 throw "Viki: Malformed simple viki name (destination=".v_dest."): ". string(a:def)
521 if viki#IsInterViki(v_name)
522 let i_name = viki#InterVikiName(v_name)
523 let useSuffix = viki#InterVikiSuffix(v_name)
524 let v_name = viki#InterVikiPart(v_name)
525 elseif viki#IsHyperWord(v_name)
526 let hword = viki#HyperWordValue(v_name)
528 let i_name = hword.interviki
529 let useSuffix = hword.suffix
530 let v_name = hword.name
538 let v_dest = expand("%:p:h")
539 let useSuffix = g:vikiDefSep
543 if viki#IsSupportedType("S")
545 if v_name =~ b:vikiQuotedSelfRef
546 let v_name = g:vikiSelfRef
547 elseif v_name =~ b:vikiQuotedRef
548 let v_name = matchstr(v_name, "^". b:vikiSimpleNameQuoteBeg .'\zs.\+\ze'. b:vikiSimpleNameQuoteEnd ."$")
550 elseif !viki#IsSupportedType("c")
551 throw "Viki: CamelCase names not allowed"
554 if v_name != g:vikiSelfRef
555 " TLogVAR v_dest, v_name, useSuffix
556 let rdest = viki#ExpandSimpleName(v_dest, v_name, useSuffix)
559 let rdest = g:vikiDefNil
564 let rdest = viki#InterVikiDest(rdest, i_name)
569 let v_type = v_type == g:vikiDefNil ? 's' : v_type
571 return viki#MakeDef(v_name, rdest, v_anchor, v_part, v_type)
576 " viki_viki#Find(flag, ?count=0, ?rx=nil)
577 function! viki_viki#Find(flag, ...) "{{{3
578 let rx = (a:0 >= 2 && a:2 != '') ? a:2 : viki#FindRx()
580 let i = a:0 >= 1 ? a:1 : 0
582 call search(rx, a:flag)
589 let &cpo = s:save_cpo