lib/sup/modes/reply-mode.rb in sup-0.2 vs lib/sup/modes/reply-mode.rb in sup-0.3

- old
+ new

@@ -36,18 +36,25 @@ ## the list address, which we explicitly treat with :list to = @m.is_list_message? ? @m.from : (@m.replyto || @m.from) cc = (@m.to + @m.cc - [from, to]).uniq @headers = {} - @headers[:sender] = { - "To" => [to.full_address], - } unless AccountManager.is_account? to + ## if there's no cc, then the sender is the person you want to reply + ## to. if it's a list message, then the list address is. otherwise, + ## the cc contains a recipient. + useful_recipient = !(cc.empty? || @m.is_list_message?) + @headers[:recipient] = { "To" => cc.map { |p| p.full_address }, - } unless cc.empty? || @m.is_list_message? + } if useful_recipient + ## typically we don't want to have a reply-to-sender option if the sender + ## is a user account. however, if the cc is empty, it's a message to + ## ourselves, so for the lack of any other options, we'll add it. + @headers[:sender] = { "To" => [to.full_address], } if !AccountManager.is_account?(to) || !useful_recipient + @headers[:user] = {} @headers[:all] = { "To" => [to.full_address], "Cc" => cc.select { |p| !AccountManager.is_account?(p) }.map { |p| p.full_address }, @@ -56,10 +63,11 @@ @headers[:list] = { "To" => [@m.list_address.full_address], } if @m.is_list_message? refs = gen_references + @headers.each do |k, v| @headers[k] = { "From" => "#{from.name} <#{from.email}>", "To" => [], "Cc" => [], @@ -100,12 +108,11 @@ end protected def reply_body_lines m - lines = ["Excerpts from #{@m.from.name}'s message of #{@m.date}:"] + - m.basic_body_lines.map { |l| "> #{l}" } + lines = ["Excerpts from #{@m.from.name}'s message of #{@m.date}:"] + m.quotable_body_lines.map { |l| "> #{l}" } lines.pop while lines.last =~ /^\s*$/ lines end def handle_new_text new_header, new_body @@ -119,14 +126,15 @@ def gen_references (@m.refs + [@m.id]).map { |x| "<#{x}>" }.join(" ") end - def edit_field - @selected_type = :user - self.header = @headers[:user] - update - super + def edit_field field + edited_field = super + if edited_field && edited_field != "Subject" + @selected_type = :user + update + end end def move_cursor_left i = @type_labels.index @selected_type @selected_type = @type_labels[(i - 1) % @type_labels.length]