From: Tero Tilus <tero@tilus.net>
To: Sup developers <sup-devel@rubyforge.org>
Subject: Re: [sup-devel] [PATCH] I can haz moar hooks: attachment-mentioned, index-mode-date-widget
Date: Mon, 22 Feb 2010 10:09:24 +0200 [thread overview]
Message-ID: <1266826098-sup-4481@tilus.net> (raw)
In-Reply-To: <1266825994-sup-5466@tilus.net>
[-- Attachment #1: Type: text/plain, Size: 187 bytes --]
Tero Tilus, 2010-02-22 10:07:
> Amended patch attached.
Didn't pass my own test. :D
Better luck this time with the attachment.
--
Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
[-- Attachment #2: 0001-mentions-attachments-hook-to-detect-missing-attachme.patch --]
[-- Type: application/octet-stream, Size: 1423 bytes --]
From ba316e676e02d65022b5fce7cd735cc40393134c Mon Sep 17 00:00:00 2001
From: Tero Tilus <tero@tilus.net>
Date: Mon, 22 Feb 2010 09:53:38 +0200
Subject: [PATCH] mentions-attachments hook to detect missing attachments
---
lib/sup/modes/edit-message-mode.rb | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index 8849271..224c5ae 100644
--- 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
+
attr_reader :status
attr_accessor :body, :header
bool_reader :edited
@@ -444,7 +454,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?
--
1.5.6.5
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
next prev parent reply other threads:[~2010-02-22 8:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1261167840-sup-592@orion>
[not found] ` <1261179239-sup-9258@tilus.net>
[not found] ` <1261246334-sup-1438@masanjin.net>
[not found] ` <1261276156-sup-5510@tilus.net>
[not found] ` <1261402666-sup-8068@masanjin.net>
2010-01-22 1:32 ` Tero Tilus
2010-02-04 7:06 ` Tero Tilus
2010-02-22 7:22 ` Rich Lane
2010-02-22 8:07 ` Tero Tilus
2010-02-22 8:09 ` Tero Tilus [this message]
2010-02-27 8:11 ` Rich Lane
2010-02-27 8:16 ` Rich Lane
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=1266826098-sup-4481@tilus.net \
--to=tero@tilus.net \
--cc=sup-devel@rubyforge.org \
/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