Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: marcus-sup@bar-coded.net (Marcus Williams)
Subject: [sup-talk] [PATCH] Added quoteline hook for reply mode
Date: Tue, 15 Jan 2008 09:40:04 +0000	[thread overview]
Message-ID: <1200389942-sup-6442@tomsk> (raw)
In-Reply-To: <1200388608-sup-6945@tomsk>

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 |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
index 04018e3..9c4b11d 100644
--- a/lib/sup/modes/reply-mode.rb
+++ b/lib/sup/modes/reply-mode.rb
@@ -9,6 +9,14 @@ class ReplyMode < EditMessageMode
     :list => "Mailing list",
     :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 }
-- 
1.5.3.7



  reply	other threads:[~2008-01-15  9:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-14 12:24 [sup-talk] [PATCH] Added quoteline hook. This allows you to specify how the text above the quoted email should look (Normally 'Excerpts froms...') Marcus Williams
2008-01-15  5:20 ` William Morgan
2008-01-15  9:18   ` Marcus Williams
2008-01-15  9:40     ` Marcus Williams [this message]
2008-01-16  1:31       ` [sup-talk] [PATCH] Added quoteline hook for reply mode William Morgan
2008-01-16 16:32       ` Grant Hollingworth
2008-01-16 16:39         ` Marcus Williams
2008-01-16 21:09           ` William Morgan
2008-01-17 17:49             ` [sup-talk] [PATCH] renamed "quoteline" hook to "attribution" Grant Hollingworth
2008-01-22  2:49               ` William Morgan

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=1200389942-sup-6442@tomsk \
    --to=marcus-sup@bar-coded.net \
    /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