From b7e80adc14797014993b983383d6816de3dcb1a7 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 28 Sep 2009 15:29:44 -0700 Subject: [PATCH] Add new :crypto_default configuration option. 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 | 8 +++++++- lib/sup/modes/edit-message-mode.rb | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/sup/horizontal-selector.rb b/lib/sup/horizontal-selector.rb index aef16d4..13c63ed 100644 --- a/lib/sup/horizontal-selector.rb +++ b/lib/sup/horizontal-selector.rb @@ -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 diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb index 8da316f..3449503 100644 --- a/lib/sup/modes/edit-message-mode.rb +++ b/lib/sup/modes/edit-message-mode.rb @@ -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 -- 2.43.0