sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 14ecf325af6d52f29c0f99ae41a99a2d12eae8d5
parent 7e2bb889e617302c82e28d04cb2e0db5d35fbb08
Author: Hamish Downer <dmishd@gmail.com>
Date:   Sun, 19 Jun 2011 23:59:14 +0100

Ensure default options are set

When a new option is added (previous to this commit) then if it is not
in your config.yaml it would default to false, as sup would just load
your config file and not then check default values.

Now the default values (apart from accounts) are set and are merged with
the values from your file (with the file taking precedence of course). So
any new values added will have the intended default.

Diffstat:
M lib/sup.rb | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -262,10 +262,30 @@ EOS
 
   ## set up default configuration file
   def load_config filename
+    default_config = {
+      :editor => ENV["EDITOR"] || "/usr/bin/vim -f -c 'setlocal spell spelllang=en_us' -c 'set filetype=mail'",
+      :thread_by_subject => false,
+      :edit_signature => false,
+      :ask_for_from => false,
+      :ask_for_to => true,
+      :ask_for_cc => true,
+      :ask_for_bcc => false,
+      :ask_for_subject => true,
+      :confirm_no_attachments => true,
+      :confirm_top_posting => true,
+      :jump_to_open_message => true,
+      :discard_snippets_from_encrypted_messages => false,
+      :default_attachment_save_dir => "",
+      :sent_source => "sup://sent",
+      :poll_interval => 300,
+      :wrap_width => 0,
+      :slip_rows => 0,
+      :col_jump => 2
+    }
     if File.exists? filename
       config = Redwood::load_yaml_obj filename
       abort "#{filename} is not a valid configuration file (it's a #{config.class}, not a hash)" unless config.is_a?(Hash)
-      config
+      default_config.merge config
     else
       require 'etc'
       require 'socket'
@@ -289,25 +309,8 @@ EOS
             :gpgkey => ""
           }
         },
-        :editor => ENV["EDITOR"] || "/usr/bin/vim -f -c 'setlocal spell spelllang=en_us' -c 'set filetype=mail'",
-        :thread_by_subject => false,
-        :edit_signature => false,
-        :ask_for_from => false,
-        :ask_for_to => true,
-        :ask_for_cc => true,
-        :ask_for_bcc => false,
-        :ask_for_subject => true,
-        :confirm_no_attachments => true,
-        :confirm_top_posting => true,
-        :jump_to_open_message => true,
-        :discard_snippets_from_encrypted_messages => false,
-        :default_attachment_save_dir => "",
-        :sent_source => "sup://sent",
-        :poll_interval => 300,
-        :wrap_width => 0,
-        :slip_rows => 0,
-        :col_jump => 2
       }
+      config.merge! default_config
       begin
         Redwood::save_yaml_obj config, filename, false, true
       rescue StandardError => e