commit eb37b892d474eec2bec3217d6a96b0cc99cd59f5
parent ee84f2b7cb7192b6bebaea192ff78e024139faf6
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Tue, 22 Jan 2008 12:24:44 -0800
Merge branch 'master' into next
Diffstat:
6 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -398,7 +398,7 @@ EOS
def ask_with_completions domain, question, completions, default=nil
ask domain, question, default do |s|
- completions.select { |x| x =~ /^#{s}/i }.map { |x| [x, x] }
+ completions.select { |x| x =~ /^#{Regexp::escape s}/i }.map { |x| [x, x] }
end
end
@@ -414,7 +414,7 @@ EOS
raise "william screwed up completion: #{partial.inspect}"
end
- completions.select { |x| x =~ /^#{target}/i }.map { |x| [prefix + x, x] }
+ completions.select { |x| x =~ /^#{Regexp::escape target}/i }.map { |x| [prefix + x, x] }
end
end
@@ -423,7 +423,7 @@ EOS
prefix, target = partial.split_on_commas_with_remainder
target ||= prefix.pop || ""
prefix = prefix.join(", ") + (prefix.empty? ? "" : ", ")
- completions.select { |x| x =~ /^#{target}/i }.map { |x| [prefix + x, x] }
+ completions.select { |x| x =~ /^#{Regexp::escape target}/i }.map { |x| [prefix + x, x] }
end
end
@@ -436,7 +436,7 @@ EOS
if dir
[[s.sub(full, dir), "~#{name}"]]
else
- users.select { |u| u =~ /^#{name}/ }.map do |u|
+ users.select { |u| u =~ /^#{Regexp::escape name}/ }.map do |u|
[s.sub("~#{name}", "~#{u}"), "~#{u}"]
end
end
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
@@ -144,7 +144,7 @@ private
def make_id fn
# use 7 digits for the size. why 7? seems nice.
- sprintf("%d%07d", File.mtime(fn), File.size(fn)).to_i
+ sprintf("%d%07d", File.mtime(fn), File.size(fn) % 10000000).to_i
end
def with_file_for id
diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
@@ -53,6 +53,16 @@ Variables:
Return value:
The decoded text of the attachment, or nil if not decoded.
EOS
+
+ HookManager.register "mime-view", <<EOS
+Executes when viewing a MIME attachment, i.e., launching a separate
+viewer program.
+Variables:
+ content_type: the content-type of the attachment
+ filename: the filename of the attachment as saved to disk
+Return value:
+ True if the viewing was successful, false otherwise.
+EOS
#' stupid ruby-mode
## raw_content is the post-MIME-decode content. this is used for
@@ -105,12 +115,18 @@ EOS
def expandable?; !viewable? end
def initial_state; :open end
def viewable?; @lines.nil? end
- def view!
- path = write_to_disk
+ def view_default! path
system "/usr/bin/run-mailcap --action=view #{@content_type}:#{path} > /dev/null 2> /dev/null"
$? == 0
end
+ def view!
+ path = write_to_disk
+ ret = HookManager.run "mime-view", :content_type => @content_type,
+ :filename => path
+ view_default! path unless ret
+ end
+
def write_to_disk
file = Tempfile.new(@filename || "sup-attachment")
file.print @raw_content
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
@@ -402,7 +402,7 @@ private
## otherwise, it's body text
else
body = Message.convert_from m.decode, m.charset if m.body
- text_to_chunks (body || "").normalize_whitespace.split("\n"), encrypted
+ text_to_chunks((body || "").normalize_whitespace.split("\n"), encrypted)
end
end
end
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -145,7 +145,7 @@ EOS
%w(read unread archived starred unstarred).each do |state|
define_method "handle_#{state}_update" do |*a|
- handle_simple_update *a
+ handle_simple_update(*a)
end
end
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -62,7 +62,7 @@ module RMail
end
def charset
- if header.field?("content-type") && header.fetch("content-type") =~ /charset="?(.*?)"?(;|$)/
+ if header.field?("content-type") && header.fetch("content-type") =~ /charset="?(.*?)"?(;|$)/i
$1
end
end