vmail 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/NOTES CHANGED
@@ -475,33 +475,25 @@ DONE
475
475
  - map u update from message window
476
476
  - do search after loading vim or mvim and send size first
477
477
  - vim resize event
478
-
479
- next:
478
+ - mvim - window width corrected
479
+ - delete mvmail command. just use env variable - cleaner
480
480
  - sending an attachment
481
481
  - can specify a directory, then all the items in the directory get
482
482
  attached and sent
483
- - forwarding attachments
483
+
484
+ next:
485
+ - forwarding with attachments
484
486
  - could be "attach: [uid] attachments to signal"
485
- - put instructions in message window; put in a top section
486
- - help /readme
487
- - help document should just be readme? or part of it.
487
+ - help doc: just return readme file, or a vim version of it (vim filetype later)
488
488
  - follow mysql and use -u and -p flags on startup of server?
489
489
  - omitting -p flag forces prompt
490
- - get rid of config file
491
- - use temp files
492
- - tempname()
493
- - system() allows a parameters that is written to tmp file and passed
494
- to stdin
495
490
  - print all selected messages into file (append)
496
- - can pipe through a command line tool, so we don't need to clutter
497
- viewer.vim with more mappings and functions
498
491
  - ,s s confusion? Star vs search
499
492
  - enhance contacts auto fix with more advanced vim script
500
493
  - sort contacts by frequency, then take first 10 or so of any match
501
- - mvim - window width not correct
502
- - mvim - starred messages not syntax colored
503
494
 
504
495
  later:
496
+ - mvim - starred messages not syntax colored
505
497
  - mvim redrawstatus line bug
506
498
  http://vim.1045645.n5.nabble.com/Redrawing-bug-in-MacVim-Command-T-since-commit-ba44868-td3248742.html
507
499
  - allow one daemon, multiple clients (select mailbox?)
@@ -523,6 +515,10 @@ later:
523
515
  - sometimes update doesn't work - bug
524
516
  - show total messages from a search, showing 100
525
517
  - message threads
518
+ - use temp files
519
+ - tempname()
520
+ - system() allows a parameters that is written to tmp file and passed
521
+ to stdin
526
522
 
527
523
 
528
524
 
@@ -22,7 +22,7 @@ The format of the yaml file is as follows:
22
22
  Sent via vmail. http://danielchoi.com
23
23
 
24
24
  Start the program by typing `vmail` on your command line. If you want to use the Macvim
25
- version, type `mvmail`.
25
+ version, `export VMAIL_VIM=mvim` first.
26
26
 
27
27
  There is no real documentation as of yet, but here are the raw vimscript mappings
28
28
 
@@ -97,6 +97,7 @@ function! s:show_message()
97
97
  redraw
98
98
  endfunction
99
99
 
100
+ " from message window
100
101
  function! s:show_next_message()
101
102
  call s:focus_list_window()
102
103
  execute "normal j"
@@ -105,12 +106,26 @@ endfunction
105
106
 
106
107
  function! s:show_previous_message()
107
108
  call s:focus_list_window()
108
- execute "normal k"
109
- if line('.') != 1
110
- execute "normal \<cr>"
111
- endif
109
+ execute "normal k"
110
+ if line('.') != 1
111
+ execute "normal \<cr>"
112
+ endif
113
+ endfunction
114
+
115
+ " from message list window
116
+ function! s:show_next_message_in_list()
117
+ if line('.') != line('$')
118
+ call feedkeys("j\<cr>\<cr>")
119
+ endif
120
+ endfunction
121
+
122
+ function! s:show_previous_message_in_list()
123
+ if line('.') != 1
124
+ call feedkeys("k\<cr>\<cr>")
125
+ endif
112
126
  endfunction
113
127
 
128
+
114
129
  " invoked from withint message window
115
130
  function! s:show_raw()
116
131
  let command = s:show_message_command . s:current_uid . ' raw'
@@ -169,11 +184,11 @@ function! s:update()
169
184
  redraw
170
185
  call cursor(line + 1, 0)
171
186
  normal z.
172
- echom "you have " . num . " new message" . (num == 1 ? '' : 's') . "!"
173
- redrawstatus
187
+ redraw
188
+ echo "you have " . num . " new message" . (num == 1 ? '' : 's') . "!"
174
189
  else
175
- echom "no new messages"
176
- redrawstatus
190
+ redraw
191
+ echo "no new messages"
177
192
  endif
178
193
  endfunction
179
194
 
@@ -510,7 +525,7 @@ function! s:cancel_compose()
510
525
  close!
511
526
  endfunction
512
527
 
513
- function! s:deliver_message()
528
+ function! s:send_message()
514
529
  write
515
530
  let mail = join(getline(1,'$'), "\n")
516
531
  exec ":!" . s:deliver_command . " < ComposeMessage"
@@ -546,8 +561,8 @@ func! s:save_attachments()
546
561
  end
547
562
  let s:savedir = input("save attachments to directory: ", s:savedir)
548
563
  let command = s:save_attachments_command . s:savedir
549
- echo command
550
564
  let res = system(command)
565
+ echo res
551
566
  endfunc
552
567
  " --------------------------------------------------------------------------------
553
568
 
@@ -608,15 +623,16 @@ func! s:message_list_window_mappings()
608
623
  noremap <silent> <buffer> <Leader>c :call <SID>compose_message()<CR>
609
624
  noremap <silent> <buffer> <Leader>r :call <SID>show_message()<cr>:call <SID>compose_reply(0)<CR>
610
625
  noremap <silent> <buffer> <Leader>a :call <SID>show_message()<cr>:call <SID>compose_reply(1)<CR>
611
- " go fullscreen
626
+ noremap <silent> <buffer> <c-j> :call <SID>show_next_message_in_list()<cr>
627
+ noremap <silent> <buffer> <c-k> :call <SID>show_previous_message_in_list()<cr>
612
628
  nnoremap <silent> <buffer> <Space> :call <SID>toggle_fullscreen()<cr>
613
629
  endfunc
614
630
 
615
631
  func! s:compose_window_mappings()
616
- " NOTE deliver_message is a global mapping, so user can load a saved
632
+ " NOTE send_message is a global mapping, so user can load a saved
617
633
  " message from a file and send it
618
- nnoremap <silent> <Leader>vd :call <SID>deliver_message()<CR>
619
- nnoremap <silent> <buffer> <Leader>vs :call <SID>save_draft()<CR>
634
+ nnoremap <silent> <Leader>vs :call <SID>send_message()<CR>
635
+ nnoremap <silent> <buffer> <Leader>vd :call <SID>save_draft()<CR>
620
636
  noremap <silent> <buffer> <leader>q :call <SID>cancel_compose()<cr>
621
637
  nmap <silent> <buffer> q <leader>q
622
638
  endfunc
@@ -378,12 +378,7 @@ EOF
378
378
  def new_mail_from_input(text)
379
379
  require 'mail'
380
380
  mail = Mail.new
381
- raw_headers, body = *text.split(/\n\s*\n/, 2)
382
- # handle attachments
383
- if (attachments = body.split(/\n\s*\n/, 2)[0]) =~ /^attach:/
384
- # TODO
385
- log "attachments: #{YAML::load(attachments).inspect}"
386
- end
381
+ raw_headers, raw_body = *text.split(/\n\s*\n/, 2)
387
382
  headers = {}
388
383
  raw_headers.split("\n").each do |line|
389
384
  key, value = *line.split(/:\s*/, 2)
@@ -397,7 +392,27 @@ EOF
397
392
  mail.bcc = headers['bcc'] #&& headers['cc'].split(/,\s+/)
398
393
  mail.subject = headers['subject']
399
394
  mail.from ||= @username
400
- mail.body = body
395
+ # attachments are added as a snippet of YAML after a blank line
396
+ # after the headers, and followed by a blank line
397
+ if (attachments = raw_body.split(/\n\s*\n/, 2)[0]) =~ /^attach(ment|ments)*:/
398
+ # TODO
399
+ files = YAML::load(attachments).values.flatten
400
+ log "attachments: #{files}"
401
+ files.each do |file|
402
+ if File.directory?(file)
403
+ Dir.glob("#{file}/*").each {|f| mail.add_file(f) if File.size?(f)}
404
+ else
405
+ mail.add_file(file) if File.size?(file)
406
+ end
407
+ end
408
+ mail.text_part do
409
+ body raw_body.split(/\n\s*\n/, 2)[1]
410
+ end
411
+ else
412
+ mail.text_part do
413
+ body raw_body
414
+ end
415
+ end
401
416
  mail
402
417
  end
403
418
 
@@ -409,11 +424,13 @@ EOF
409
424
  return unless dir && @current_mail
410
425
  attachments = @current_mail.attachments
411
426
  `mkdir -p #{dir}`
412
- attachments.each do |x|
427
+ saved = attachments.map do |x|
413
428
  path = File.join(dir, x.filename)
414
429
  log "saving #{path}"
415
430
  File.open(path, 'wb') {|f| f.puts x.decoded}
431
+ path
416
432
  end
433
+ "saved:\n" + saved.map {|x| "- #{x}"}.join("\n")
417
434
  end
418
435
 
419
436
  def open_html_part(uid)
@@ -1,3 +1,3 @@
1
1
  module Vmail
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi
@@ -34,7 +34,6 @@ description: Manage your email with Vim
34
34
  email:
35
35
  - dhchoi@gmail.com
36
36
  executables:
37
- - mvmail
38
37
  - vmail
39
38
  - vmail_client
40
39
  extensions: []
@@ -46,7 +45,6 @@ files:
46
45
  - NOTES
47
46
  - README.markdown
48
47
  - Rakefile
49
- - bin/mvmail
50
48
  - bin/vmail
51
49
  - bin/vmail_client
52
50
  - gmail.vim
data/bin/mvmail DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- begin
4
- require 'vmail'
5
- rescue LoadError
6
- require 'rubygems'
7
- require 'gmail'
8
- end
9
-
10
- ENV['VMAIL_VIM'] = 'mvim'
11
- Vmail.start
12
-