soywiki 0.0.9 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/soywiki.vim CHANGED
@@ -2,9 +2,8 @@
2
2
  " Maintainer: Daniel Choi <dhchoi@gmail.com>
3
3
  " License: MIT License (c) 2011 Daniel Choi
4
4
 
5
- " This regex matches namedspaced WikiWords, top-level WikiWords, and relative
6
- " .WikiWords in a namespace
7
- let s:wiki_link_pattern = '\C\<\([a-z][[:alnum:]_]\+\.\)\?[A-Z][a-z]\+[A-Z]\w*\>\|\.[A-Z][a-z]\+[A-Z]\w*\>'
5
+ " This regex matches namedspaced WikiWords and unqualified WikiWords
6
+ let s:wiki_link_pattern = '\C\<\([a-z][[:alnum:]_]\+\.\)\?[A-Z][a-z]\+[A-Z]\w*\>'
8
7
 
9
8
  let s:http_link_pattern = 'https\?:[^ >)\]]\+'
10
9
  let s:rename_links_command = 'soywiki-rename '
@@ -19,37 +18,68 @@ func! s:trimString(string)
19
18
  endfunc
20
19
 
21
20
  func! s:page_title()
22
- let title_line = getline(1)
23
- return s:trimString(title_line)
21
+ return substitute(bufname(''), '\/', '.', '')
22
+ endfunc
23
+
24
+ func! s:display_missing_namespace_error(num_segments)
25
+ if a:num_segments == 1
26
+ call s:error("Invalid wiki page: missing a namespace. Put it in a namespace subdirectory.")
27
+ elseif a:num_segments > 2
28
+ call s:error("Invalid wiki page: nested too deeply. Namespaces are limited to one level.")
29
+ endif
30
+ endfunc
31
+
32
+ func! s:display_invalid_wiki_word_error(word)
33
+ call s:error(a:word . " is not a valid WikiWord.")
34
+ endfunc
35
+
36
+ func! s:namespace_of_title(page_title)
37
+ let segments = split(a:page_title, '\.')
38
+ " page must have namespace
39
+ if len(segments) == 2
40
+ return get(segments, 0)
41
+ else
42
+ call s:display_missing_namespace_error(len(segments))
43
+ endif
24
44
  endfunc
25
45
 
26
46
  func! s:page_namespace()
27
- let segments = split(s:page_title(), '\.')
28
- return get(segments, 0)
47
+ return s:namespace_of_title(s:page_title())
29
48
  endfunc
30
49
 
31
50
  func! s:title_without_namespace(page_title)
32
- if len(split(a:page_title, '\.')) == 2
33
- return "." . get(split(a:page_title, '\.'), 1)
51
+ let segments = split(a:page_title, '\.')
52
+ if len(segments) == 2
53
+ return "." . get(segments, 1)
34
54
  else
35
- return a:page_title
55
+ call s:display_missing_namespace_error(len(segments))
36
56
  endif
37
57
  endfunc
38
58
 
39
- func! s:namespace_of_title(page_title)
40
- if len(split(a:page_title, '\.')) == 2
41
- return get(split(a:page_title, '\.'), 0)
59
+ " returns 1 or 0
60
+ func! s:has_namespace(link)
61
+ return (match(a:link, '\a\.') != -1)
62
+ endfunc
63
+
64
+ " adds current page's namespace to the link
65
+ func! s:infer_namespace(link)
66
+ if s:has_namespace(s:filename2pagetitle(a:link))
67
+ return s:filename2pagetitle(a:link)
42
68
  else
43
- ""
69
+ let x = s:page_namespace() . "." . a:link
70
+ return x
44
71
  endif
45
72
  endfunc
46
73
 
74
+ func! s:valid_wiki_word(link)
75
+ return (match(a:link, s:wiki_link_pattern) == 0)
76
+ endfunc
47
77
 
48
78
  func! s:is_wiki_page()
49
- return (match(getline(1), s:wiki_link_pattern) == 0)
79
+ return s:valid_wiki_word(s:page_title())
50
80
  endfunc
51
81
 
52
- func! s:page_title2file(page)
82
+ func! s:pagetitle2file(page)
53
83
  return substitute(a:page, '\.', '/', 'g')
54
84
  endfunc
55
85
 
@@ -59,46 +89,55 @@ endfunc
59
89
 
60
90
  func! s:list_pages()
61
91
  let s:search_for_link = ""
62
- call s:get_page_list()
63
- call s:page_list_window("CompletePageInSelectionWindow", "Select page: ")
92
+ call s:page_list_window(s:get_page_list(), "Select page: ")
64
93
  endfunc
65
94
 
95
+ " returns a fully namespaced link
66
96
  func! s:link_under_cursor()
67
97
  let link = expand("<cWORD>")
68
98
  " strip off non-letters at the end (e.g., a comma)
69
99
  let link = substitute(link, '[^[:alnum:]]*$', '', '')
70
- " see if we have a link relative to the namespace
71
- if (match(link, '^\.')) == 0
72
- " find the namespace from the page title
73
- let link = s:page_namespace() . link " this link already has a period at the beginning
100
+ if ! s:has_namespace(link)
101
+ let link = s:infer_namespace(link)
74
102
  endif
75
- let link = substitute(link, '^[^\.[:alnum:]]', '', '') " link may begin with period
76
- return link
103
+ if match(link, s:wiki_link_pattern) == -1
104
+ if match(link, s:http_link_pattern) != -1
105
+ call s:open_href()
106
+ endif
107
+ return ""
108
+ else
109
+ return link
110
+ end
77
111
  endfunc
78
112
 
79
113
  " follows a camel case link to a new page
80
114
  func! s:follow_link(split)
81
115
  let link = s:link_under_cursor()
82
- if match(link, s:wiki_link_pattern) == -1
116
+ if link == ""
83
117
  let link = s:find_next_wiki_link(0)
118
+ if link == ""
119
+ return ""
120
+ endif
84
121
  endif
85
122
  call s:load_page(link, a:split)
86
123
  endfunc
87
124
 
88
125
  func! s:follow_link_under_cursor(split)
89
126
  let link = s:link_under_cursor()
90
- if match(link, s:wiki_link_pattern) == -1
91
- echom "Not a wiki link"
92
- return
127
+ if link == ""
128
+ echom link . " is not a wiki link"
129
+ return ""
130
+ else
131
+ call s:load_page(link, a:split)
93
132
  endif
94
- call s:load_page(link, a:split)
95
133
  endfunc
96
134
 
97
135
  func! s:find_next_wiki_link(backward)
98
136
  let n = 0
99
- let result = search(s:wiki_link_pattern, 'w' . (a:backward == 1 ? 'b' : ''))
137
+ " don't wrap
138
+ let result = search(s:wiki_link_pattern, 'W' . (a:backward == 1 ? 'b' : ''))
100
139
  if (result == 0)
101
- return
140
+ return ""
102
141
  end
103
142
  return s:link_under_cursor()
104
143
  endfunc
@@ -107,16 +146,13 @@ func! s:load_page(page, split)
107
146
  if (s:is_wiki_page())
108
147
  write
109
148
  endif
110
-
111
- let file = s:page_title2file(a:page)
112
-
149
+ let file = s:pagetitle2file(a:page)
150
+ let title = s:filename2pagetitle(a:page)
113
151
  if (!filereadable(file))
114
152
  " create the file
115
153
  let namespace = s:namespace_of_title(a:page)
116
- if len(namespace) > 0
117
- call system("mkdir -p " . namespace)
118
- endif
119
- call writefile([a:page, '', ''], file)
154
+ call system("mkdir -p " . namespace)
155
+ call writefile([title, '', ''], file)
120
156
  endif
121
157
  if (a:split == 2)
122
158
  exec "vsplit ". file
@@ -127,70 +163,64 @@ func! s:load_page(page, split)
127
163
  wincmd p
128
164
  close
129
165
  endif
130
-
131
166
  if len(s:search_for_link) > 0
132
- let res = search(s:search_for_link, 'cw')
167
+ let res = search(s:search_for_link, 'cw')
133
168
  let s:search_for_link = ''
134
169
  endif
135
170
  endfunc
136
171
 
137
- func! s:load_most_recently_modified_page()
172
+ func! s:load_most_recently_modified_page(index)
138
173
  let pages = split(system(s:ls_command), "\n")
139
- let start_page = len(pages) > 0 ? get(pages, 0) : "HomePage"
174
+ let start_page = len(pages) > a:index ? get(pages, a:index) : "main.HomePage"
140
175
  call s:load_page(start_page, 0)
141
176
  endfunc
142
177
 
143
178
  func! s:delete_page()
144
179
  let file = bufname('%')
145
180
  let bufnr = bufnr('%')
146
- call delete(file)
147
- call system("git commit " . bufname('%') . " -m 'deletion'")
181
+
148
182
  " go to most recently saved
149
- let target = s:trimString(system(s:ls_command . " | head -1"))
150
- exec "e " . target
183
+ " this should be a function call
184
+ split
185
+ call s:load_most_recently_modified_page(1)
186
+ wincmd p
187
+
188
+ echo system("git rm " . file)
189
+ call system("git commit " . file . " -m 'deletion'")
151
190
  exec "bdelete " . bufnr
152
191
  redraw
153
192
  echom "Deleted " . file
154
- call s:load_most_recently_modified_page()
155
- endfunc
156
-
157
- func! s:prompt_for_wiki_word(prompt, default)
158
- let input = s:trimString(input(a:prompt, a:default))
159
- while match(input, s:wiki_link_pattern) == -1
160
- let input = s:trimString(input("Must be a WikiWord! Press CTRL-c to cancel. " . a:prompt , a:default))
161
- endwhile
162
- return input
163
193
  endfunc
164
194
 
165
- func! s:rename_page()
166
- let oldfile = bufname('%')
167
- let newfile = s:page_title2file( s:prompt_for_wiki_word("Rename oldfile: ", l:oldfile) )
168
- if (oldfile == newfile)
169
- echo "Canceled"
170
- return
171
- endif
195
+ func! s:rename_page(page_path_or_title)
196
+ let page_title = s:infer_namespace(a:page_path_or_title)
197
+ let newfile = s:pagetitle2file(page_title)
172
198
  if (filereadable(newfile))
173
199
  exe "echom '" . newfile . " already exists!'"
174
200
  return
175
201
  endif
176
- call system("git mv " . l:oldfile . " " . newfile)
177
- exec "e ". newfile
178
- " replace all existing inbound links
179
- " TODO replace this with a ruby script
180
- exec "! " . s:rename_links_command . oldfile . " " . newfile
181
- call system("git commit -am 'rename wiki page'")
182
- e!
183
- endfunc
184
-
185
- func! s:create_page()
186
- let title = s:prompt_for_wiki_word("New page title: ", "")
187
- let newfile = s:page_title2file(title)
188
- if (filereadable(newfile))
189
- exe "echom '" . newfile . " already exists!'"
190
- return
202
+ if s:valid_wiki_word(page_title)
203
+ let original_file = bufname('')
204
+ echo system("git mv " . original_file . " " . newfile)
205
+ exec "!" . s:rename_links_command . original_file . " " . newfile
206
+ call system("git commit -am 'rename wiki page and links'")
207
+ exec "e " . newfile
208
+ else
209
+ call s:display_invalid_wiki_word_error(page_title)
210
+ endif
211
+ endfunc
212
+
213
+ func! s:create_page(page_path)
214
+ let page_title = s:infer_namespace(a:page_path)
215
+ let page_path = s:pagetitle2file(page_title)
216
+ if (filereadable(page_path))
217
+ exe "echom '" . page_path . " already exists! Loaded.'"
218
+ endif
219
+ if s:valid_wiki_word(page_title)
220
+ call s:load_page(s:filename2pagetitle(page_path), 0)
221
+ else
222
+ call s:display_invalid_wiki_word_error(page_title)
191
223
  endif
192
- call writefile([s:filename2pagetitle(title), '', ''], newfile)
193
- exec "e ". newfile
194
224
  endfunc
195
225
 
196
226
  func! s:save_revision()
@@ -199,7 +229,6 @@ func! s:save_revision()
199
229
  endfunc
200
230
 
201
231
  func! s:show_revision_history(stat)
202
- " maybe later allow --stat
203
232
  if (a:stat)
204
233
  exec ":!git log --stat " . bufname('%')
205
234
  else
@@ -211,51 +240,55 @@ func! s:show_blame()
211
240
  exec ":! git blame --date=relative " . bufname('%')
212
241
  endfunc
213
242
 
214
-
215
243
  " -------------------------------------------------------------------------------
216
244
  " select Page
217
245
 
246
+ " This function both sets a script variable and returns the value.
218
247
  func! s:get_page_list()
248
+ " no file current in buffer
219
249
  if len(bufname('%')) == 0
220
- let s:page_list = split(system(s:ls_command), "\n")
250
+ return split(system(s:ls_command), "\n")
221
251
  else
222
- let s:page_list = split(system(s:ls_command . " | grep -vF '" . bufname('%') . "'" ), "\n")
252
+ return split(system(s:ls_command . " | grep -vF '" . s:page_title() . "'" ), "\n")
223
253
  endif
224
254
  endfunction
225
255
 
226
256
  func! s:pages_in_this_namespace(pages)
227
257
  let namespace = s:page_namespace()
228
- let pages = filter( a:pages, 'v:val =~ "^' . namespace . '"')
258
+ let pages = filter( a:pages, 'v:val =~ "^' . namespace . '\."')
229
259
  " strip leading namespace
230
260
  let pages = map( pages, "substitute(v:val, '^" . namespace . "\.', '', '') " )
231
261
  return pages
232
262
  endfunc
233
263
 
264
+ " When user press TAB after typing a few characters in the page selection
265
+ " window, if the user started typing a namespace (which starts with a
266
+ " lowercase letter), try to complete it. Otherwise take no action.
234
267
  func! s:reduce_matches()
235
268
  if (!exists("s:matching_pages"))
236
269
  return
237
270
  endif
238
271
  let fragment = expand("<cWORD>")
239
- let reduced_pages = filter( s:matching_pages, 'v:val =~ "^' . fragment . '"')
240
272
  " find the first namespace in the list
241
273
  let namespaced_matches = filter( s:matching_pages, 'v:val =~ "^' . fragment . '\."')
242
274
  if (len(namespaced_matches) == 0)
243
275
  return
244
- elseif match(fragment, '^[A-Z]') == -1 && match(fragment, '\.' == -1)
276
+ elseif match(fragment, '^[a-z]') == 0 && match(fragment, '\.' == -1)
245
277
  " we're beginning to type a namespace
246
278
  let namespace = get(split(get(namespaced_matches, 0), '\.'), 0)
247
279
  let namespace .= "."
248
- call feedkeys( "BcW". namespace. "\<C-x>\<C-u>\<C-p>" , "t")
280
+ call feedkeys( "BcW" . namespace . "\<C-x>\<C-u>\<C-p>" , "t")
249
281
  else
250
- " we're tabbing to auto complete the term, not find a namespace
251
282
  return
252
283
  endif
253
284
  endfunc
254
285
 
255
- function! s:page_list_window(complete_function, prompt)
286
+ function! s:page_list_window(page_match_list, prompt)
256
287
  " remember the original window
257
288
  let s:return_to_winnr = winnr()
289
+ let s:matching_pages = a:page_match_list
258
290
  topleft split page-list-buffer
291
+ setlocal completefunc=CompletePageTitle
259
292
  setlocal buftype=nofile
260
293
  setlocal noswapfile
261
294
  setlocal modifiable
@@ -264,7 +297,6 @@ function! s:page_list_window(complete_function, prompt)
264
297
  inoremap <buffer> <Tab> <Esc>:call <SID>reduce_matches()<cr>
265
298
  noremap <buffer> q <Esc>:close<cr>
266
299
  inoremap <buffer> <Esc> <Esc>:close<cr>
267
- exec "setlocal completefunc=" . a:complete_function
268
300
  " c-p clears the line
269
301
  call setline(1, a:prompt)
270
302
  normal $
@@ -272,46 +304,32 @@ function! s:page_list_window(complete_function, prompt)
272
304
  " call feedkeys("a", 't')
273
305
  endfunction
274
306
 
275
- function! CompletePage(findstart, base)
276
- let s:matching_pages = s:page_list[:]
277
- let possible_period = getline('.')[col('.') - 2]
278
- if (possible_period == '.')
279
- " filter to pages in this namespace
307
+ " This function assumes s:matching_pages has been set by the calling function
308
+ function! CompletePageTitle(findstart, base)
309
+ let fragment = expand("<cWORD>")
310
+ if !exists("s:matching_pages")
311
+ let s:matching_pages = s:get_page_list()
312
+ endif
313
+ if match(fragment, '^[A-Z]') == 0
314
+ " we have a WikiWord without a namespace; filter down to pages in pages in this
315
+ " namespace
280
316
  let s:matching_pages = s:pages_in_this_namespace(s:matching_pages)
281
317
  endif
282
318
  if a:findstart
283
319
  " locate the start of the word
284
- let line = getline('.')
285
- let start = col('.') - 1
286
- while start > 0 && line[start - 1] =~ '[[:alnum:]]'
287
- let start -= 1
288
- endwhile
289
- return start
290
- else
291
- let base = s:trimString(a:base)
292
- if (base == '')
293
- return s:matching_pages
320
+ " Assume we're in a page select window if there is a ': ' in the line.
321
+ " Admittedly, this is not work well in all cases
322
+ if bufname('') == 'page-list-buffer'
323
+ " by starting after prompt ': '
324
+ let start = match(getline('.'), ': ') + 2
294
325
  else
295
- let res = []
296
- for m in s:matching_pages
297
- if m =~ '\c' . base
298
- call add(res, m)
299
- endif
300
- endfor
301
- return res
302
- endif
303
- endif
304
- endfun
305
-
306
- function! CompletePageInSelectionWindow(findstart, base)
307
- let s:matching_pages = s:page_list[:]
308
- if a:findstart
309
- " locate the start of the word
310
- let line = getline('.')
311
- let start = col('.') - 1
312
- while start > 0 && line[start - 1] =~ '[[:alnum:]\.]'
313
- let start -= 1
314
- endwhile
326
+ " locate the start of the word
327
+ let line = getline('.')
328
+ let start = col('.') - 1
329
+ while start > 0 && line[start - 1] =~ '\a'
330
+ let start -= 1
331
+ endwhile
332
+ end
315
333
  return start
316
334
  else
317
335
  let base = s:trimString(a:base)
@@ -353,43 +371,17 @@ endfunction
353
371
 
354
372
  func! s:list_pages_linking_in()
355
373
  let s:pages_linking_in = split(system(s:find_pages_linking_in_command . s:page_title()), "\n")
356
- let s:search_for_link = s:title_without_namespace( s:page_title())
374
+ " cursor should jump to this string after the selected page is loaded:
375
+ let s:search_for_link = s:title_without_namespace(s:page_title())
357
376
  if len(s:pages_linking_in) == 1
358
377
  call s:load_page(get(s:pages_linking_in, 0), 0)
359
378
  elseif len(s:pages_linking_in) == 0
360
379
  echom "No pages link to " . s:page_title() . "!"
361
380
  else
362
- call s:page_list_window("CompletePagesLinkingIn_InSelectionWindow", "Pages that link to " . s:page_title() . ": ")
381
+ call s:page_list_window(s:pages_linking_in, "Pages that link to " . s:page_title() . ": ")
363
382
  endif
364
383
  endfunc
365
384
 
366
- function! CompletePagesLinkingIn_InSelectionWindow(findstart, base)
367
- " todo, this must be smarter, deal with different namespaces
368
- let s:matching_pages = s:pages_linking_in[:]
369
- if a:findstart
370
- " locate the start of the word
371
- let line = getline('.')
372
- let start = col('.') - 1
373
- while start > 0 && line[start - 1] =~ '[[:alnum:]\.]'
374
- let start -= 1
375
- endwhile
376
- return start
377
- else
378
- let base = s:trimString(a:base)
379
- if (base == '')
380
- return s:matching_pages
381
- else
382
- let res = []
383
- for m in s:matching_pages
384
- if m =~ '\c' . base
385
- call add(res, m)
386
- endif
387
- endfor
388
- return res
389
- endif
390
- endif
391
- endfun
392
-
393
385
  "------------------------------------------------------------------------
394
386
  " This appends the selected text (use visual-mode) to the page selected
395
387
  " in the page selection window.
@@ -418,6 +410,7 @@ func! s:extract(...) range
418
410
  " this one just deletes the line
419
411
  silent exe "norm! :".first.",".last."change\<CR>.\<CR>"
420
412
  endif
413
+ write!
421
414
  if bufnr(file) == -1 || bufwinnr(bufnr(file)) == -1
422
415
  if !filereadable(file)
423
416
  " create the file
@@ -444,7 +437,6 @@ func! s:extract(...) range
444
437
  write!
445
438
  endfunc
446
439
 
447
-
448
440
  func! s:error(str)
449
441
  echohl ErrorMsg
450
442
  echomsg a:str
@@ -490,40 +482,45 @@ func! s:expand(seamless, vertical)
490
482
  redraw
491
483
  echom "Expanded " . (a:seamless == 0 ? 'seamfully' : 'seamlessly') . "."
492
484
  endfunc
493
-
494
485
  "------------------------------------------------------------------------
495
-
496
486
  func! s:open_href()
497
487
  let line = search(s:http_link_pattern, 'cw')
498
- let href = matchstr(getline(line('.')), s:http_link_pattern)
488
+ let href = expand("<cWORD>")
499
489
  let command = g:SoyWiki#browser_command . " '" . href . "' "
500
490
  call system(command)
501
491
  echom command
502
492
  endfunc
503
-
504
493
  " --------------------------------------------------------------------------------
505
494
  " HELP
506
495
  func! s:show_help()
507
496
  let command = g:SoyWiki#browser_command . ' ' . shellescape('http://danielchoi.com/software/soywiki.html')
508
497
  call system(command)
509
498
  endfunc
510
-
511
-
512
499
  "------------------------------------------------------------------------
513
500
 
514
501
  func! s:global_mappings()
515
502
  noremap <leader>m :call <SID>list_pages()<CR>
516
503
  noremap <leader>M :call <SID>list_pages_linking_in()<CR>
517
504
  noremap <silent> <leader>o :call <SID>open_href()<cr>
518
-
505
+ nnoremap <silent> q :close<cr>
506
+ nnoremap <silent> <C-h> :close<cr>
507
+
508
+ " reflow text
509
+ nnoremap \ gwap
510
+ " insert a line
511
+ nmap <Leader>- o<Esc>k72i-<Esc><CR>
512
+ " insert date
513
+ map <Leader>d :r !date<CR>o
514
+
519
515
  command! -bar -nargs=1 -range -complete=file SWAppend :<line1>,<line2>call s:extract(<f-args>, 'append', 0)
520
516
  command! -bar -nargs=1 -range -complete=file SWInsert :<line1>,<line2>call s:extract(<f-args>, 'insert', 0)
521
517
  command! -bar -nargs=1 -range -complete=file SWLinkAppend :<line1>,<line2>call s:extract(<f-args>, 'append', 1)
522
518
  command! -bar -nargs=1 -range -complete=file SWLinkInsert :<line1>,<line2>call s:extract(<f-args>, 'insert', 1)
523
519
 
524
520
  command! -bar -nargs=1 SWSearch :call s:wiki_search(<f-args>)
521
+ " TODO a search confined to current namespace
525
522
 
526
- autocmd BufReadPost,BufNewFile,WinEnter,BufEnter,BufNew * call s:highlight_wikiwords()
523
+ autocmd BufReadPost,BufNewFile,WinEnter,BufEnter,BufNew,BufAdd * call s:highlight_wikiwords()
527
524
  autocmd BufEnter * call s:prep_buffer()
528
525
  endfunc
529
526
 
@@ -533,18 +530,15 @@ func! s:prep_buffer()
533
530
  if (s:is_wiki_page())
534
531
  set textwidth=72
535
532
  nnoremap <buffer> <cr> :call <SID>follow_link_under_cursor(0)<cr>
536
- nnoremap <buffer> - :call <SID>follow_link_under_cursor(1)<cr>
537
- nnoremap <buffer> \| :call <SID>follow_link_under_cursor(2)<cr>
533
+ nnoremap <buffer> <c-l> :call <SID>follow_link_under_cursor(1)<cr>
534
+ nnoremap <buffer> <c-n> :call <SID>follow_link_under_cursor(2)<cr>
538
535
  noremap <buffer> <leader>f :call <SID>follow_link(0)<CR>
539
- noremap <buffer> <c-n> :call <SID>find_next_wiki_link(0)<CR>
540
- noremap <buffer> <c-p> :call <SID>find_next_wiki_link(1)<CR>
536
+ noremap <buffer> <c-j> :call <SID>find_next_wiki_link(0)<CR>
537
+ noremap <buffer> <c-k> :call <SID>find_next_wiki_link(1)<CR>
541
538
 
542
- noremap <leader>c :call <SID>create_page()<CR>
543
- command! -buffer SWRename :call s:rename_page()
544
-
545
- noremap <buffer> <leader>r :call <SID>rename_page()<CR>
539
+ command! -bar -nargs=1 -range -complete=file SWCreate :call <SID>create_page(<f-args>)
540
+ command! -bar -nargs=1 -range -complete=file SWRenameTo :call <SID>rename_page(<f-args>)
546
541
  command! -buffer SWDelete :call s:delete_page()
547
- noremap <buffer> <leader># :call <SID>delete_page()<CR>
548
542
 
549
543
  command! -buffer SWLog :call s:show_revision_history(0)
550
544
  noremap <buffer> <leader>l :call <SID>show_revision_history(0)<CR>
@@ -561,7 +555,7 @@ func! s:prep_buffer()
561
555
  noremap <silent> <leader>? :call <SID>show_help()<cr>
562
556
 
563
557
  set nu
564
- setlocal completefunc=CompletePage
558
+ setlocal completefunc=CompletePageTitle
565
559
  augroup <buffer>
566
560
  au!
567
561
  autocmd BufWritePost <buffer> call s:save_revision()
@@ -571,8 +565,6 @@ endfunc
571
565
 
572
566
  func! s:highlight_wikiwords()
573
567
  if (s:is_wiki_page())
574
- " exe ":match Constant /". s:http_link_pattern . "/"
575
- "exe ":2match Comment /". s:wiki_link_pattern. "/"
576
568
  syntax clear
577
569
  exe "syn match Comment /". s:wiki_link_pattern. "/"
578
570
  exe "syn match Constant /". s:http_link_pattern . "/"
@@ -585,6 +577,8 @@ if (!isdirectory(".git"))
585
577
  call system("git init")
586
578
  echom "Created .git repository to store revisions"
587
579
  endif
580
+ " compress the repo
581
+ call system("git gc")
588
582
 
589
583
  if !exists("g:SoyWiki#browser_command")
590
584
  for cmd in ["gnome-open", "open"]
@@ -599,11 +593,10 @@ if !exists("g:SoyWiki#browser_command")
599
593
  endif
600
594
 
601
595
  if len(bufname("%")) == 0
602
- call s:load_most_recently_modified_page()
596
+ call s:load_most_recently_modified_page(0)
603
597
  else
604
598
  call s:load_page(bufname("%"), 0)
605
599
  endif
606
-
607
- call s:get_page_list()
608
600
  syntax enable
609
601
  let mapleader = ','
602
+ call s:highlight_wikiwords()
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 0
8
- - 9
9
- version: 0.0.9
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-09 00:00:00 -05:00
17
+ date: 2011-02-12 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -79,7 +79,6 @@ files:
79
79
  - website/lightbox2/js/prototype.js
80
80
  - website/lightbox2/js/scriptaculous.js
81
81
  - website/soywiki-template.html
82
- - website/soywiki.html
83
82
  - website/stylesheets-vmail/960.css
84
83
  - website/stylesheets-vmail/reset.css
85
84
  - website/stylesheets-vmail/site.css