lib/vmail.vim in vmail-2.6.5 vs lib/vmail.vim in vmail-2.6.6
- old
+ new
@@ -67,13 +67,13 @@
setlocal filetype=vmail
autocmd BufNewFile,BufRead *.txt setlocal modifiable
endfunction
" the message display buffer window
-function! s:create_message_window()
+function! s:create_message_window()
exec "split " . s:message_bufname
- setlocal modifiable
+ setlocal modifiable
setlocal buftype=nofile
let s:message_window_bufnr = bufnr('%')
call s:message_window_mappings()
close
endfunction
@@ -107,22 +107,22 @@
call setline(line('.'), newline)
setlocal nomodifiable
write
" this just clears the command line and prevents the screen from
" moving up when the next echo statement executes:
- " call feedkeys(":\<cr>")
+ " call feedkeys(":\<cr>")
" redraw
let command = s:show_message_command . s:uid
echom "Loading message ". s:uid .". Please wait..."
redrawstatus
let res = s:system_with_error_handling(command)
call s:focus_message_window()
set modifiable
1,$delete
put =res
" critical: don't call execute 'normal \<cr>'
- " call feedkeys("<cr>")
+ " call feedkeys("<cr>")
1delete
normal 1Gjk
set nomodifiable
if a:stay_in_message_list
call s:focus_list_window()
@@ -147,11 +147,11 @@
endfunction
function! s:show_previous_message()
let fullscreen = (bufwinnr(s:listbufnr) == -1) " we're in full screen message mode
if fullscreen
- 3split
+ 3split
exec 'b'. s:listbufnr
else
call s:focus_list_window()
end
normal k
@@ -192,14 +192,14 @@
normal 1G
setlocal nomodifiable
endfunction
function! s:focus_list_window()
- if bufwinnr(s:listbufnr) == winnr()
+ if bufwinnr(s:listbufnr) == winnr()
return
end
- let winnr = bufwinnr(s:listbufnr)
+ let winnr = bufwinnr(s:listbufnr)
if winnr == -1
" create window
split
exec "buffer" . s:listbufnr
else
@@ -245,11 +245,11 @@
write!
let num = len(lines)
call cursor(num, 0)
normal z.
redraw
- echom "You have " . num . " new message" . (num == 1 ? '' : 's') . "!"
+ echom "You have " . num . " new message" . (num == 1 ? '' : 's') . "!"
else
redraw
echom "No new messages"
endif
endfunction
@@ -292,13 +292,13 @@
" check if starred already
let action = " +FLAGS"
if (match(getline(a:firstline), flag_symbol) != -1)
let action = " -FLAGS"
endif
- let command = s:flag_command . shellescape(join(uid_set, ',')) . action . " Flagged"
+ let command = s:flag_command . shellescape(join(uid_set, ',')) . action . " Flagged"
if nummsgs == 1
- echom "Toggling flag on message"
+ echom "Toggling flag on message"
else
echom "Toggling flags on " . nummsgs . " messages"
endif
" toggle * on lines
let res = s:system_with_error_handling(command)
@@ -318,11 +318,11 @@
endwhile
setlocal nomodifiable
write
redraw
if nummsgs == 1
- echom "Toggled flag on message"
+ echom "Toggled flag on message"
else
echom "Toggled flags on " . nummsgs . " messages"
endif
endfunction
@@ -330,11 +330,11 @@
func! s:delete_messages(flag) range
let uid_set = s:collect_uids(a:firstline, a:lastline)
let nummsgs = len(uid_set)
let command = s:flag_command . shellescape(join(uid_set, ',')) . " +FLAGS " . a:flag
if nummsgs == 1
- echom "Deleting message"
+ echom "Deleting message"
else
echom "Deleting " . nummsgs . " messages"
endif
let res = s:system_with_error_handling(command)
setlocal modifiable
@@ -369,11 +369,11 @@
if append_file == ''
echom "Canceled"
return
endif
let s:append_file = append_file
- let command = s:append_to_file_command . shellescape(join(uid_set, ',')) . ' ' . s:append_file
+ let command = s:append_to_file_command . shellescape(join(uid_set, ',')) . ' ' . s:append_file
echo "Appending " . nummsgs . " message" . (nummsgs == 1 ? '' : 's') . " to " . s:append_file . ". Please wait..."
let res = s:system_with_error_handling(command)
echo res
redraw
endfunc
@@ -395,39 +395,39 @@
setlocal modifiable
resize 1
let prompt = "select mailbox to " . (a:copy ? 'copy' : 'move') . " to: "
call setline(1, prompt)
normal $
- inoremap <silent> <buffer> <cr> <Esc>:call <SID>complete_move_to_mailbox()<CR>
+ inoremap <silent> <buffer> <cr> <Esc>:call <SID>complete_move_to_mailbox()<CR>
inoremap <silent> <buffer> <esc> <Esc>:q<cr>
setlocal completefunc=CompleteMoveMailbox
" c-p clears the line
- let s:firstline = a:firstline
+ let s:firstline = a:firstline
let s:lastline = a:lastline
call feedkeys("a\<c-x>\<c-u>\<c-p>", 't')
" save these in script scope to delete the lines when move completes
endfunction
function! s:complete_move_to_mailbox()
let mailbox = get(split(getline(line('.')), ": "), 1)
close
- if s:copy_to_mailbox
+ if s:copy_to_mailbox
let command = s:copy_to_command . s:uid_set . ' ' . shellescape(mailbox)
else
let command = s:move_to_command . s:uid_set . ' ' . shellescape(mailbox)
endif
redraw
- echo "Moving uids ". s:uid_set . " to mailbox " . mailbox
+ echo "Moving uids ". s:uid_set . " to mailbox " . mailbox
let res = s:system_with_error_handling(command)
setlocal modifiable
if !s:copy_to_mailbox
exec "silent " . s:firstline . "," . s:lastline . "delete"
end
setlocal nomodifiable
write
redraw
- echo s:nummsgs . " message" . (s:nummsgs == 1 ? '' : 's') . ' ' . (s:copy_to_mailbox ? 'copied' : 'moved') . ' to ' . mailbox
+ echo s:nummsgs . " message" . (s:nummsgs == 1 ? '' : 's') . ' ' . (s:copy_to_mailbox ? 'copied' : 'moved') . ' to ' . mailbox
endfunction
function! CompleteMoveMailbox(findstart, base)
if !exists("s:mailboxes")
call s:get_mailbox_list()
@@ -472,11 +472,11 @@
leftabove split MailboxSelect
setlocal buftype=nofile
setlocal noswapfile
setlocal modifiable
resize 1
- inoremap <silent> <buffer> <cr> <Esc>:call <SID>select_mailbox()<CR>
+ inoremap <silent> <buffer> <cr> <Esc>:call <SID>select_mailbox()<CR>
inoremap <silent> <buffer> <esc> <Esc>:q<cr>
setlocal completefunc=CompleteMailbox
" c-p clears the line
call setline(1, "select mailbox to switch to: ")
normal $
@@ -524,23 +524,23 @@
call s:system_with_error_handling(command)
redraw
" reset window width now
call s:system_with_error_handling(s:set_window_width_command . winwidth(1))
" now get latest 100 messages
- call s:focus_list_window()
+ call s:focus_list_window()
setlocal modifiable
let command = s:search_command . shellescape("all")
echo "Loading messages..."
let res = s:system_with_error_handling(command)
silent 1,$delete
silent! put! =res
- execute "normal Gdd\<c-y>"
+ execute "normal Gdd\<c-y>"
setlocal nomodifiable
write
normal gg
redraw
- echom "Current mailbox: ". s:mailbox
+ echom "Current mailbox: ". s:mailbox
endfunction
func! s:search_query()
if !exists("s:query")
let s:query = ""
@@ -557,41 +557,41 @@
" close message window if open
call s:focus_message_window()
close
let command = s:search_command . shellescape(s:query)
redraw
- call s:focus_list_window()
+ call s:focus_list_window()
setlocal modifiable
echo "Running query on " . s:mailbox . ": " . s:query . ". Please wait..."
let res = s:system_with_error_handling(command)
silent! 1,$delete
silent! put! =res
- execute "silent normal Gdd\<c-y>"
+ execute "silent normal Gdd\<c-y>"
setlocal nomodifiable
write
normal gg
endfunction
function! s:more_messages()
- let command = s:more_messages_command
+ let command = s:more_messages_command
echo "Fetching more messages. Please wait..."
let res = s:system_with_error_handling(command)
setlocal modifiable
let lines = split(res, "\n")
call append(line('$'), lines)
- " execute "normal Gdd\<c-y>"
+ " execute "normal Gdd\<c-y>"
setlocal nomodifiable
normal j
redraw
echo "Done"
endfunction
-" --------------------------------------------------------------------------------
+" --------------------------------------------------------------------------------
" compose reply, compose, forward, save draft
function! s:compose_reply(all)
- let command = s:reply_template_command
+ let command = s:reply_template_command
if a:all
let command = command . ' 1'
endif
call s:open_compose_window(command)
" cursor after headers
@@ -600,18 +600,18 @@
function! s:compose_message()
let command = s:new_message_template_command
call s:open_compose_window(command)
" position cursor after to:
-" call search("^to:")
+" call search("^to:")
" normal A
endfunction
function! s:compose_forward()
- let command = s:forward_template_command
+ let command = s:forward_template_command
call s:open_compose_window(command)
-" call search("^to:")
+" call search("^to:")
" normal A
endfunction
func! s:open_compose_window(command)
redraw
@@ -635,11 +635,11 @@
func! s:turn_into_compose_window()
call s:compose_window_mappings()
setlocal completefunc=CompleteContact
endfunc
-" contacts.txt file should be generated.
+" contacts.txt file should be generated.
" grep works well, does partial matches
function! CompleteContact(findstart, base)
if !exists("s:mailboxes")
call s:get_mailbox_list()
endif
@@ -650,11 +650,11 @@
while start > 0 && line[start - 1] =~ '\a'
let start -= 1
endwhile
return start
else
- " find contacts
+ " find contacts
" model regex: match at beginning of line, or inside < > wrapping
" email addr
" '\(^ho\|<ho\)'
" let regex = shellescape('\(^' . a:base . '\|<' . a:base . '\)')
let regex = shellescape(a:base)
@@ -681,15 +681,15 @@
endif
echom substitute(res, '[\s\r\n]\+$', '', '')
redraw
endfunction
-" --------------------------------------------------------------------------------
+" --------------------------------------------------------------------------------
" call from inside message window with <Leader>h
func! s:open_html_part()
- let command = s:open_html_part_command
+ let command = s:open_html_part_command
" the command saves the html part to a local file
let outfile = s:system_with_error_handling(command)
" todo: allow user to change open in browser command?
exec "!" . s:browser_command . ' ' . outfile
endfunc
@@ -710,11 +710,11 @@
let attach = "attach: " . a:file
put =attach
endfunc
-" --------------------------------------------------------------------------------
+" --------------------------------------------------------------------------------
func! s:toggle_maximize_window()
if winnr('$') > 1
only
" normal z.
@@ -741,11 +741,11 @@
call s:system_with_error_handling(command)
let n += 1
endif
let lnum += 1
endwhile
- echom 'opened '.n.' links'
+ echom 'opened '.n.' links'
return
end
let line = search(pattern, 'cw')
if line && a:all
while line
@@ -753,29 +753,29 @@
let command = s:browser_command ." ".shellescape(href)." &"
call s:system_with_error_handling(command)
let n += 1
let line = search('https\?:', 'W')
endwhile
- echom 'opened '.n.' links'
+ echom 'opened '.n.' links'
else
let href = matchstr(getline(line('.')), pattern)
let command = s:browser_command ." ".shellescape(href)." &"
call s:system_with_error_handling(command)
echom 'opened '.href
endif
endfunc
-" --------------------------------------------------------------------------------
+" --------------------------------------------------------------------------------
" HELP
func! s:show_help()
let command = s:browser_command . ' ' . shellescape('http://danielchoi.com/software/vmail.html')
call s:system_with_error_handling(command)
"let helpfile = s:system_with_error_handling(s:show_help_command)
"exec "split " . helpfile
endfunc
-" --------------------------------------------------------------------------------
+" --------------------------------------------------------------------------------
" CONVENIENCE FUNCS
function! s:collect_uids(startline, endline)
let uid_set = []
let lnum = a:startline
@@ -785,11 +785,11 @@
let lnum += 1
endwhile
return uid_set
endfunc
-" --------------------------------------------------------------------------------
+" --------------------------------------------------------------------------------
" MAPPINGS
func! s:message_window_mappings()
if !hasmapto('<Plug>VmailMessageWindow_FocusListWindow')
nmap <buffer> <CR> <Plug>VmailMessageWindow_FocusListWindow
@@ -1069,12 +1069,12 @@
func! s:global_mappings()
" NOTE send_message is a global mapping, so user can load a saved
" message from a file and send it
nnoremap <silent> <leader>vs :call <SID>send_message()<CR>
- noremap <silent> <leader>o :call <SID>open_href(0)<cr>
- noremap <silent> <leader>O :call <SID>open_href(1)<cr>
+ noremap <silent> <leader>o :call <SID>open_href(0)<cr>
+ noremap <silent> <leader>O :call <SID>open_href(1)<cr>
noremap <silent> <leader>? :call <SID>show_help()<cr>
noremap <silent> <leader>qq :qal!<cr>
endfunc
func! s:set_list_colors()
@@ -1085,10 +1085,17 @@
syn match vmailSizeCol /|\s\+\(< 1k\|\d*\(b\|k\|M\|G\)\)\s\+|/ contains=vmailSeperator contained
syn match vmailFirstCol /^.\{-}|/ nextgroup=vmailDateCol
syn match vmailFirstColAnswered /An/ contained containedin=vmailFirstCol
syn match vmailFirstColForward /\$F/ contained containedin=vmailFirstCol
syn match vmailFirstColNotJunk /No/ contained containedin=vmailFirstCol
- syn match vmailDateCol /\s\+... \d\d \(\(\d\d:\d\d..\)\|\(\d\{4}\)\)\s\+|/ nextgroup=vmailFromCol contains=vmailSeperator
+
+ " Examples matched by vmailDateCol:
+ " | Dec 15 11:59pm |
+ " | Dec 15 2008 |
+ " | 15.12 23:59 |
+ " | 15.12 2008 |
+ syn match vmailDateCol /\s\+\(... \d\d \(\(\d\d:\d\d..\)\|\(\d\{4}\)\)\)\|\(\d\d\.\d\d \(\(\d\d:\d\d\)\|\(\d\{4}\)\)\)\s\+|/ nextgroup=vmailFromCol contains=vmailSeperator
+
syn match vmailFromCol /\s.\{-}|\@=/ contained nextgroup=vmailFromSeperator
syn match vmailFromColEmail /<[^ ]*/ contained containedin=vmailFromCol
syn match vmailFromSeperator /|/ contained nextgroup=vmailSubject
syn match vmailSubject /.*\s\+/ contained contains=vmailSizeCol
syn match vmailSubjectRe /\cre:\|fwd\?:/ contained containedin=vmailSubject