vmail 2.6.5 → 2.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -71,10 +71,21 @@ The `.vmailrc` file should look something like this. Substitute your own values.
71
71
  username: dhchoi@gmail.com
72
72
  password: password
73
73
  name: Daniel Choi
74
+ date_format: wordy
74
75
  signature: |
75
76
  --
76
77
  Sent from Vmail. http://danielchoi.com/software/vmail.html
77
78
 
79
+
80
+ ### Configuration file - optional parameters
81
+ `date_format: wordy | numerical`
82
+
83
+ `wordy`: The email arrival date is shown as for example 'Dec 15 11:59pm' or 'Dec 15 2008'.
84
+ This is the default value of the date_format parameter.
85
+
86
+ `numerical`: The email arrival date is shown as for example '15.12 23:59' or '15.12 2008'.
87
+ It saves two characters - useful on devices with really small displays.
88
+
78
89
  This file should be formatted in [YAML syntax][1].
79
90
 
80
91
  [1]:http://www.yaml.org/spec/1.2/spec.html
@@ -93,6 +104,7 @@ If you want to use a shell script to print the signature, use the
93
104
  username: dhchoi@gmail.com
94
105
  password: password
95
106
  name: Daniel Choi
107
+ date_format: wordy
96
108
  signature_script: /home/choi/bin/vmail_signature.sh
97
109
 
98
110
  You can add a `vim_opts:` key-value pair to run arbitrary Vim commands when Vmail starts up.
data/lib/vmail.vim CHANGED
@@ -69,9 +69,9 @@ function! s:create_list_window()
69
69
  endfunction
70
70
 
71
71
  " the message display buffer window
72
- function! s:create_message_window()
72
+ function! s:create_message_window()
73
73
  exec "split " . s:message_bufname
74
- setlocal modifiable
74
+ setlocal modifiable
75
75
  setlocal buftype=nofile
76
76
  let s:message_window_bufnr = bufnr('%')
77
77
  call s:message_window_mappings()
@@ -109,7 +109,7 @@ function! s:show_message(stay_in_message_list)
109
109
  write
110
110
  " this just clears the command line and prevents the screen from
111
111
  " moving up when the next echo statement executes:
112
- " call feedkeys(":\<cr>")
112
+ " call feedkeys(":\<cr>")
113
113
  " redraw
114
114
  let command = s:show_message_command . s:uid
115
115
  echom "Loading message ". s:uid .". Please wait..."
@@ -120,7 +120,7 @@ function! s:show_message(stay_in_message_list)
120
120
  1,$delete
121
121
  put =res
122
122
  " critical: don't call execute 'normal \<cr>'
123
- " call feedkeys("<cr>")
123
+ " call feedkeys("<cr>")
124
124
  1delete
125
125
  normal 1Gjk
126
126
  set nomodifiable
@@ -149,7 +149,7 @@ endfunction
149
149
  function! s:show_previous_message()
150
150
  let fullscreen = (bufwinnr(s:listbufnr) == -1) " we're in full screen message mode
151
151
  if fullscreen
152
- 3split
152
+ 3split
153
153
  exec 'b'. s:listbufnr
154
154
  else
155
155
  call s:focus_list_window()
@@ -194,10 +194,10 @@ function! s:show_raw()
194
194
  endfunction
195
195
 
196
196
  function! s:focus_list_window()
197
- if bufwinnr(s:listbufnr) == winnr()
197
+ if bufwinnr(s:listbufnr) == winnr()
198
198
  return
199
199
  end
200
- let winnr = bufwinnr(s:listbufnr)
200
+ let winnr = bufwinnr(s:listbufnr)
201
201
  if winnr == -1
202
202
  " create window
203
203
  split
@@ -247,7 +247,7 @@ function! s:update()
247
247
  call cursor(num, 0)
248
248
  normal z.
249
249
  redraw
250
- echom "You have " . num . " new message" . (num == 1 ? '' : 's') . "!"
250
+ echom "You have " . num . " new message" . (num == 1 ? '' : 's') . "!"
251
251
  else
252
252
  redraw
253
253
  echom "No new messages"
@@ -294,9 +294,9 @@ function! s:toggle_star() range
294
294
  if (match(getline(a:firstline), flag_symbol) != -1)
295
295
  let action = " -FLAGS"
296
296
  endif
297
- let command = s:flag_command . shellescape(join(uid_set, ',')) . action . " Flagged"
297
+ let command = s:flag_command . shellescape(join(uid_set, ',')) . action . " Flagged"
298
298
  if nummsgs == 1
299
- echom "Toggling flag on message"
299
+ echom "Toggling flag on message"
300
300
  else
301
301
  echom "Toggling flags on " . nummsgs . " messages"
302
302
  endif
@@ -320,7 +320,7 @@ function! s:toggle_star() range
320
320
  write
321
321
  redraw
322
322
  if nummsgs == 1
323
- echom "Toggled flag on message"
323
+ echom "Toggled flag on message"
324
324
  else
325
325
  echom "Toggled flags on " . nummsgs . " messages"
326
326
  endif
@@ -332,7 +332,7 @@ func! s:delete_messages(flag) range
332
332
  let nummsgs = len(uid_set)
333
333
  let command = s:flag_command . shellescape(join(uid_set, ',')) . " +FLAGS " . a:flag
334
334
  if nummsgs == 1
335
- echom "Deleting message"
335
+ echom "Deleting message"
336
336
  else
337
337
  echom "Deleting " . nummsgs . " messages"
338
338
  endif
@@ -371,7 +371,7 @@ func! s:append_messages_to_file() range
371
371
  return
372
372
  endif
373
373
  let s:append_file = append_file
374
- let command = s:append_to_file_command . shellescape(join(uid_set, ',')) . ' ' . s:append_file
374
+ let command = s:append_to_file_command . shellescape(join(uid_set, ',')) . ' ' . s:append_file
375
375
  echo "Appending " . nummsgs . " message" . (nummsgs == 1 ? '' : 's') . " to " . s:append_file . ". Please wait..."
376
376
  let res = s:system_with_error_handling(command)
377
377
  echo res
@@ -397,11 +397,11 @@ function! s:move_to_mailbox(copy) range
397
397
  let prompt = "select mailbox to " . (a:copy ? 'copy' : 'move') . " to: "
398
398
  call setline(1, prompt)
399
399
  normal $
400
- inoremap <silent> <buffer> <cr> <Esc>:call <SID>complete_move_to_mailbox()<CR>
400
+ inoremap <silent> <buffer> <cr> <Esc>:call <SID>complete_move_to_mailbox()<CR>
401
401
  inoremap <silent> <buffer> <esc> <Esc>:q<cr>
402
402
  setlocal completefunc=CompleteMoveMailbox
403
403
  " c-p clears the line
404
- let s:firstline = a:firstline
404
+ let s:firstline = a:firstline
405
405
  let s:lastline = a:lastline
406
406
  call feedkeys("a\<c-x>\<c-u>\<c-p>", 't')
407
407
  " save these in script scope to delete the lines when move completes
@@ -410,13 +410,13 @@ endfunction
410
410
  function! s:complete_move_to_mailbox()
411
411
  let mailbox = get(split(getline(line('.')), ": "), 1)
412
412
  close
413
- if s:copy_to_mailbox
413
+ if s:copy_to_mailbox
414
414
  let command = s:copy_to_command . s:uid_set . ' ' . shellescape(mailbox)
415
415
  else
416
416
  let command = s:move_to_command . s:uid_set . ' ' . shellescape(mailbox)
417
417
  endif
418
418
  redraw
419
- echo "Moving uids ". s:uid_set . " to mailbox " . mailbox
419
+ echo "Moving uids ". s:uid_set . " to mailbox " . mailbox
420
420
  let res = s:system_with_error_handling(command)
421
421
  setlocal modifiable
422
422
  if !s:copy_to_mailbox
@@ -425,7 +425,7 @@ function! s:complete_move_to_mailbox()
425
425
  setlocal nomodifiable
426
426
  write
427
427
  redraw
428
- echo s:nummsgs . " message" . (s:nummsgs == 1 ? '' : 's') . ' ' . (s:copy_to_mailbox ? 'copied' : 'moved') . ' to ' . mailbox
428
+ echo s:nummsgs . " message" . (s:nummsgs == 1 ? '' : 's') . ' ' . (s:copy_to_mailbox ? 'copied' : 'moved') . ' to ' . mailbox
429
429
  endfunction
430
430
 
431
431
  function! CompleteMoveMailbox(findstart, base)
@@ -474,7 +474,7 @@ function! s:mailbox_window()
474
474
  setlocal noswapfile
475
475
  setlocal modifiable
476
476
  resize 1
477
- inoremap <silent> <buffer> <cr> <Esc>:call <SID>select_mailbox()<CR>
477
+ inoremap <silent> <buffer> <cr> <Esc>:call <SID>select_mailbox()<CR>
478
478
  inoremap <silent> <buffer> <esc> <Esc>:q<cr>
479
479
  setlocal completefunc=CompleteMailbox
480
480
  " c-p clears the line
@@ -526,19 +526,19 @@ function! s:select_mailbox()
526
526
  " reset window width now
527
527
  call s:system_with_error_handling(s:set_window_width_command . winwidth(1))
528
528
  " now get latest 100 messages
529
- call s:focus_list_window()
529
+ call s:focus_list_window()
530
530
  setlocal modifiable
531
531
  let command = s:search_command . shellescape("all")
532
532
  echo "Loading messages..."
533
533
  let res = s:system_with_error_handling(command)
534
534
  silent 1,$delete
535
535
  silent! put! =res
536
- execute "normal Gdd\<c-y>"
536
+ execute "normal Gdd\<c-y>"
537
537
  setlocal nomodifiable
538
538
  write
539
539
  normal gg
540
540
  redraw
541
- echom "Current mailbox: ". s:mailbox
541
+ echom "Current mailbox: ". s:mailbox
542
542
  endfunction
543
543
 
544
544
  func! s:search_query()
@@ -559,37 +559,37 @@ function! s:do_search()
559
559
  close
560
560
  let command = s:search_command . shellescape(s:query)
561
561
  redraw
562
- call s:focus_list_window()
562
+ call s:focus_list_window()
563
563
  setlocal modifiable
564
564
  echo "Running query on " . s:mailbox . ": " . s:query . ". Please wait..."
565
565
  let res = s:system_with_error_handling(command)
566
566
  silent! 1,$delete
567
567
  silent! put! =res
568
- execute "silent normal Gdd\<c-y>"
568
+ execute "silent normal Gdd\<c-y>"
569
569
  setlocal nomodifiable
570
570
  write
571
571
  normal gg
572
572
  endfunction
573
573
 
574
574
  function! s:more_messages()
575
- let command = s:more_messages_command
575
+ let command = s:more_messages_command
576
576
  echo "Fetching more messages. Please wait..."
577
577
  let res = s:system_with_error_handling(command)
578
578
  setlocal modifiable
579
579
  let lines = split(res, "\n")
580
580
  call append(line('$'), lines)
581
- " execute "normal Gdd\<c-y>"
581
+ " execute "normal Gdd\<c-y>"
582
582
  setlocal nomodifiable
583
583
  normal j
584
584
  redraw
585
585
  echo "Done"
586
586
  endfunction
587
587
 
588
- " --------------------------------------------------------------------------------
588
+ " --------------------------------------------------------------------------------
589
589
  " compose reply, compose, forward, save draft
590
590
 
591
591
  function! s:compose_reply(all)
592
- let command = s:reply_template_command
592
+ let command = s:reply_template_command
593
593
  if a:all
594
594
  let command = command . ' 1'
595
595
  endif
@@ -602,14 +602,14 @@ function! s:compose_message()
602
602
  let command = s:new_message_template_command
603
603
  call s:open_compose_window(command)
604
604
  " position cursor after to:
605
- " call search("^to:")
605
+ " call search("^to:")
606
606
  " normal A
607
607
  endfunction
608
608
 
609
609
  function! s:compose_forward()
610
- let command = s:forward_template_command
610
+ let command = s:forward_template_command
611
611
  call s:open_compose_window(command)
612
- " call search("^to:")
612
+ " call search("^to:")
613
613
  " normal A
614
614
  endfunction
615
615
 
@@ -637,7 +637,7 @@ func! s:turn_into_compose_window()
637
637
  setlocal completefunc=CompleteContact
638
638
  endfunc
639
639
 
640
- " contacts.txt file should be generated.
640
+ " contacts.txt file should be generated.
641
641
  " grep works well, does partial matches
642
642
  function! CompleteContact(findstart, base)
643
643
  if !exists("s:mailboxes")
@@ -652,7 +652,7 @@ function! CompleteContact(findstart, base)
652
652
  endwhile
653
653
  return start
654
654
  else
655
- " find contacts
655
+ " find contacts
656
656
  " model regex: match at beginning of line, or inside < > wrapping
657
657
  " email addr
658
658
  " '\(^ho\|<ho\)'
@@ -683,11 +683,11 @@ function! s:send_message()
683
683
  redraw
684
684
  endfunction
685
685
 
686
- " --------------------------------------------------------------------------------
686
+ " --------------------------------------------------------------------------------
687
687
 
688
688
  " call from inside message window with <Leader>h
689
689
  func! s:open_html_part()
690
- let command = s:open_html_part_command
690
+ let command = s:open_html_part_command
691
691
  " the command saves the html part to a local file
692
692
  let outfile = s:system_with_error_handling(command)
693
693
  " todo: allow user to change open in browser command?
@@ -712,7 +712,7 @@ func! s:attach_file(file)
712
712
  endfunc
713
713
 
714
714
 
715
- " --------------------------------------------------------------------------------
715
+ " --------------------------------------------------------------------------------
716
716
 
717
717
  func! s:toggle_maximize_window()
718
718
  if winnr('$') > 1
@@ -743,7 +743,7 @@ func! s:open_href(all) range
743
743
  endif
744
744
  let lnum += 1
745
745
  endwhile
746
- echom 'opened '.n.' links'
746
+ echom 'opened '.n.' links'
747
747
  return
748
748
  end
749
749
  let line = search(pattern, 'cw')
@@ -755,7 +755,7 @@ func! s:open_href(all) range
755
755
  let n += 1
756
756
  let line = search('https\?:', 'W')
757
757
  endwhile
758
- echom 'opened '.n.' links'
758
+ echom 'opened '.n.' links'
759
759
  else
760
760
  let href = matchstr(getline(line('.')), pattern)
761
761
  let command = s:browser_command ." ".shellescape(href)." &"
@@ -764,7 +764,7 @@ func! s:open_href(all) range
764
764
  endif
765
765
  endfunc
766
766
 
767
- " --------------------------------------------------------------------------------
767
+ " --------------------------------------------------------------------------------
768
768
  " HELP
769
769
  func! s:show_help()
770
770
  let command = s:browser_command . ' ' . shellescape('http://danielchoi.com/software/vmail.html')
@@ -773,7 +773,7 @@ func! s:show_help()
773
773
  "exec "split " . helpfile
774
774
  endfunc
775
775
 
776
- " --------------------------------------------------------------------------------
776
+ " --------------------------------------------------------------------------------
777
777
  " CONVENIENCE FUNCS
778
778
 
779
779
  function! s:collect_uids(startline, endline)
@@ -787,7 +787,7 @@ function! s:collect_uids(startline, endline)
787
787
  return uid_set
788
788
  endfunc
789
789
 
790
- " --------------------------------------------------------------------------------
790
+ " --------------------------------------------------------------------------------
791
791
  " MAPPINGS
792
792
 
793
793
  func! s:message_window_mappings()
@@ -1071,8 +1071,8 @@ func! s:global_mappings()
1071
1071
  " NOTE send_message is a global mapping, so user can load a saved
1072
1072
  " message from a file and send it
1073
1073
  nnoremap <silent> <leader>vs :call <SID>send_message()<CR>
1074
- noremap <silent> <leader>o :call <SID>open_href(0)<cr>
1075
- noremap <silent> <leader>O :call <SID>open_href(1)<cr>
1074
+ noremap <silent> <leader>o :call <SID>open_href(0)<cr>
1075
+ noremap <silent> <leader>O :call <SID>open_href(1)<cr>
1076
1076
  noremap <silent> <leader>? :call <SID>show_help()<cr>
1077
1077
  noremap <silent> <leader>qq :qal!<cr>
1078
1078
  endfunc
@@ -1087,7 +1087,14 @@ func! s:set_list_colors()
1087
1087
  syn match vmailFirstColAnswered /An/ contained containedin=vmailFirstCol
1088
1088
  syn match vmailFirstColForward /\$F/ contained containedin=vmailFirstCol
1089
1089
  syn match vmailFirstColNotJunk /No/ contained containedin=vmailFirstCol
1090
- syn match vmailDateCol /\s\+... \d\d \(\(\d\d:\d\d..\)\|\(\d\{4}\)\)\s\+|/ nextgroup=vmailFromCol contains=vmailSeperator
1090
+
1091
+ " Examples matched by vmailDateCol:
1092
+ " | Dec 15 11:59pm |
1093
+ " | Dec 15 2008 |
1094
+ " | 15.12 23:59 |
1095
+ " | 15.12 2008 |
1096
+ 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
1097
+
1091
1098
  syn match vmailFromCol /\s.\{-}|\@=/ contained nextgroup=vmailFromSeperator
1092
1099
  syn match vmailFromColEmail /<[^ ]*/ contained containedin=vmailFromCol
1093
1100
  syn match vmailFromSeperator /|/ contained nextgroup=vmailSubject
@@ -46,6 +46,20 @@ module Vmail
46
46
  @smtp_domain = config['smtp_domain'] || 'gmail.com'
47
47
  @authentication = config['authentication'] || 'plain'
48
48
  @width = 100
49
+ @date_format = config['date_format'] || 'wordy'
50
+ if @date_format == 'numerical'
51
+ @date_formatter_this_year = '%d.%m %H:%M'
52
+ @date_formatter_prev_years = '%d.%m %Y'
53
+ @formatted_date_with = 11
54
+ else
55
+ if @date_format != 'wordy'
56
+ @logger.warn "Unknown date_format: #{@date_format}; Using default value: wordy"
57
+ @date_format = 'wordy'
58
+ end
59
+ @date_formatter_this_year = '%b %d %I:%M%P'
60
+ @date_formatter_prev_years = '%b %d %Y'
61
+ @formatted_date_with = 14
62
+ end
49
63
  current_message = nil
50
64
  end
51
65
 
@@ -1,5 +1,7 @@
1
1
  require 'iconv'
2
+
2
3
  module Vmail
4
+
3
5
  module ShowingHeaders
4
6
 
5
7
  def get_message_headers(message_ids)
@@ -76,9 +78,9 @@ module Vmail
76
78
  def format_header_for_list(message)
77
79
  date = DateTime.parse(message.date)
78
80
  formatted_date = if date.year != Time.now.year
79
- date.strftime "%b %d %Y"
81
+ date.strftime @date_formatter_prev_years
80
82
  else
81
- date.strftime "%b %d %I:%M%P"
83
+ date.strftime @date_formatter_this_year
82
84
  end
83
85
  address = if @mailbox == mailbox_aliases['sent']
84
86
  message.recipients
@@ -90,7 +92,7 @@ module Vmail
90
92
  address_col_width = (mid_width * 0.3).ceil
91
93
  subject_col_width = (mid_width * 0.7).floor
92
94
  row_text = [ format_flags(message.flags).col(2),
93
- (formatted_date || '').col(14),
95
+ (formatted_date || '').col(@formatted_date_with),
94
96
  address.col(address_col_width),
95
97
  message.subject.col(subject_col_width),
96
98
  number_to_human_size(message.size).rcol(7),
data/lib/vmail/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vmail
2
- VERSION = '2.6.5'
2
+ VERSION = '2.6.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmail
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.5
4
+ version: 2.6.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: