Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue/idea 30th from eMBee list - added command (and keyboard shortcut), which removes all tags from message #363

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions lib/sup/modes/thread_index_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)", '&'
Expand Down Expand Up @@ -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
Expand Down