From: William Morgan Date: Sun, 30 Dec 2007 19:05:25 +0000 (-0800) Subject: added dispatch-and-kill to thread-view-mode X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=641b1e316c034ec158dfdbec6297002e7fe9f827;p=sup added dispatch-and-kill to thread-view-mode --- diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb index 0abeb62..af1761f 100644 --- a/lib/sup/modes/thread-index-mode.rb +++ b/lib/sup/modes/thread-index-mode.rb @@ -88,7 +88,7 @@ EOS m.load_from_source! end end - mode = ThreadViewMode.new t, @hidden_labels + mode = ThreadViewMode.new t, @hidden_labels, self BufferManager.spawn t.subj, mode BufferManager.draw_screen mode.jump_to_first_open diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb index d7a6a82..238f59a 100644 --- a/lib/sup/modes/thread-view-mode.rb +++ b/lib/sup/modes/thread-view-mode.rb @@ -48,6 +48,7 @@ EOS k.add :unsubscribe_from_list, "Subscribe to/unsubscribe from mailing list", ")" k.add :pipe_message, "Pipe message or attachment to a shell command", '|' + ## dispatch-and-kill commands k.add_multi "(A)rchive/(d)elete/mark as (s)pam/do (n)othing:", ',' do |kk| kk.add :archive_and_kill, "Archive this thread and view next", 'a' kk.add :delete_and_kill, "Delete this thread and view next", 'd' @@ -63,11 +64,15 @@ EOS ## Message objects. @chunk_lines is a map from row #s to Chunk ## objects. @person_lines is a map from row #s to Person objects. - def initialize thread, hidden_labels=[] + def initialize thread, hidden_labels=[], index_mode=nil super() @thread = thread @hidden_labels = hidden_labels + ## used for dispatch-and-kill + @index_mode = index_mode + @dying = false + @layout = SavingHash.new { MessageLayout.new } @chunk_layout = SavingHash.new { ChunkLayout.new } earliest, latest = nil, nil @@ -340,29 +345,45 @@ EOS end def archive_and_kill - @thread.remove_label :inbox - @thread.save Index - UpdateManager.relay self, :archived, @thread.first - BufferManager.kill_buffer_safely buffer + dispatch_and_kill do + @thread.remove_label :inbox + UpdateManager.relay self, :archived, @thread.first + end end def spam_and_kill - @thread.apply_label :spam - @thread.save Index - UpdateManager.relay self, :spammed, @thread.first - BufferManager.kill_buffer_safely buffer + dispatch_and_kill do + @thread.apply_label :spam + UpdateManager.relay self, :spammed, @thread.first + end + end + + def delete_and_kill + dispatch_and_kill do + @thread.apply_label :deleted + UpdateManager.relay self, :deleted, @thread.first + end end def skip_and_kill - BufferManager.kill_buffer_safely buffer + dispatch_and_kill { } end - def delete_and_kill - @thread.apply_label :deleted - @thread.save Index - UpdateManager.relay self, :deleted, @thread.first - BufferManager.kill_buffer_safely buffer + def dispatch_and_kill + return if @dying + @dying = true + + if @index_mode + @index_mode.launch_next_thread_after(@thread) do + @thread.save Index if yield + BufferManager.kill_buffer_safely buffer + end + else + @thread.save Index if yield + BufferManager.kill_buffer_safely buffer + end end + private :dispatch_and_kill def pipe_message chunk = @chunk_lines[curpos]