]> git.notmuchmail.org Git - sup/commitdiff
Added quoteline hook for reply mode
authorMarcus Williams <marcus-sup@bar-coded.net>
Tue, 15 Jan 2008 09:40:04 +0000 (09:40 +0000)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 16 Jan 2008 01:23:26 +0000 (17:23 -0800)
This hook allows a user to configure a quote line for replies. The
default is the standard sup quote line "Excerpts from...". Multiple
lines are allowed.

lib/sup/modes/reply-mode.rb

index 04018e3217ac3680511b1e98f1c2be93e26e6475..2d05f15208de168aa7ad1e41dc0a4a75791839cb 100644 (file)
@@ -10,6 +10,14 @@ class ReplyMode < EditMessageMode
     :user => "Customized"
   }
 
+  HookManager.register "quoteline", <<EOS
+Generates a quote line "On 1/4/2007, Joe Bloggs wrote:".
+Variables:
+      message: A message object representing the message being replied to
+Return value:
+  A string containing the text of the quote line (can be multi-line)
+EOS
+
   def initialize message
     @m = message
 
@@ -115,11 +123,16 @@ protected
   end
 
   def reply_body_lines m
-    lines = ["Excerpts from #{@m.from.name}'s message of #{@m.date}:"] + m.quotable_body_lines.map { |l| "> #{l}" }
+    quoteline = HookManager.run("quoteline", :message => m) || default_quoteline(m)
+    lines = quoteline.split("\n") + m.quotable_body_lines.map { |l| "> #{l}" }
     lines.pop while lines.last =~ /^\s*$/
     lines
   end
 
+  def default_quoteline m
+    "Excerpts from #{@m.from.name}'s message of #{@m.date}:"
+  end
+
   def handle_new_text new_header, new_body
     old_header = @headers[@type_selector.val]
     if new_header.size != old_header.size || old_header.any? { |k, v| new_header[k] != v }