# File lib/sup/modes/thread-index-mode.rb, line 555
  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

    user_labels.map! { |l| (l.to_s =~ /^-/)? [l.to_s.gsub(/^-?/, '').to_sym, true] : [l, false] }
    hl = user_labels.select { |(l,_)| @hidden_labels.member? l }
    unless hl.empty?
      BufferManager.flash "'#{hl}' is a reserved label!"
      return
    end

    old_labels = threads.map { |t| t.labels.dup }

    threads.each do |t|
      user_labels.each do |(l, to_remove)|
        if to_remove
          t.remove_label l
        else
          t.apply_label l
          LabelManager << l
        end
      end
      UpdateManager.relay self, :labeled, t.first
    end

    regen_text

    UndoManager.register "labeling #{threads.size.pluralize 'thread'}" do
      threads.zip(old_labels).map do |t, old_labels|
        t.labels = old_labels
        UpdateManager.relay self, :labeled, t.first
        Index.save_thread t
      end
      regen_text
    end

    threads.each { |t| Index.save_thread t }
  end