module Redwood
class ThreadViewMode < LineCursorMode
+ include CanSpawnComposeMode
+ include CanSpawnForwardMode
+
## this holds all info we need to lay out a message
class MessageLayout
attr_accessor :top, :bot, :prev, :next, :depth, :width, :state, :color, :star_color, :orig_new
k.add :compose, "Compose message to person", 'm'
k.add :archive_and_kill, "Archive thread and kill buffer", 'a'
k.add :delete_and_kill, "Delete thread and kill buffer", 'd'
+ k.add :subscribe_to_list, "Subscribe to/unsubscribe from mailing list", "("
+ k.add :unsubscribe_from_list, "Subscribe to/unsubscribe from mailing list", ")"
end
## there are a couple important instance variables we hold to format
BufferManager.spawn "Reply to #{m.subj}", mode
end
+ def subscribe_to_list
+ m = @message_lines[curpos] or return
+ if m.list_subscribe && m.list_subscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
+ spawn_compose_mode :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+ else
+ BufferManager.flash "Can't find List-Subscribe header for this message."
+ end
+ end
+
+ def unsubscribe_from_list
+ m = @message_lines[curpos] or return
+ if m.list_unsubscribe && m.list_unsubscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
+ spawn_compose_mode :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+ else
+ BufferManager.flash "Can't find List-Unsubscribe header for this message."
+ end
+ end
+
def forward
m = @message_lines[curpos] or return
- mode = ForwardMode.new m
- BufferManager.spawn "Forward of #{m.subj}", mode
- mode.edit_message
+ spawn_forward_mode m
end
include CanAliasContacts
def compose
p = @person_lines[curpos]
- mode =
- if p
- ComposeMode.new :to => [p]
- else
- ComposeMode.new
- end
- BufferManager.spawn "Compose message", mode
- mode.edit_message
+ if p
+ spawn_compose_mode :to => [p]
+ else
+ spawn_compose_mode
+ end
end
def edit_labels
@thread.labels = (reserved_labels + new_labels).uniq
new_labels.each { |l| LabelManager << l }
update
- UpdateManager.relay self, :label, m
+ UpdateManager.relay self, :label_thread, @thread
end
def toggle_starred
end
def jump_to_next_open
+ return continue_search_in_buffer if in_search? # hack: allow 'n' to apply to both operations
m = @message_lines[curpos] or return
while nextm = @layout[m].next
break if @layout[nextm].state != :closed