--- raggle.backup	2010-10-25 08:08:07.626468032 -0400
+++ raggle	2010-10-25 08:18:56.812190806 -0400
@@ -457,16 +457,16 @@
         HTML_ENTITY_LUT[m]
       else
         case m
-        when 'amp':   '&'
-        when 'nbsp'   ' '
-        when /^quot$/ni:  '"'
-        when /^lt$/ni:    '<'
-        when /^gt$/ni:    '>'
-        when /^copy/:     '(c)'
-        when /^trade/:    '(tm)'
-        when /^#8212$/n:  ","
-        when /^#8217$/n:  "'"
-        when /^#8218$/n:  ","
+        when 'amp'      then  '&'
+        when 'nbsp'     then  ' '
+        when /^quot$/ni then  '"'
+        when /^lt$/ni   then  '<'
+        when /^gt$/ni   then  '>'
+        when /^copy/    then  '(c)'
+        when /^trade/   then  '(tm)'
+        when /^#8212$/n then  ","
+        when /^#8217$/n then  "'"
+        when /^#8218$/n then  ","
         when /^#(\d+)$/n
           r = $1.to_i # Integer() interprets leading zeros as octal
           if !r.between?(0, 255) && munge_uni
@@ -474,7 +474,7 @@
           else
             r.chr
           end
-        when /^#x([0-9a-f]+)$/ni
+        when /^#x([0-9a-f]+)$/ni then
           r = $1.hex
           if !r.between?(0, 255) && munge_uni
             UNICODE_LUT[r] ? UNICODE_LUT[r] : munge_str
@@ -915,7 +915,7 @@
         Parser::each_token(@source) do |token, data, attributes|
         #puts "C: #{@context[-1]} T: #{token} D: <#{data}> L: #{@lines.inspect}"
         case token
-        when :TEXT
+        when :TEXT then
           if @context[-1] == :in_pre
             tmp = data.split("\n", -1)
             if @lines[-1]
@@ -925,13 +925,13 @@
           else
             reflow_text(data)
           end
-        when :START_TAG
+        when :START_TAG then
           @current_attributes = attributes
           tag = TAG_SET[data]
           next unless tag
           context_enter(@context, tag)
           call_actions(tag, :start)
-        when :END_TAG
+        when :END_TAG then
           tag = TAG_SET[data]
           next unless tag
           context_exit(@context, tag)
@@ -1146,7 +1146,8 @@
             max_items = outline.attributes['max_items'] || nil
             priority = outline.attributes['priority'].to_i || $config['default_feed_priority']
             # the following properties take effect unless overridden on CLI
-            if outline.attributes['refresh']: opml_refresh = outline.attributes['refresh'].to_i 
+            if outline.attributes['refresh']
+              opml_refresh = outline.attributes['refresh'].to_i 
             else opml_refresh = nil; end  # fixes clobberation
             frefresh = refresh || opml_refresh || $config['default_feed_refresh']
             fsave_items = save_items || outline.attributes['save_items'] || false
@@ -1185,7 +1186,8 @@
         raise if $wins
         die "Parsing #{file_name} failed: #{parse_err.message}" unless $wins
       rescue => err
-        if $wins: Interfaces::NcursesInterface::set_status($config['msg_bad_uri'])
+        if $wins
+          Interfaces::NcursesInterface::set_status($config['msg_bad_uri'])
         else die err.message; end
       end
     end
@@ -1222,7 +1224,8 @@
           raise "Couldn't open output file \"#{file_name}\"."
         end
       rescue => err
-        if $wins: Interfaces::NcursesInterface::set_status($config['msg_bad_uri'])
+        if $wins
+          Interfaces::NcursesInterface::set_status($config['msg_bad_uri'])
         else die err.message; end
       end
     end
@@ -2010,53 +2013,53 @@
       begin
         gopts.each do |opt, arg|
           case opt
-            when '--add'
+            when '--add' then
               ret['mode'] = 'add'
               ret['url'] = arg if arg && arg.size > 0
-            when '--edit'
+            when '--edit' then
               ret['mode'] = 'edit'
               ret['id'] = arg.to_i
-            when'--delete'
+            when'--delete' then
               ret['mode'] = 'delete'
               ret['id'] = arg.to_i
-            when '--invalidate'
+            when '--invalidate' then
               ret['mode'] = 'invalidate'
               ret['id'] = arg.to_i
-            when '--update'
+            when '--update' then
               ret['mode'] = 'update'
               ret['id'] = (arg && (arg != 'all')) ? arg.to_i : 'all'
-            when '--config':  $config['config_path'] = arg
-            when '--force':   ret['force'] = true
-            when '--list':    ret['mode'] = 'list'
-            when '--title':   ret['title'] = arg
-            when '--url':     ret['url'] = arg
-            when '--refresh': ret['refresh'] = arg.to_i
-            when '--version'
+            when '--config'  then $config['config_path'] = arg
+            when '--force'   then ret['force'] = true
+            when '--list'    then ret['mode'] = 'list'
+            when '--title'   then ret['title'] = arg
+            when '--url'     then ret['url'] = arg
+            when '--refresh' then ret['refresh'] = arg.to_i
+            when '--version' then
               puts "Raggle v#$VERSION"
               exit(0)
-            when '--priority':      ret['priority'] = arg.to_i
-            when '--purge':         ret['mode'] = 'purge'
-            when '--sort'
+            when '--priority' then ret['priority'] = arg.to_i
+            when '--purge'    then ret['mode'] = 'purge'
+            when '--sort' then
               ret['mode'] = 'sort'
-            when '--lock-title':    ret['lock_title?'] = true
-            when '--unlock-title':  ret['lock_title?'] = false
-            when '--save-items':    ret['save_items?'] = true
-            when '--max'
+            when '--lock-title'   then ret['lock_title?'] = true
+            when '--unlock-title' then ret['lock_title?'] = false
+            when '--save-items'   then ret['save_items?'] = true
+            when '--max' then
               ret['max_items'] = arg.to_i
               ret['save_items?'] = true if ret['max_items'] > 0
-            when '--unsave-items':  ret['save_items?'] = false
-            when '--verbose':       $config['verbose'] = true
-            when '--import-opml'
+            when '--unsave-items' then ret['save_items?'] = false
+            when '--verbose'      then $config['verbose'] = true
+            when '--import-opml' then
               ret['mode'] = 'import_opml'
               ret['opml_file'] = arg
-            when '--export-opml'
+            when '--export-opml' then
               ret['mode'] = 'export_opml'
               ret['opml_file'] = arg
-            when '--diag':          $config['diag'] = true
-            when '--default-config'
+            when '--diag' then $config['diag'] = true
+            when '--default-config' then
               ret['mode'] = 'default_config'
-            when '--ascii':         ret['ascii'] = true
-            when '--server'
+            when '--ascii' then ret['ascii'] = true
+            when '--server' then
               if $HAVE_LIB['webrick']
                 $config['run_http_server'] = true
                 $config['http_server']['port'] = arg.to_i \
@@ -2064,16 +2067,16 @@
               else
                 die 'Missing WEBrick, can\'t run HTTP Server.'
               end
-            when '--drb-server'
+            when '--drb-server' then
               if $HAVE_LIB['drb']
                 $config['run_drb_server'] = true
               else
                 die "Missing DRb, can't run DRb Server."
               end
-            when '--find'
+            when '--find' then
               ret['mode'] = 'find_feeds'
               ret['find_str'] = arg
-            when '--help'
+            when '--help' then
               CLI::print_usage
           end
         end
@@ -2153,30 +2156,30 @@
     #
     def CLI::handle_mode(opts)
       case opts['mode']
-      when 'list'
+      when 'list' then
         CLI::list_feeds
         exit(0)
-      when 'add'
+      when 'add' then
         added = Engine::add_feed opts
         Engine::save_feed_list if added
         exit(0)
-      when 'delete'
+      when 'delete' then
         Engine::delete_feed opts['id']
         Engine::save_feed_list
         exit(0)
-      when 'invalidate'
+      when 'invalidate' then
         Engine::invalidate_feed opts['id']
         Engine::save_feed_list
         exit(0)
-      when 'edit'
+      when 'edit' then
         Engine::edit_feed opts['id'], opts
         Engine::save_feed_list
         exit(0)
-      when 'sort'
+      when 'sort' then
         Engine::sort_feeds
         Engine::save_feed_list
         exit(0)
-      when 'update'
+      when 'update' then
         # start grab log
         Engine.start_grab_log
 
@@ -2193,21 +2196,21 @@
         Engine::save_feed_list
 
         exit(0)
-      when 'purge'
+      when 'purge' then
         Engine::purge_feed_cache
         exit(0)
-      when 'import_opml'
+      when 'import_opml' then
         OPML::import opts['opml_file'], opts['refresh'], opts['lock_title?'], opts['save_items?'],
           opts['force']
         Engine::save_feed_list
         exit(0)
-      when 'export_opml'
+      when 'export_opml' then
         OPML::export opts['opml_file']
         exit(0)
-      when 'find_feeds'
+      when 'find_feeds' then
         CLI::find_feeds(opts['find_str'])
         exit(0)
-      when 'default_config'
+      when 'default_config' then
         CLI::default_config
         exit(0)
       end
@@ -2333,10 +2336,10 @@
         #
         def Key::close_window
           case $a_win
-          when NcursesInterface::get_win_id('find'): $wins[$a_win].close(true)
-          when NcursesInterface::get_win_id('cat'): $wins[$a_win].close(true)
-          when NcursesInterface::get_win_id('keys'): $wins[$a_win].close(true)
-          when NcursesInterface::get_win_id('edit'): $wins[$a_win].close(true)
+          when NcursesInterface::get_win_id('find') then $wins[$a_win].close(true)
+          when NcursesInterface::get_win_id('cat')  then $wins[$a_win].close(true)
+          when NcursesInterface::get_win_id('keys') then $wins[$a_win].close(true)
+          when NcursesInterface::get_win_id('edit') then $wins[$a_win].close(true)
           end
         end
 
@@ -3404,16 +3407,19 @@
           end
 
           case feedopt  # create options hash to pass to engine
-          when 'save_items?'
-            if str =~ /true/i: newopts = {feedopt => true}
+          when 'save_items?' then
+            if str =~ /true/i
+              newopts = {feedopt => true}
             else newopts = {feedopt => false}; end
-          when 'priority', 'refresh'
+          when 'priority', 'refresh' then
             newopts = {feedopt => str.to_i}
-          when 'max_items'
-            if str =~ /none|nil/i: newopts = {feedopt => nil}
+          when 'max_items' then
+            if str =~ /none|nil/i
+              newopts = {feedopt => nil}
             else newopts = {feedopt => str.to_i}; end
-          when 'category'
-            if str =~ /\bnone\b|\bnil\b/i: newopts = {feedopt => nil}
+          when 'category' then
+            if str =~ /\bnone\b|\bnil\b/i
+              newopts = {feedopt => nil}
             else newopts = {feedopt => str}; end
           else newopts = {feedopt => str}
           end
@@ -3575,7 +3581,7 @@
           item_content = item_content.gsub(/href\s*=\s*["']([^'"]+?)['"]/m) {
             m = $1.dup
             new_url = case m
-              when (/^(\w+):\/\//): m
+              when (/^(\w+):\/\//) then m
               else 
                 # attempt to merge URI with host_uri.  if that fails,
                 # log a warning, then fall back to the unmodified string
@@ -3599,7 +3605,7 @@
           # fix host-relative item URL
           item_url = feed['items'][id]['url'].dup
           item_url = case item_url
-            when (/(\w+):\/\//):  item_url
+            when (/(\w+):\/\//) then  item_url
             else [host_uri, item_url].join('/')
           end
         end
@@ -3665,8 +3671,8 @@
         # get browser command
         cmd = $config['browser_cmd'].map { |cmd_part|
         case cmd_part
-          when /%s/:  cmd_part % url.escape
-          when '${browser}':  $config['browser']
+          when /%s/         then cmd_part % url.escape
+          when '${browser}' then $config['browser']
           else cmd_part
           end
         }
@@ -3833,7 +3839,8 @@
         # if it's not nil, then add it to our list
         added = false
         if url && url.length > 0
-          if title: added = Engine::add_feed({ 'url' => url, 'title' => title })
+          if title
+            added = Engine::add_feed({ 'url' => url, 'title' => title })
           else added = Engine::add_feed({ 'url' => url }); end
           NcursesInterface::populate_feed_win
         else
@@ -3996,7 +4003,7 @@
           end
 
           case bmb[:type]
-          when :csv_file
+          when :csv_file then
             # expand bookmark file path
             path = Engine::expand_str(bmb[:path])
             
@@ -4020,11 +4027,11 @@
               status = $config['msg_bm_file_err'] % [path, err.to_s]
               NcursesInterface::set_status(status)
             end
-          when :exec
+          when :exec then
             fork {
               system(bmb[:path], title, url, tags, ext)
             }
-          when :db
+          when :db then
             # build query
             cols, args = [], []
             { :title  => title,
@@ -4043,7 +4050,7 @@
 
               # database-specific connection stuff
               case bmb[:dbtype]
-              when :mysql
+              when :mysql then
                 unless $HAVE_LIB['mysql']
                   raise $config['msg_bm_db_missing'] % 'Mysql'
                 end
@@ -4052,7 +4059,7 @@
                 db = Mysql::connect(bmb[:host], bmb[:user], bmb[:pass])
                 db.select_db(bmb[:dbname])
                 quote_meth = Mysql::method(:escape_string)
-              when :sqlite
+              when :sqlite then
                 unless $HAVE_LIB['sqlite']
                   raise $config['msg_bm_db_missing'] % 'SQLite'
                 end
@@ -4112,13 +4119,13 @@
           old_key = key
           key = key.gsub(/^KEY_/, '')
           case key
-          when 'DC':        key = 'Delete'
-          when ' ':         key = 'Space'
-          when 'NPAGE':     key = 'Page Down'
-          when 'PPAGE':     key = 'Page Up'
-          when '':        key = 'Control-L'
-          when '	':  key = 'Tab'
-          when /^\d$/:      key = '1-9'
+          when 'DC'    then key = 'Delete'
+          when ' '     then key = 'Space'
+          when 'NPAGE' then key = 'Page Down'
+          when 'PPAGE' then key = 'Page Up'
+          when ''    then key = 'Control-L'
+          when '	' then key = 'Tab'
+          when /^\d$/  then key = '1-9'
           end
           unless key == old_key  # remove cruft if key info updated
             keys[key] = keys[old_key]
@@ -4251,9 +4258,9 @@
         $wins = []
         $config['theme']['window_order'].each { |i|
           case i
-            when /feed/:  cl = NcursesInterface::ListWindow
-            when /item/:  cl = NcursesInterface::ListWindow
-            when /desc/:  cl = NcursesInterface::TextWindow
+            when /feed/ then cl = NcursesInterface::ListWindow
+            when /item/ then cl = NcursesInterface::ListWindow
+            when /desc/ then cl = NcursesInterface::TextWindow
           else
             raise "Unknown window #{i}"
           end
@@ -4285,7 +4292,7 @@
           if r && r.size > 0
             c = Ncurses::getch
             case c
-            when Ncurses::KEY_MOUSE
+            when Ncurses::KEY_MOUSE then
               mev = Ncurses::MEVENT.new
               Ncurses.getmouse(mev)
 
@@ -4388,27 +4395,27 @@
             cat = $1 if req.query_string =~ /category=([^&]+)/
 
             case mode
-              when 'sort'
+              when 'sort' then
                 Engine::sort_feeds
-              when 'invalidate_all'
+              when 'invalidate_all' then
                 Engine::invalidate_feed(-1)
                 $feed_thread.run
-              when 'add'
+              when 'add' then
                 url = $1 if req.query_string =~ /url=(.*)$/
                 added = Engine::add_feed({ 'url' => url })
                 $feed_thread.run if added and $config['update_after_add']
-              when 'delete'
+              when 'delete' then
                 if req.query_string =~ /id=(\d+)/
                   id = $1.to_i
                   Engine::delete_feed(id)
                 end
-              when 'invalidate'
+              when 'invalidate' then
                 if req.query_string =~ /id=(\d+)/
                   id = $1.to_i
                   Engine::invalidate_feed(id)
                   $feed_thread.run 
                 end
-              when 'save_feed_list'
+              when 'save_feed_list' then
                 Engine::save_feed_list
             end
               
