From: wmorgan-sup@masanjin.net (William Morgan)
Subject: [sup-talk] mailcap for os x
Date: Tue, 15 Jan 2008 20:06:01 -0800 [thread overview]
Message-ID: <1200456328-sup-4928@south> (raw)
In-Reply-To: <1200453317-sup-5958@south>
Reformatted excerpts from William Morgan's message of 2008-01-15:
> That's not a problem. There are plenty of hooks that override default
> behavior if they're present, but do nothing if not. The quoteline one
> Marcus just submitted is a good example.
Something like this. Then you can move all the quick_look and
explicit_view stuff in your original email into a mime-view.rb hook.
diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
index 08dcf27..8e5def9 100644
--- 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
--
William <wmorgan-sup at masanjin.net>
prev parent reply other threads:[~2008-01-16 4:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 16:22 Grant Hollingworth
2007-12-27 18:50 ` William Morgan
2008-01-15 16:34 ` Grant Hollingworth
2008-01-16 3:20 ` William Morgan
2008-01-16 3:39 ` William Morgan
2008-01-16 4:06 ` William Morgan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1200456328-sup-4928@south \
--to=wmorgan-sup@masanjin.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox