From d2c4be7f00a9e63d4d26c31c5e179636c7dba7b6 Mon Sep 17 00:00:00 2001 From: ty221 Date: Sat, 3 Jan 2015 00:06:41 +0100 Subject: [PATCH 1/2] Fixed issue 30th from eMBee list --- lib/sup/modes/thread_index_mode.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/sup/modes/thread_index_mode.rb b/lib/sup/modes/thread_index_mode.rb index 71d3fed64..0655584e6 100644 --- a/lib/sup/modes/thread_index_mode.rb +++ b/lib/sup/modes/thread_index_mode.rb @@ -41,6 +41,7 @@ class ThreadIndexMode < LineCursorMode k.add :toggle_new, "Toggle new/read status of all messages in thread", 'N' k.add :edit_labels, "Edit or add labels for a thread", 'l' k.add :edit_message, "Edit message (drafts only)", 'e' + k.add :pure_labels, "Remove all labels from message", 'Z' k.add :toggle_spam, "Mark/unmark thread as spam", 'S' k.add :toggle_deleted, "Delete/undelete thread", 'd' k.add :kill, "Kill thread (never to be seen in inbox again)", '&' @@ -606,6 +607,30 @@ def edit_labels Index.save_thread thread end + def pure_labels + thread = cursor_thread or return + speciall = (@hidden_labels + LabelManager::RESERVED_LABELS).uniq + + old_labels = thread.labels + pos = curpos + + keepl, modifyl = thread.labels.partition { |t| speciall.member? t } + thread.labels = Set.new(keepl) + + update_text_for_line curpos + + UndoManager.register "labeling thread" do + thread.labels = old_labels + update_text_for_line pos + UpdateManager.relay self, :labeled, thread.first + Index.save_thread thread + end + + UpdateManager.relay self, :labeled, thread.first + Index.save_thread thread + end + + def multi_edit_labels threads user_labels = BufferManager.ask_for_labels :labels, "Add/remove labels (use -label to remove): ", [], @hidden_labels return unless user_labels From 5842bbfa3217772385374418cfb160b52f7e169c Mon Sep 17 00:00:00 2001 From: ty221 Date: Sun, 4 Jan 2015 10:49:40 +0100 Subject: [PATCH 2/2] Added possibility to apply command to multithreads --- lib/sup/modes/thread_index_mode.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/sup/modes/thread_index_mode.rb b/lib/sup/modes/thread_index_mode.rb index 0655584e6..0ea1f7e1e 100644 --- a/lib/sup/modes/thread_index_mode.rb +++ b/lib/sup/modes/thread_index_mode.rb @@ -630,6 +630,30 @@ def pure_labels Index.save_thread thread end + def multi_pure_labels threads + + speciall = (@hidden_labels + LabelManager::RESERVED_LABELS).uniq + threads.each do |thread| + old_labels = thread.labels + pos = curpos + + keepl, modifyl = thread.labels.partition { |t| speciall.member? t } + thread.labels = Set.new(keepl) + + update_text_for_line curpos + + UndoManager.register "labeling thread" do + thread.labels = old_labels + update_text_for_line pos + UpdateManager.relay self, :labeled, thread.first + Index.save_thread thread + end + + UpdateManager.relay self, :labeled, thread.first + Index.save_thread thread + end + end + def multi_edit_labels threads user_labels = BufferManager.ask_for_labels :labels, "Add/remove labels (use -label to remove): ", [], @hidden_labels