From: nicolas.pouillard@gmail.com (Nicolas Pouillard)
Subject: [sup-talk] [PATCH] Resync listable_labels and applyable_labels with reality
Date: Mon, 16 Mar 2009 19:40:09 +0100 [thread overview]
Message-ID: <1237228801-sup-301@ausone.local> (raw)
Resent...
The listable_labels method listed all labels except unread
which seems an unneeded complication/restriction, so it's
renamed to all_labels. The applyable_labels was in fact
user-defined labels so it's renamed to user_defined_labels.
---
bin/sup | 2 +-
lib/sup/buffer.rb | 4 +++-
lib/sup/label.rb | 13 +++++--------
lib/sup/modes/label-list-mode.rb | 4 ++--
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/bin/sup b/bin/sup
index 152c42c..e82d1ce 100644
--- a/bin/sup
+++ b/bin/sup
@@ -237,7 +237,7 @@ begin
when :search_unread
SearchResultsMode.spawn_from_query "is:unread"
when :list_labels
- labels = LabelManager.listable_labels.map { |l| LabelManager.string_for l }
+ labels = LabelManager.all_labels.map { |l| LabelManager.string_for l }
user_label = bm.ask_with_completions :label, "Show threads with label (enter for listing): ", labels
unless user_label.nil?
if user_label.empty?
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index 0447f61..5d0b7eb 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -478,7 +478,9 @@ EOS
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 }
+ # here I would prefer to give more control and allow all_labels instead of
+ # user_defined_labels only
+ applyable_labels = (LabelManager.user_defined_labels - forbidden_labels).map { |l| LabelManager.string_for l }.sort_by { |s| s.downcase }
answer = ask_many_with_completions domain, question, applyable_labels, default
diff --git a/lib/sup/label.rb b/lib/sup/label.rb
index 70a26ea..e63db9e 100644
--- a/lib/sup/label.rb
+++ b/lib/sup/label.rb
@@ -7,9 +7,6 @@ class LabelManager
## add/remove these via normal label mechanisms.
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, :attachment ]
-
## labels that will typically be hidden from the user
HIDDEN_RESERVED_LABELS = [ :starred, :unread, :attachment ]
@@ -28,18 +25,18 @@ class LabelManager
self.class.i_am_the_instance self
end
- ## all listable (just user-defined at the moment) labels, ordered
+ ## all labels user-defined and system, ordered
## nicely and converted to pretty strings. use #label_for to recover
## the original label.
- def listable_labels
+ def all_labels
## uniq's only necessary here because of certain upgrade issues
- (LISTABLE_RESERVED_LABELS + @labels.keys).uniq
+ (RESERVED_LABELS + @labels.keys).uniq
end
- ## all apply-able (user-defined and system listable) labels, ordered
+ ## all user-defined labels, ordered
## nicely and converted to pretty strings. use #label_for to recover
## the original label.
- def applyable_labels
+ def user_defined_labels
@labels.keys
end
diff --git a/lib/sup/modes/label-list-mode.rb b/lib/sup/modes/label-list-mode.rb
index 132b654..a35d110 100644
--- a/lib/sup/modes/label-list-mode.rb
+++ b/lib/sup/modes/label-list-mode.rb
@@ -48,12 +48,12 @@ protected
def regen_text
@text = []
- labels = LabelManager.listable_labels
+ labels = LabelManager.all_labels
counts = labels.map do |label|
string = LabelManager.string_for label
total = Index.num_results_for :label => label
- unread = Index.num_results_for :labels => [label, :unread]
+ unread = (label == :unread)? total : Index.num_results_for(:labels => [label, :unread])
[label, string, total, unread]
end.sort_by { |l, s, t, u| s.downcase }
--
Nicolas Pouillard
next reply other threads:[~2009-03-16 18:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-16 18:40 Nicolas Pouillard [this message]
2009-03-29 16:30 ` William Morgan
2009-03-29 16:53 ` Nicolas Pouillard
-- strict thread matches above, loose matches on Subject: below --
2009-03-16 18:37 Nicolas Pouillard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1237228801-sup-301@ausone.local \
--to=nicolas.pouillard@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox