for next release
----------------
+_ BufferManager#ask_for_labels opens up label-list-mode if empty
+_ tab completion for mid-text cursors
_ forward attachments
_ messages as attachments
_ individual labeling in thread-view-mode
answer || []
end
+ ## returns an array of labels
+ def ask_for_labels domain, question, default_labels, forbidden_labels=[]
+ default = default_labels.join(" ")
+ default += " " unless default.empty?
+
+ applyable_labels = (LabelManager.applyable_labels - forbidden_labels).map { |l| LabelManager.string_for l }.sort_by { |s| s.downcase }
+
+ answer = BufferManager.ask_many_with_completions domain, question, applyable_labels, default
+
+ return unless answer
+
+ user_labels = answer.split(/\s+/).map { |l| l.intern }
+ user_labels.each do |l|
+ if forbidden_labels.include?(l) || LabelManager::RESERVED_LABELS.include?(l)
+ BufferManager.flash "'#{l}' is a reserved label!"
+ return
+ end
+ end
+ user_labels
+ end
+
+
def ask domain, question, default=nil, &block
raise "impossible!" if @asking
@asking = true
thread = @threads[curpos] or return
speciall = (@hidden_labels + LabelManager::RESERVED_LABELS).uniq
keepl, modifyl = thread.labels.partition { |t| speciall.member? t }
- cur_label_string = modifyl.join(" ")
- cur_label_string += " " unless cur_label_string.empty?
- applyable_labels = (LabelManager.applyable_labels - @hidden_labels).map { |l| LabelManager.string_for l }.sort_by { |s| s.downcase }
+ user_labels = BufferManager.ask_for_labels :label, "Labels for thread: ", modifyl, @hidden_labels
- answer = BufferManager.ask_many_with_completions :label, "Labels for thread: ", applyable_labels, cur_label_string
-
- return unless answer
- user_labels = answer.split(/\s+/).map { |l| l.intern }
-
- hl = user_labels.select { |l| speciall.member? l }
- if hl.empty?
- thread.labels = keepl + user_labels
- user_labels.each { |l| LabelManager << l }
- else
- BufferManager.flash "'#{hl}' is a reserved label!"
- end
+ return unless user_labels
+ thread.labels = keepl + user_labels
+ user_labels.each { |l| LabelManager << l }
update_text_for_line curpos
end