diff --git a/lib/sup/modes/thread_index_mode.rb b/lib/sup/modes/thread_index_mode.rb index 71d3fed64..0ea1f7e1e 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,54 @@ 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_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 return unless user_labels