return "<#{random_tag}@#{Socket.gethostname}.notmuch>"
end
- def open_reply(orig)
+ def open_compose_helper(lines, cur)
help_lines = [
'Notmuch-Help: Type in your message here; to help you use these bindings:',
'Notmuch-Help: ,s - send the message (Notmuch-Help lines will be removed)',
'Notmuch-Help: ,q - abort the message',
]
+
+ dir = File.expand_path('~/.notmuch/compose')
+ FileUtils.mkdir_p(dir)
+ Tempfile.open(['nm-', '.mail'], dir) do |f|
+ f.puts(help_lines)
+ f.puts
+ f.puts(lines)
+
+ sig_file = File.expand_path('~/.signature')
+ if File.exists?(sig_file)
+ f.puts("-- ")
+ f.write(File.read(sig_file))
+ end
+
+ f.flush
+
+ cur += help_lines.size + 1
+
+ VIM::command("let s:reply_from='%s'" % $email_address)
+ VIM::command("call s:new_file_buffer('compose', '#{f.path}')")
+ VIM::command("call cursor(#{cur}, 0)")
+ end
+ end
+
+ def open_reply(orig)
reply = orig.reply do |m|
# fix headers
if not m[:reply_to]
m.content_transfer_encoding = '7bit'
end
- dir = File.expand_path('~/.notmuch/compose')
- FileUtils.mkdir_p(dir)
- Tempfile.open(['nm-', '.mail'], dir) do |f|
- lines = []
-
- lines += help_lines
- lines << ''
-
- body_lines = []
- if $mail_installed
- addr = Mail::Address.new(orig[:from].value)
- name = addr.name
- name = addr.local + "@" if name.nil? && !addr.local.nil?
- else
- name = orig[:from]
- end
- name = "somebody" if name.nil?
-
- body_lines << "%s wrote:" % name
- part = orig.find_first_text
- part.convert.each_line do |l|
- body_lines << "> %s" % l.chomp
- end
- body_lines << ""
- body_lines << ""
- body_lines << ""
-
- reply.body = body_lines.join("\n")
+ lines = []
- lines += reply.to_s.lines.map { |e| e.chomp }
- lines << ""
+ body_lines = []
+ if $mail_installed
+ addr = Mail::Address.new(orig[:from].value)
+ name = addr.name
+ name = addr.local + "@" if name.nil? && !addr.local.nil?
+ else
+ name = orig[:from]
+ end
+ name = "somebody" if name.nil?
- old_count = lines.count - 1
+ body_lines << "%s wrote:" % name
+ part = orig.find_first_text
+ part.convert.each_line do |l|
+ body_lines << "> %s" % l.chomp
+ end
+ body_lines << ""
+ body_lines << ""
+ body_lines << ""
- f.puts(lines)
+ reply.body = body_lines.join("\n")
- sig_file = File.expand_path('~/.signature')
- if File.exists?(sig_file)
- f.puts("-- ")
- f.write(File.read(sig_file))
- end
+ lines += reply.to_s.lines.map { |e| e.chomp }
+ lines << ""
- f.flush
+ cur = lines.count - 1
- VIM::command("let s:reply_from='%s'" % $email_address)
- VIM::command("call s:new_file_buffer('compose', '#{f.path}')")
- VIM::command("call cursor(#{old_count}, 0)")
- end
+ open_compose_helper(lines, cur)
end
def folders_render()