]> git.cworth.org Git - sup/commitdiff
check for missing attachments and top-posting
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 20 Aug 2007 02:05:00 +0000 (02:05 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 20 Aug 2007 02:05:00 +0000 (02:05 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@534 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup.rb
lib/sup/modes/edit-message-mode.rb

index 7de719a1602722fe7b315a7870dce8644816f607..7edc35bbf6f6bcdf8b8e4a2830434a3d749e5ae7 100644 (file)
@@ -195,7 +195,9 @@ else
     :thread_by_subject => false,
     :edit_signature => false,
     :ask_for_cc => true,
-    :ask_for_bcc => false
+    :ask_for_bcc => false,
+    :confirm_no_attachments => true,
+    :confirm_top_posting => true,
   }
   begin
     FileUtils.mkdir_p Redwood::BASE_DIR
index 56acd4fffed05f3e8db01f5ae65a2a980a11a765..d8f2c5705c7c9ca7a3615f63200d0e75544a4733 100644 (file)
@@ -188,6 +188,8 @@ protected
 
   def send_message
     return unless edited? || BufferManager.ask_yes_or_no("Message unedited. Really send?")
+    return unless $config[:confirm_no_attachments] && mentions_attachments? && @attachments.size == 0 && BufferManager.ask_yes_or_no("You haven't added any attachments. Really send?")#" stupid ruby-mode
+    return unless $config[:confirm_top_posting] && top_posting? && BufferManager.ask_yes_or_no("You're top posting. That makes you a bad person. Really send?") #" stupid ruby-mode
 
     date = Time.now
     from_email = 
@@ -276,6 +278,14 @@ EOS
 
 private
 
+  def mentions_attachments?
+    @body.any? { |l| l =~ /^[^>]/ && l =~ /\battach(ment|ed|ing|)\b/i }
+  end
+
+  def top_posting?
+    @body.join =~ /(\S+)\s*Excerpts from /
+  end
+
   def sig_lines
     p = PersonManager.person_for @header["From"]
     sigfn = (AccountManager.account_for(p.email) ||