]> git.cworth.org Git - sup/commitdiff
Add new :crypto_default configuration option. next
authorCarl Worth <cworth@cworth.org>
Mon, 28 Sep 2009 22:29:44 +0000 (15:29 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 28 Sep 2009 22:56:35 +0000 (15:56 -0700)
For example, users that want to sign all outgoing messages by default
can set:

:crypto_default: :sign

in ~/.sup/config.yaml. Configuring an invalid value will cause a list
of the valid values to be logged at the "error" level.

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

index aef16d4844e2379d65c910332e4317eb758add19..13c63ed38e17b4a5a91957aadd7417c89480abc1 100644 (file)
@@ -12,7 +12,13 @@ class HorizontalSelector
     @selection = 0
   end
 
-  def set_to val; @selection = @vals.index(val) end
+  def set_to val
+    if @vals.index(val)
+      @selection = @vals.index(val)
+    else
+      error "Invalid option ", val.inspect, " (valid options: ", @vals.inspect, ")"
+    end
+  end
 
   def val; @vals[@selection] end
 
index 8da316fe00593f8085adb167e0200b5a6c650d07..3449503bf1d297e9ebd0bf2a03a6f780ec7bceff 100644 (file)
@@ -89,7 +89,12 @@ EOS
       if CryptoManager.have_crypto?
         HorizontalSelector.new "Crypto:", [:none] + CryptoManager::OUTGOING_MESSAGE_OPERATIONS.keys, ["None"] + CryptoManager::OUTGOING_MESSAGE_OPERATIONS.values
       end
-    add_selector @crypto_selector if @crypto_selector
+    if @crypto_selector
+      if !$config[:crypto_default].nil?
+        @crypto_selector.set_to $config[:crypto_default]
+      end
+      add_selector @crypto_selector
+    end
     
     HookManager.run "before-edit", :header => @header, :body => @body