]> git.notmuchmail.org Git - sup/commitdiff
resume arbitrary messages
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 17 Jan 2007 23:09:30 +0000 (23:09 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 17 Jan 2007 23:09:30 +0000 (23:09 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@260 5c8cc53c-5e98-4d25-b20a-d8db53a31250

doc/TODO
lib/sup/modes/compose-mode.rb
lib/sup/modes/thread-view-mode.rb

index c9e2ae4a862a42c44413b86ce7875f03189496ed..05c22c759264f0c6079236c7c095bc04909e6b90 100644 (file)
--- 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
index 3dce01ee8e2a07035ea4ec238c396c3aa9795140..677d9995a6f8cf6f19f8600eb297071c74259440 100644 (file)
@@ -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
 
index eb0d444c5bd7818d07f60ac5504483ea73ec2666..e399122f58d743d20e4d2f81d997e22de7a64200 100644 (file)
@@ -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