Subject: [sup-talk] mime-view

From: [email-masked] (Daniel Wagner)
Date: Mon, 18 Feb 2008 20:01:49 -0800

Hello,

Recently, activating attachments has stopped working.  (I can't be more
specific about when this started; it could have been at the upgrade to
0.4, or weeks after, I'm not sure.)  I get a message like "Couldn't view
the attachment, opening as text", which obviously doesn't work well for
a large variety of attachments.

I verified that sup is detecting the correct mime-type, and that saving
the file to disk and manually running "see" did the Right Thing.  I also
tried adding a hook; the contents of my ~/.sup/hooks/mime-view.rb:

system "xmessage -default okay In the hook."
system "see #{content_type}:#{filename}"
return true

The xmessage window appears.  Still, this is pieced together from the
examples on the wiki and the comments in message-chunks.rb; I have no
real knowledge of Ruby.  Please let me know if I've written nonsense.
In any case, still no luck.

Any clues on what I should do?  Thanks.
~d

---

From: [email-masked] (William Morgan)
Date: Tue, 19 Feb 2008 09:32:57 -0800

Reformatted excerpts from Daniel Wagner's message of 2008-02-18:
> Recently, activating attachments has stopped working.

You know, in reexamining this code, I think there is a silly bug here,
and I think it also caused the weirdness that John Bent was experiencing
a few weeks ago.

Can you try the latest (master/next) from git, or apply the following
patch:

diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
index 0606395..ba8b846 100644
--- a/lib/sup/message-chunks.rb
+++ b/lib/sup/message-chunks.rb
@@ -126,7 +126,7 @@ EOS
       path = write_to_disk
       ret = HookManager.run "mime-view", :content_type => @content_type,
                                          :filename => path
-      view_default! path unless ret
+      ret || view_default!(path)
     end
 
     def write_to_disk

> system "see #{content_type}:#{filename}"

This looks fine, though I would change the last line to just
  $?.success?

which will evaluate to true iff the see command was successful. With
the above change, everything should Just Work (tm).

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (John Bent)
Date: Tue, 19 Feb 2008 10:54:10 -0700

> and I think it also caused the weirdness that John Bent was experiencing
That's a relief.  I thought I was the cause of the weirdness.  This works
great; thanks.  Now my hooks/mime-view.rb (for a mac) is:
###########################
system "open '#{filename}'"
###########################

Thanks all!

John

---

From: [email-masked] (William Morgan)
Date: Tue, 19 Feb 2008 09:56:43 -0800

Reformatted excerpts from John Bent's message of 2008-02-19:
> That's a relief.  I thought I was the cause of the weirdness.  This
> works great; thanks.

Good to hear. Stupidest bug evar. Don't know how I missed it before.

---

From: [email-masked] (William Morgan)
Date: Tue, 19 Feb 2008 10:23:56 -0800

> This looks fine, though I would change the last line to just

Never mind that. Remove the last (and first!) line completely.
Kernel#system returns true iff the command is successful.

---

From: [email-masked] (Daniel Wagner)
Date: Tue, 19 Feb 2008 22:59:16 -0800

> Can you try the latest (master/next) from git, or apply the following

Applied it (by hand), still no joy.  BUT!  On a little more digging, it
looks like the #{} syntax wasn't properly escaping spaces in the
filename.  A few \" later, I'm back in business.

system "see #{content_type}:\"#{filename}\""

Thanks,
~d