From mboxrd@z Thu Jan 1 00:00:00 1970 From: marcus-sup@bar-coded.net (Marcus Williams) Date: Wed, 27 Feb 2008 22:40:57 +0000 Subject: [sup-talk] [PATCH] Additional attachment goodness... Message-ID: <1204151850-sup-9501@tomsk> Adds hidden/reserved attachment label to track attachments. Also adds new flag on thread index mode to denote an attachment '#'. This extends the attachments patch sent earlier and is also against latest 'next'. It will require another sup-sync -all to work against all sources, but attempts to be backwards compatable with non-synced sources. Adds a "has:attachment" search query. --- lib/sup/index.rb | 2 +- lib/sup/label.rb | 6 +++--- lib/sup/message.rb | 1 + lib/sup/modes/thread-index-mode.rb | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/sup/index.rb b/lib/sup/index.rb index 4205f2a..bb70328 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -438,7 +438,7 @@ protected extraopts[:load_deleted] = true if subs =~ /\blabel:deleted\b/ ## gmail style "is" operator - subs = subs.gsub(/\b(is):(\S+)\b/) do + subs = subs.gsub(/\b(is|has):(\S+)\b/) do field, label = $1, $2 case label when "read" diff --git a/lib/sup/label.rb b/lib/sup/label.rb index 4afc0f9..716ef98 100644 --- a/lib/sup/label.rb +++ b/lib/sup/label.rb @@ -5,13 +5,13 @@ class LabelManager ## labels that have special semantics. user will be unable to ## add/remove these via normal label mechanisms. - RESERVED_LABELS = [ :starred, :spam, :draft, :unread, :killed, :sent, :deleted, :inbox ] + RESERVED_LABELS = [ :starred, :spam, :draft, :unread, :killed, :sent, :deleted, :inbox, :attachment ] ## labels which it nonetheless makes sense to search for by - LISTABLE_RESERVED_LABELS = [ :starred, :spam, :draft, :sent, :killed, :deleted, :inbox ] + LISTABLE_RESERVED_LABELS = [ :starred, :spam, :draft, :sent, :killed, :deleted, :inbox, :attachment ] ## labels that will typically be hidden from the user - HIDDEN_RESERVED_LABELS = [ :starred, :unread ] + HIDDEN_RESERVED_LABELS = [ :starred, :unread, :attachment ] def initialize fn @fn = fn diff --git a/lib/sup/message.rb b/lib/sup/message.rb index 480f52c..2be779c 100644 --- a/lib/sup/message.rb +++ b/lib/sup/message.rb @@ -410,6 +410,7 @@ private # attachment (should we allow images with generated names?). # Lowercase the filename because searches are easier that way @attachments.push filename.downcase unless filename =~ /^sup-attachment-/ + add_label :attachment unless filename =~ /^sup-attachment-/ [Chunk::Attachment.new(m.header.content_type, filename, m, sibling_types)] ## otherwise, it's body text diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb index 7a0b815..1b2c0d7 100644 --- a/lib/sup/modes/thread-index-mode.rb +++ b/lib/sup/modes/thread-index-mode.rb @@ -713,7 +713,8 @@ protected from + [ [subj_color, size_widget_text], - [:to_me_color, dp ? " >" : (p ? ' +' : " ")], + [:to_me_color, t.labels.member?(:attachment) ? "#" : " "], + [:to_me_color, dp ? ">" : (p ? '+' : " ")], [subj_color, t.subj + (t.subj.empty? ? "" : " ")], ] + (t.labels - @hidden_labels).map { |label| [:label_color, "+#{label} "] } + -- 1.5.4.1