sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 582e97faf70e41caa65109ac8bdc1c7ecdecd718
parent 1bc1e724993ab29478abb45e45ee381df547da2b
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Sun,  7 Mar 2010 13:18:36 -0800

Merge branch 'mentions-attachments-hook'

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

Diffstat:
M lib/sup/modes/edit-message-mode.rb | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
@@ -40,6 +40,16 @@ Return value:
 	none
 EOS
 
+  HookManager.register "mentions-attachments", <<EOS
+Detects if given message mentions attachments the way it is probable
+that there should be files attached to the message.
+Variables:
+	header: a hash of headers. See 'signature' hook for documentation.
+	body: an array of lines of body text.
+Return value:
+	True if attachments are mentioned.
+EOS
+
   HookManager.register "crypto-mode", <<EOS
 Modifies cryptography settings based on header and message content, before
 editing a new message. This can be used to set, for example, default cryptography
@@ -459,7 +469,11 @@ private
   end
 
   def mentions_attachments?
-    @body.any? { |l| l =~ /^[^>]/ && l =~ /\battach(ment|ed|ing|)\b/i }
+    if HookManager.enabled? "mentions-attachments"
+      HookManager.run "mentions-attachments", :header => @header, :body => @body
+    else
+      @body.any? {  |l| l =~ /^[^>]/ && l =~ /\battach(ment|ed|ing|)\b/i }
+    end
   end
 
   def top_posting?