]> git.notmuchmail.org Git - sup/commitdiff
add --commit option to spawn a compose-mode upon startup
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 7 Feb 2008 22:12:11 +0000 (14:12 -0800)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 7 Feb 2008 22:12:11 +0000 (14:12 -0800)
bin/sup
lib/sup/modes/compose-mode.rb

diff --git a/bin/sup b/bin/sup
index 9a398b76813857410c78b4db569e4393dbde25c7..84fd77c5d07df9b2fc4f16b09cfa17dced6cfbec 100644 (file)
--- a/bin/sup
+++ b/bin/sup
@@ -36,6 +36,7 @@ EOS
   opt :no_threads, "Turn off threading. Helps with debugging. (Necessarily disables background polling for new messages.)"
   opt :no_initial_poll, "Don't poll for new messages when starting."
   opt :search, "Search for this query upon startup", :type => String
+  opt :compose, "Compose message to this recipient upon startup", :type => String
 end
 
 if $opts[:list_hooks]
@@ -198,6 +199,10 @@ begin
   
   imode.load_threads :num => ibuf.content_height, :when_done => lambda { reporting_thread("poll after loading inbox") { sleep 1; PollManager.poll } unless $opts[:no_threads] || $opts[:no_initial_poll] }
 
+  if $opts[:compose]
+    ComposeMode.spawn_nicely :to_default => $opts[:compose]
+  end
+
   unless $opts[:no_threads]
     PollManager.start
     SuicideManager.start
index f063b92129a9487cf9fc6e2a26b450095d3711e5..7674d7bda63538c5014e4e32aa4740f13203f01f 100644 (file)
@@ -20,7 +20,7 @@ class ComposeMode < EditMessageMode
   end
 
   def self.spawn_nicely opts={}
-    to = opts[:to] || BufferManager.ask_for_contacts(:people, "To: ") or return
+    to = opts[:to] || BufferManager.ask_for_contacts(:people, "To: ", [opts[:to_default]]) or return
     cc = opts[:cc] || (BufferManager.ask_for_contacts(:people, "Cc: ") or return if $config[:ask_for_cc])
     bcc = opts[:bcc] || (BufferManager.ask_for_contacts(:people, "Bcc: ") or return if $config[:ask_for_bcc])
     subj = opts[:subj] || (BufferManager.ask(:subject, "Subject: ") or return if $config[:ask_for_subject])