sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit c733472323bef3f9ba346c8507251de1a432390b
parent 44336aa8ce39ea0769ad03ec3fac483ddc0e855b
Author: Tero Tilus <tero@tilus.net>
Date:   Sat, 10 Oct 2009 10:21:33 +0300

moved deriving the cmd for bouncing to Account and fixed a bug in it

The default sendmail command used for bouncing mail was derived from
Account#sendmail in ThreadViewMode#bounce.  Moved it to
Account#bounce_sendmail.  Part of work towards more DRY mail bouncing
within mark-as-spam hook. The code also had a bug, "$1" (instead of $1
or "#{$1}").  Fixed it.

Signed-off-by: Tero Tilus 

Diffstat:
M lib/sup/account.rb | 11 +++++++++++
M lib/sup/modes/thread-view-mode.rb | 7 +------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/sup/account.rb b/lib/sup/account.rb
@@ -10,6 +10,17 @@ class Account < Person
     @sendmail = h[:sendmail]
     @signature = h[:signature]
   end
+
+  # Default sendmail command for bouncing mail,
+  # deduced from #sendmail
+  def bounce_sendmail
+    sendmail.sub(/\s(\-(ti|it|t))\b/) do |match|
+      case $1
+      when '-t' then ''
+      else ' -i'
+      end
+    end
+  end
 end
 
 class AccountManager
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -202,12 +202,7 @@ EOS
     m = @message_lines[curpos] or return
     to = BufferManager.ask_for_contacts(:people, "Bounce To: ") or return
 
-    defcmd = AccountManager.default_account.sendmail.sub(/\s(\-(ti|it|t))\b/) do |match|
-      case "$1"
-        when '-t' then ''
-        else ' -i'
-      end
-    end
+    defcmd = AccountManager.default_account.bounce_sendmail
 
     cmd = case (hookcmd = HookManager.run "bounce-command", :from => m.from, :to => to)
           when nil, /^$/ then defcmd