From 75416d4ef7c2853e4421912e74ef9c01a06366e3 Mon Sep 17 00:00:00 2001 From: wmorgan Date: Wed, 17 Jan 2007 23:09:30 +0000 Subject: [PATCH] resume arbitrary messages git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@260 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- doc/TODO | 3 ++- lib/sup/modes/compose-mode.rb | 10 +++++++--- lib/sup/modes/thread-view-mode.rb | 28 ++++++++++++++++++---------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/doc/TODO b/doc/TODO index c9e2ae4..05c22c7 100644 --- a/doc/TODO +++ b/doc/TODO @@ -17,13 +17,14 @@ undo maybe: filters maybe: rangefilter on the initial inbox to only consider the most recent 1000 messages select all, starred, to me, etc -editing of arbitrary messages annotations on messages gmail pop move sup-import argument handling to getopt be able to mark individual messages as spam in thread-view-mode +toggle wrapping +x resuming of arbitrary messages x alias authors in thread-view-mode x fix up contact list mode: should display while loading, and when you add an alias, should move everything else to the right x fix bug: envelope-to thing still not working diff --git a/lib/sup/modes/compose-mode.rb b/lib/sup/modes/compose-mode.rb index 3dce01e..677d999 100644 --- a/lib/sup/modes/compose-mode.rb +++ b/lib/sup/modes/compose-mode.rb @@ -3,15 +3,19 @@ module Redwood class ComposeMode < EditMessageMode attr_reader :body, :header - def initialize h={} + def initialize opts={} super() @header = { "From" => AccountManager.default_account.full_address, "Message-Id" => gen_message_id, } - @header["To"] = [h[:to]].flatten.compact.map { |p| p.full_address } - @body = sig_lines + @header["To"] = opts[:to].map { |p| p.full_address }.join(", ") if opts[:to] + @header["Cc"] = opts[:cc].map { |p| p.full_address }.join(", ") if opts[:cc] + @header["Bcc"] = opts[:bcc].map { |p| p.full_address }.join(", ") if opts[:bcc] + @header["Subject"] = opts[:subj] if opts[:subj] + + @body = opts[:body] || sig_lines regen_text end diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb index eb0d444..e399122 100644 --- a/lib/sup/modes/thread-view-mode.rb +++ b/lib/sup/modes/thread-view-mode.rb @@ -23,6 +23,7 @@ class ThreadViewMode < LineCursorMode k.add :reply, "Reply to a message", 'r' k.add :forward, "Forward a message", 'f' k.add :alias, "Edit alias/nickname for a person", 'a' + k.add :edit_as_new, "Edit message as new", 'd' k.add :save_to_disk, "Save message/attachment to disk", 's' end @@ -70,26 +71,26 @@ class ThreadViewMode < LineCursorMode def [] i; @text[i]; end def show_header - return unless(m = @message_lines[curpos]) + m = @message_lines[curpos] or return BufferManager.spawn_unless_exists("Full header") do TextMode.new m.raw_header end end def toggle_detailed_header - return unless(m = @message_lines[curpos]) + m = @message_lines[curpos] or return @layout[m].state = (@layout[m].state == :detailed ? :open : :detailed) update end def reply - return unless(m = @message_lines[curpos]) + m = @message_lines[curpos] or return mode = ReplyMode.new m BufferManager.spawn "Reply to #{m.subj}", mode end def forward - return unless(m = @message_lines[curpos]) + m = @message_lines[curpos] or return mode = ForwardMode.new m BufferManager.spawn "Forward of #{m.subj}", mode mode.edit @@ -103,7 +104,7 @@ class ThreadViewMode < LineCursorMode end def toggle_starred - return unless(m = @message_lines[curpos]) + m = @message_lines[curpos] or return if m.has_label? :starred m.remove_label :starred else @@ -116,7 +117,7 @@ class ThreadViewMode < LineCursorMode end def toggle_expanded - return unless(chunk = @chunk_lines[curpos]) + chunk = @chunk_lines[curpos] or return case chunk when Message, Message::Quote, Message::Signature l = @layout[chunk] @@ -128,8 +129,15 @@ class ThreadViewMode < LineCursorMode update end + def edit_as_new + m = @message_lines[curpos] or return + mode = ComposeMode.new(:body => m.basic_body_lines, :to => m.to, :cc => m.cc, :subj => m.subj, :bcc => m.bcc) + BufferManager.spawn "edit as new", mode + mode.edit + end + def save_to_disk - return unless(chunk = @chunk_lines[curpos]) + chunk = @chunk_lines[curpos] or return case chunk when Message::Attachment fn = BufferManager.ask :filename, "Save attachment to file: ", chunk.filename @@ -142,7 +150,7 @@ class ThreadViewMode < LineCursorMode end def edit_message - return unless(m = @message_lines[curpos]) + m = @message_lines[curpos] or return if m.is_draft? mode = ResumeMode.new m BufferManager.spawn "Edit message", mode @@ -153,7 +161,7 @@ class ThreadViewMode < LineCursorMode end def jump_to_next_open - return unless(m = @message_lines[curpos]) + m = @message_lines[curpos] or return while nextm = @layout[m].next break if @layout[nextm].state == :open m = nextm @@ -162,7 +170,7 @@ class ThreadViewMode < LineCursorMode end def jump_to_prev_open - return unless(m = @message_lines[curpos]) + m = @message_lines[curpos] or return ## jump to the top of the current message if we're in the body; ## otherwise, to the previous message -- 2.45.2