Subject: [sup-devel] [PATCH] wrap quoted text according to wrap preferences

From: adam lazur <[email-masked]>
Date: Thu, 2 Sep 2010 13:49:24 -0700

From: adam lazur <[email-masked]>

Wrap expanded sections of quoted text at a column boundary, just like
sup already does for unquoted text. I split the existing wrapper code
into a utility function.
---
 lib/sup/modes/thread-view-mode.rb |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
index 088529b..f648f8b 100644
--- a/lib/sup/modes/thread-view-mode.rb
+++ b/lib/sup/modes/thread-view-mode.rb
@@ -841,6 +841,19 @@ private
     p.longname + (ContactManager.is_aliased_contact?(p) ? " (#{ContactManager.alias_for p})" : "")
   end
 
+  def maybe_wrap_text lines
+    if @wrap
+      config_width = $config[:wrap_width]
+      if config_width and config_width != 0
+        width = [config_width, buffer.content_width].min
+      else
+        width = buffer.content_width
+      end
+      lines = lines.map { |l| l.chomp.wrap width }.flatten
+    end
+    return lines
+  end
+
   ## todo: check arguments on this overly complex function
   def chunk_to_lines chunk, state, start, depth, parent=nil, color=nil, star_color=nil
     prefix = " " * INDENT_SPACES * depth
@@ -856,23 +869,15 @@ private
     else
       raise "Bad chunk: #{chunk.inspect}" unless chunk.respond_to?(:inlineable?) ## debugging
       if chunk.inlineable?
-        lines = chunk.lines
-        if @wrap
-          config_width = $config[:wrap_width]
-          if config_width and config_width != 0
-            width = [config_width, buffer.content_width].min
-          else
-            width = buffer.content_width
-          end
-          lines = lines.map { |l| l.chomp.wrap width }.flatten
-        end
+        lines = maybe_wrap_text(chunk.lines)
         lines.map { |line| [[chunk.color, "#{prefix}#{line}"]] }
       elsif chunk.expandable?
         case state
         when :closed
           [[[chunk.patina_color, "#{prefix}+ #{chunk.patina_text}"]]]
         when :open
-          [[[chunk.patina_color, "#{prefix}- #{chunk.patina_text}"]]] + chunk.lines.map { |line| [[chunk.color, "#{prefix}#{line}"]] }
+          lines = maybe_wrap_text(chunk.lines)
+          [[[chunk.patina_color, "#{prefix}- #{chunk.patina_text}"]]] + lines.map { |line| [[chunk.color, "#{prefix}#{line}"]] }
         end
       else
         [[[chunk.patina_color, "#{prefix}x #{chunk.patina_text}"]]]
-- 
1.7.2.1

_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: Robin Burchell <[email-masked]>
Date: Sat, 04 Sep 2010 20:40:18 +1000

Hi Adam,

> sup already does for unquoted text. I split the existing wrapper code

Thanks for this. Fixes an annoyance that I really didn't like. I've applied it
to my tree at http://github.com/rburchell/sup/ and so far, so good.

I'll let you know if I see any breakage.

--
Robin Burchell
http://rburchell.com