sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 59f56ec3c096c1d34db7468f23ec86c5d426a762
parent 021db8cd37e1ed595703a109e1029a8e93721324
Author: Gaute Hope <eg@gaute.vetsj.com>
Date:   Mon, 19 May 2014 12:09:58 +0200

Merge branch 'develop'

Diffstat:
M .travis.yml | 1 -
M History.txt | 8 ++++++++
M Rakefile | 11 ++---------
M ReleaseNotes | 4 ++++
M bin/sup-sync | 2 +-
M bin/sup-tweak-labels | 7 ++++++-
M lib/sup/colormap.rb | 6 ++++++
M lib/sup/modes/thread_index_mode.rb | 13 ++++++++++++-
M lib/sup/modes/thread_view_mode.rb | 20 ++++++++++++++++++++
M sup.gemspec | 110 +++++++++++++++++++++++++++++++++++--------------------------------------------
10 files changed, 108 insertions(+), 74 deletions(-)
diff --git a/.travis.yml b/.travis.yml
@@ -2,7 +2,6 @@ language: ruby
 
 rvm:
   - 2.1.1
-  - 2.1.0
   - 2.0.0
   - 1.9.3
 
diff --git a/History.txt b/History.txt
@@ -1,3 +1,11 @@
+== 0.18.0 / 2014-05-19
+
+* new color option, :with_attachment for defining colors for the
+  attachment character.
+* sup-tweak-labels works again (out of service since sync_back).
+* gem building is done through bundler
+* you can now kill a thread using & from thread_view
+
 == 0.17.0 / 2014-04-11
 
 * add continuous scrolling to thread view
diff --git a/Rakefile b/Rakefile
@@ -1,5 +1,6 @@
 require 'rubygems'
 require 'rake/testtask'
+require "bundler/gem_tasks"
 
 Rake::TestTask.new(:test) do |test|
   test.libs << 'test'
@@ -8,12 +9,4 @@ Rake::TestTask.new(:test) do |test|
 end
 task :default => :test
 
-require 'rubygems/package_task'
-# For those who don't have `rubygems-bundler` installed
-load 'sup.gemspec' unless defined? Redwood::Gemspec
-
-Gem::PackageTask.new(Redwood::Gemspec) do |pkg|
-  pkg.need_tar = true
-end
-
-task :travis => [:test, :gem]
+task :travis => [:test, :build]
diff --git a/ReleaseNotes b/ReleaseNotes
@@ -1,3 +1,7 @@
+Release 0.18.0:
+
+sup-tweak-labels works again. new color options and some bug fixes.
+
 Release 0.17.0:
 
 Bugfixes and new option for continous scrolling as well as an option for
diff --git a/bin/sup-sync b/bin/sup-sync
@@ -175,7 +175,7 @@ begin
           puts "Changing flags for #{source}##{m.source_info} from #{old_m.labels} to #{m.labels}" if opts[:verbose]
           num_updated += 1
         end
-      else fail
+      else fail "sup-sync cannot handle :update's"
       end
 
       if Time.now - last_info_time > PROGRESS_UPDATE_INTERVAL
diff --git a/bin/sup-tweak-labels b/bin/sup-tweak-labels
@@ -51,6 +51,7 @@ EOS
   opt :very_verbose, "Print message names and subjects as they're processed."
   opt :all_sources, "Scan over all sources.", :short => :none
   opt :dry_run, "Don't actually modify the index. Probably only useful with --verbose.", :short => "-n"
+  opt :no_sync_back, "Do not sync back to the original Maildir."
   opt :version, "Show version information", :short => :none
 end
 opts[:verbose] = true if opts[:very_verbose]
@@ -63,6 +64,7 @@ Trollop::die "nothing to do: no labels to add or remove" if add_labels.empty? &&
 Redwood::start
 index = Redwood::Index.init
 index.lock_interactively or exit
+
 begin
   index.load
 
@@ -106,7 +108,10 @@ begin
       puts "From #{m.from}, subject: #{m.subj}" if opts[:very_verbose]
       puts "#{m.id}: {#{old_labels.to_a.join ','}} => {#{m.labels.to_a.join ','}}" if opts[:verbose]
       puts if opts[:very_verbose]
-      index.update_message_state m unless opts[:dry_run]
+      unless opts[:dry_run]
+        index.update_message_state [m, false]
+        m.sync_back unless opts[:no_sync_back]
+      end
     end
 
     if Time.now - last_info_time > 60
diff --git a/lib/sup/colormap.rb b/lib/sup/colormap.rb
@@ -50,6 +50,7 @@ class Colormap
     :quote => { :fg => "yellow", :bg => "default" },
     :sig => { :fg => "yellow", :bg => "default" },
     :to_me => { :fg => "green", :bg => "default" },
+    :with_attachment => { :fg => "green", :bg => "default" },
     :starred => { :fg => "yellow", :bg => "default", :attrs => ["bold"] },
     :starred_patina => { :fg => "yellow", :bg => "green", :attrs => ["bold"] },
     :alternate_starred_patina => { :fg => "yellow", :bg => "blue", :attrs => ["bold"] },
@@ -190,6 +191,11 @@ class Colormap
       Redwood::load_yaml_obj Redwood::COLOR_FN
     end
 
+    ## Set attachment sybmol to sane default for existing colorschemes
+    if user_colors and user_colors.has_key? :to_me 
+      user_colors[:with_attachment] = user_colors[:to_me] unless user_colors.has_key? :with_attachment
+    end
+
     Colormap::DEFAULT_COLORS.merge(user_colors||{}).each_pair do |k, v|
       fg = begin
         Ncurses.const_get "COLOR_#{v[:fg].to_s.upcase}"
diff --git a/lib/sup/modes/thread_index_mode.rb b/lib/sup/modes/thread_index_mode.rb
@@ -236,6 +236,13 @@ EOS
     update
   end
 
+  def handle_killed_update sender, m
+    t = @ts_mutex.synchronize { @ts.thread_for m }
+    return unless t
+    hide_thread t
+    update
+  end
+
   def handle_spammed_update sender, m
     t = @ts_mutex.synchronize { @ts.thread_for m }
     return unless t
@@ -247,6 +254,10 @@ EOS
     add_or_unhide m
   end
 
+  def handle_unkilled_update sender, m
+    add_or_unhide m
+  end
+
   def undo
     UndoManager.undo
   end
@@ -979,7 +990,7 @@ protected
       from +
       [
       [:size_widget_color, size_widget_text],
-      [:to_me_color, t.labels.member?(:attachment) ? "@" : " "],
+      [:with_attachment_color , t.labels.member?(:attachment) ? "@" : " "],
       [:to_me_color, directly_participated ? ">" : (participated ? '+' : " ")],
     ] +
       (t.labels - @hidden_labels).sort_by {|x| x.to_s}.map {
diff --git a/lib/sup/modes/thread_view_mode.rb b/lib/sup/modes/thread_view_mode.rb
@@ -78,11 +78,13 @@ EOS
 
     k.add :archive_and_next, "Archive this thread, kill buffer, and view next", 'a'
     k.add :delete_and_next, "Delete this thread, kill buffer, and view next", 'd'
+    k.add :kill_and_next, "Kill this thread, kill buffer, and view next", '&'
     k.add :toggle_wrap, "Toggle wrapping of text", 'w'
 
     k.add_multi "(a)rchive/(d)elete/mark as (s)pam/mark as u(N)read:", '.' do |kk|
       kk.add :archive_and_kill, "Archive this thread and kill buffer", 'a'
       kk.add :delete_and_kill, "Delete this thread and kill buffer", 'd'
+      kk.add :kill_and_kill, "Kill this thread and kill buffer", '&'
       kk.add :spam_and_kill, "Mark this thread as spam and kill buffer", 's'
       kk.add :unread_and_kill, "Mark this thread as unread and kill buffer", 'N'
       kk.add :do_nothing_and_kill, "Just kill this buffer", '.'
@@ -91,6 +93,7 @@ EOS
     k.add_multi "(a)rchive/(d)elete/mark as (s)pam/mark as u(N)read/do (n)othing:", ',' do |kk|
       kk.add :archive_and_next, "Archive this thread, kill buffer, and view next", 'a'
       kk.add :delete_and_next, "Delete this thread, kill buffer, and view next", 'd'
+      kk.add :kill_and_next, "Kill this thread, kill buffer, and view next", '&'
       kk.add :spam_and_next, "Mark this thread as spam, kill buffer, and view next", 's'
       kk.add :unread_and_next, "Mark this thread as unread, kill buffer, and view next", 'N'
       kk.add :do_nothing_and_next, "Kill buffer, and view next", 'n', ','
@@ -99,6 +102,7 @@ EOS
     k.add_multi "(a)rchive/(d)elete/mark as (s)pam/mark as u(N)read/do (n)othing:", ']' do |kk|
       kk.add :archive_and_prev, "Archive this thread, kill buffer, and view previous", 'a'
       kk.add :delete_and_prev, "Delete this thread, kill buffer, and view previous", 'd'
+      kk.add :kill_and_prev, "Kill this thread, kill buffer, and view previous", '&'
       kk.add :spam_and_prev, "Mark this thread as spam, kill buffer, and view previous", 's'
       kk.add :unread_and_prev, "Mark this thread as unread, kill buffer, and view previous", 'N'
       kk.add :do_nothing_and_prev, "Kill buffer, and view previous", 'n', ']'
@@ -581,18 +585,21 @@ EOS
   def archive_and_kill; archive_and_then :kill end
   def spam_and_kill; spam_and_then :kill end
   def delete_and_kill; delete_and_then :kill end
+  def kill_and_kill; kill_and_then :kill end
   def unread_and_kill; unread_and_then :kill end
   def do_nothing_and_kill; do_nothing_and_then :kill end
 
   def archive_and_next; archive_and_then :next end
   def spam_and_next; spam_and_then :next end
   def delete_and_next; delete_and_then :next end
+  def kill_and_next; kill_and_then :next end
   def unread_and_next; unread_and_then :next end
   def do_nothing_and_next; do_nothing_and_then :next end
 
   def archive_and_prev; archive_and_then :prev end
   def spam_and_prev; spam_and_then :prev end
   def delete_and_prev; delete_and_then :prev end
+  def kill_and_prev; kill_and_then :prev end
   def unread_and_prev; unread_and_then :prev end
   def do_nothing_and_prev; do_nothing_and_then :prev end
 
@@ -635,6 +642,19 @@ EOS
     end
   end
 
+  def kill_and_then op
+    dispatch op do
+      @thread.apply_label :killed
+      UpdateManager.relay self, :killed, @thread.first
+      Index.save_thread @thread
+      UndoManager.register "killed 1 thread" do
+        @thread.remove_label :killed
+        Index.save_thread @thread
+        UpdateManager.relay self, :unkilled, @thread.first
+      end
+    end
+  end
+
   def unread_and_then op
     dispatch op do
       @thread.apply_label :unread
diff --git a/sup.gemspec b/sup.gemspec
@@ -1,67 +1,55 @@
-lib = File.expand_path("../lib", __FILE__)
-$:.unshift(lib) unless $:.include?(lib)
+$:.push File.expand_path("../lib", __FILE__)
 
 require 'sup/version'
 
-# Files
-SUP_EXECUTABLES = %w(sup sup-add sup-config sup-dump sup-import-dump
-  sup-recover-sources sup-sync sup-sync-back-maildir sup-tweak-labels
-  sup-psych-ify-config-files)
-SUP_EXTRA_FILES = %w(CONTRIBUTORS README.md LICENSE History.txt ReleaseNotes)
-SUP_FILES =
-  SUP_EXTRA_FILES +
-  SUP_EXECUTABLES.map { |f| "bin/#{f}" } +
-  Dir["lib/**/*.rb"]
-
-
-module Redwood
-  Gemspec = Gem::Specification.new do |s|
-    s.name = "sup"
-    s.version = ENV["REL"] || (::Redwood::VERSION == "git" ? "999" : ::Redwood::VERSION)
-    s.date = Time.now.strftime "%Y-%m-%d"
-    s.authors = ["William Morgan", "Gaute Hope", "Hamish Downer", "Matthieu Rakotojaona"]
-    s.email   = "sup-talk@rubyforge.org"
-    s.summary = "A console-based email client with the best features of GMail, mutt and Emacs"
-    s.homepage = "http://supmua.org"
-    s.description = <<-DESC
-      Sup is a console-based email client for people with a lot of email.
-
-      * GMail-like thread-centered archiving, tagging and muting
-      * Handling mail from multiple mbox and Maildir sources
-      * Blazing fast full-text search with a rich query language
-      * Multiple accounts - pick the right one when sending mail
-      * Ruby-programmable hooks
-      * Automatically tracking recent contacts
+Gem::Specification.new do |s|
+  s.name = "sup"
+  s.version = ENV["REL"] || (::Redwood::VERSION == "git" ? "999" : ::Redwood::VERSION)
+  s.date = Time.now.strftime "%Y-%m-%d"
+  s.authors = ["William Morgan", "Gaute Hope", "Hamish Downer", "Matthieu Rakotojaona"]
+  s.email   = "sup-talk@rubyforge.org"
+  s.summary = "A console-based email client with the best features of GMail, mutt and Emacs"
+  s.homepage = "http://supmua.org"
+  s.license = 'GPL-2'
+  s.description = <<-DESC
+    Sup is a console-based email client for people with a lot of email.
+
+    * GMail-like thread-centered archiving, tagging and muting
+    * Handling mail from multiple mbox and Maildir sources
+    * Blazing fast full-text search with a rich query language
+    * Multiple accounts - pick the right one when sending mail
+    * Ruby-programmable hooks
+    * Automatically tracking recent contacts
 DESC
-    s.license = 'GPL-2'
-    # TODO: might want to add index migrating script here, too
-    s.post_install_message = <<-EOF
+  s.post_install_message = <<-EOF
 SUP: If you are upgrading Sup from before version 0.14.0: Please
-     run `sup-psych-ify-config-files` to migrate from 0.13.
-
-     Check https://github.com/sup-heliotrope/sup/wiki/Migration-0.13-to-0.14
-     for more detailed and up-to-date instructions.
-    EOF
-    s.files = SUP_FILES
-    s.executables = SUP_EXECUTABLES
-
-    s.required_ruby_version = '>= 1.9.3'
-
-    s.add_runtime_dependency "xapian-ruby", "~> 1.2.15"
-    s.add_runtime_dependency "ncursesw", "~> 1.4.0"
-    s.add_runtime_dependency "rmail-sup", "~> 1.0.1"
-    s.add_runtime_dependency "highline"
-    s.add_runtime_dependency "trollop", ">= 1.12"
-    s.add_runtime_dependency "lockfile"
-    s.add_runtime_dependency "mime-types", "~> 1.0"
-    s.add_runtime_dependency "locale", "~> 2.0"
-    s.add_runtime_dependency "chronic", "~> 0.9.1"
-    s.add_runtime_dependency "unicode", "~> 0.4.4"
-
-    s.add_development_dependency "bundler", "~> 1.3"
-    s.add_development_dependency "rake"
-    s.add_development_dependency "minitest", "~> 4.7"
-    s.add_development_dependency "rr", "~> 1.0.5"
-    s.add_development_dependency "gpgme", ">= 2.0.2"
-  end
+   run `sup-psych-ify-config-files` to migrate from 0.13.
+
+   Check https://github.com/sup-heliotrope/sup/wiki/Migration-0.13-to-0.14
+   for more detailed and up-to-date instructions.
+  EOF
+
+  s.files         = `git ls-files -z`.split("\x0")
+  s.executables   = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
+  s.test_files    = s.files.grep(%r{^(test|spec|features)/})
+  s.require_paths = ["lib"]
+
+  s.required_ruby_version = '>= 1.9.3'
+
+  s.add_runtime_dependency "xapian-ruby", "~> 1.2.15"
+  s.add_runtime_dependency "ncursesw", "~> 1.4.0"
+  s.add_runtime_dependency "rmail-sup", "~> 1.0.1"
+  s.add_runtime_dependency "highline"
+  s.add_runtime_dependency "trollop", ">= 1.12"
+  s.add_runtime_dependency "lockfile"
+  s.add_runtime_dependency "mime-types", "~> 1.0"
+  s.add_runtime_dependency "locale", "~> 2.0"
+  s.add_runtime_dependency "chronic", "~> 0.9.1"
+  s.add_runtime_dependency "unicode", "~> 0.4.4"
+
+  s.add_development_dependency "bundler", "~> 1.3"
+  s.add_development_dependency "rake"
+  s.add_development_dependency "minitest", "~> 4.7"
+  s.add_development_dependency "rr", "~> 1.0.5"
+  s.add_development_dependency "gpgme", ">= 2.0.2"
 end