Subject: [sup-talk] Problems with undo archive and thread focus

From: Matthias Guedemann <[email-masked]>
Date: Thu, 05 Nov 2009 09:27:25 +0100

Hi,

while using sup for a while now I came across surprising behavior in the
following situations.

One is, if you hit 'a' in thread view mode, the thread is archived but undo does
not work. If you go back to index view and hit 'u' the just archived thread does
not appear, but the one before.

The second is, if I respond to a thread and send the mail, I normally want to
either archive that mail directly or label and archive it. But the thread is put
to the front and the focus is on the last place of the thread. Therefore I
sometimes archive the wrong thread (but undo comes in handy)

The first seems to be a bug, the second may be a problem only for me.

best regards,

Matthias
-- 
__________________________________________________________
                                            ___  __    __
Dipl. Inf. Matthias Guedemann              / __\/ _\  /__\
Computer Systems in Engineering           / /   \ \  /_\
Otto-von-Guericke Universitaet Magdeburg / /___ _\ \//__
Tel.: 0391 / 67-19359                    \____/ \__/\__/
__________________________________________________________
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Rich Lane <[email-masked]>
Date: Thu, 19 Nov 2009 23:51:22 -0500

Excerpts from Andrew Pimlott's message of Thu Nov 12 12:30:01 -0500 2009:
> Excerpts from Matthias Guedemann's message of Thu Nov 05 00:27:25 -0800 2009:
> I was annoyed by this too and found that undo is minimally implemented.
> I added undo to thread view, at least for the cases that I care about or
> were easy.  I have to say I was discouraged that this was necessary: the
> code to archive a thread should all be in one place, and the undo
> record should be created there.  There's a lot of code duplication, and
> I can't tell if it's because the model and view are too coupled, or
> because nobody has bothered to factor it out.
> 
> The patch is appended.  (This is the first time I've done this with git.)

Branch thread-view-mode-undo, merged to master at
git://github.com/rlane/sup
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Matthias Guedemann <[email-masked]>
Date: Mon, 16 Nov 2009 10:42:18 +0100

Hi Andrew,

> The patch is appended.  (This is the first time I've done this with git.)

thanks, works perfectly.

> That's the next most annying thing for me.  Hope to get a chance to work
> on it.

I had a look at the code and it should not be too hard, basically when a reply
buffer is spawned (e.g. thread-view-mode line 168), a hook to call set_sursor_pos
0 (as ThreadViewMode is a subclass of LineCursorMode) after successful sending of
the reply should do the job. 

But unfortunately I don't know too much about the inner workings of sup (can the
HookManager be used for this? or should the hook be supplied as attribute to the
reply-buffer?), or even Ruby, to do it at the moment.

best regards

Matthias

---

From: Andrew Pimlott <[email-masked]>
Date: Thu, 12 Nov 2009 09:30:01 -0800

Andrew

Subject: [PATCH] create undo records in thread view

---
 lib/sup/modes/thread-view-mode.rb |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
index 81197c2..2f2d564 100644
--- a/lib/sup/modes/thread-view-mode.rb
+++ b/lib/sup/modes/thread-view-mode.rb
@@ -254,7 +254,8 @@ EOS
   end    
 
   def edit_labels
-    reserved_labels = @thread.labels.select { |l| LabelManager::RESERVED_LABELS.include? l }
+    old_labels = @thread.labels
+    reserved_labels = old_labels.select { |l| LabelManager::RESERVED_LABELS.include? l }
     new_labels = BufferManager.ask_for_labels :label, "Labels for thread: ", @thread.labels
 
     return unless new_labels
@@ -262,6 +263,10 @@ EOS
     new_labels.each { |l| LabelManager << l }
     update
     UpdateManager.relay self, :labeled, @thread.first
+    UndoManager.register "labeling thread" do
+      @thread.labels = old_labels
+      UpdateManager.relay self, :labeled, @thread.first
+    end
   end
 
   def toggle_starred
@@ -476,6 +481,10 @@ EOS
     dispatch op do
       @thread.remove_label :inbox
       UpdateManager.relay self, :archived, @thread.first
+      UndoManager.register "archiving 1 thread" do
+        @thread.apply_label :inbox
+        UpdateManager.relay self, :unarchived, @thread.first
+      end
     end
   end
 
@@ -483,6 +492,10 @@ EOS
     dispatch op do
       @thread.apply_label :spam
       UpdateManager.relay self, :spammed, @thread.first
+      UndoManager.register "marking 1 thread as spam" do
+        @thread.remove_label :spam
+        UpdateManager.relay self, :unspammed, @thread.first
+      end
     end
   end
 
@@ -490,6 +503,10 @@ EOS
     dispatch op do
       @thread.apply_label :deleted
       UpdateManager.relay self, :deleted, @thread.first
+      UndoManager.register "deleting 1 thread" do
+        @thread.remove_label :deleted
+        UpdateManager.relay self, :undeleted, @thread.first
+      end
     end
   end
 
-- 
1.5.6.5

-- 
I've decided to go back to school.  Kindergarden.
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk