Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] Resync listable_labels and applyable_labels with reality
@ 2009-03-16 18:37 Nicolas Pouillard
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Pouillard @ 2009-03-16 18:37 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [sup-talk] [PATCH] Resync listable_labels and applyable_labels with reality
  2009-03-29 16:30 ` William Morgan
@ 2009-03-29 16:53   ` Nicolas Pouillard
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Pouillard @ 2009-03-29 16:53 UTC (permalink / raw)


Excerpts from William Morgan's message of Sun Mar 29 18:30:36 +0200 2009:
> Reformatted excerpts from Nicolas Pouillard's message of 2009-03-16:
> > 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.
> 
> I've put this on branch labels-rework and merged into next. I think the
> net effect is that you'll see "unread" when you press L, which is fine.
> 
> If you want to submit a followup patch that allows users to set
> "reserved" labels via 'l', I'd consider applying it. I'm a little
> concerned that you'd see a big list like "unread, inbox, attachment,
> sent" for every single interesting message, but I think I'd rather err
> on the side of giving more power than less.

Indeed, may one can sort them to have the boring ones first?

-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [sup-talk] [PATCH] Resync listable_labels and applyable_labels with reality
  2009-03-16 18:40 Nicolas Pouillard
@ 2009-03-29 16:30 ` William Morgan
  2009-03-29 16:53   ` Nicolas Pouillard
  0 siblings, 1 reply; 4+ messages in thread
From: William Morgan @ 2009-03-29 16:30 UTC (permalink / raw)


Reformatted excerpts from Nicolas Pouillard's message of 2009-03-16:
> 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.

I've put this on branch labels-rework and merged into next. I think the
net effect is that you'll see "unread" when you press L, which is fine.

If you want to submit a followup patch that allows users to set
"reserved" labels via 'l', I'd consider applying it. I'm a little
concerned that you'd see a big list like "unread, inbox, attachment,
sent" for every single interesting message, but I think I'd rather err
on the side of giving more power than less.
-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [sup-talk] [PATCH] Resync listable_labels and applyable_labels with reality
@ 2009-03-16 18:40 Nicolas Pouillard
  2009-03-29 16:30 ` William Morgan
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Pouillard @ 2009-03-16 18:40 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-29 16:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-16 18:37 [sup-talk] [PATCH] Resync listable_labels and applyable_labels with reality Nicolas Pouillard
2009-03-16 18:40 Nicolas Pouillard
2009-03-29 16:30 ` William Morgan
2009-03-29 16:53   ` Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox