Subject: [sup-talk] [PATCH] run-mailcap fix

From: [email-masked] (Benoît PIERRE)
Date: Sun, 02 Aug 2009 17:23:47 +0200

I use this line in my ~/.mailcap to view HTML attachements in Mutt:

text/html; w3m -dump -T text/html %s | pager; needsterminal; description=HTML Text; nametemplate=%s.html

which doesn't work with Sup. The attached patch fix this by not redirecting
stderr to /dev/null.  It also restores the correct ncurses state (including
arrow keypresses, thanks to Edward Z. Yang recent patch).
-- 
A: Because it destroys the flow of conversation.
Q: Why is top posting dumb?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sup-run-mailcap.patch
Type: application/octet-stream
Size: 704 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090802/1fa7b4f6/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090802/1fa7b4f6/attachment.bin>

---

From: [email-masked] (William Morgan)
Date: Tue, 11 Aug 2009 13:28:46 -0700

Hi Beno?t,

Reformatted excerpts from Beno?t PIERRE's message of 2009-08-02:
> The attached patch fix this by not redirecting stderr to /dev/null.
> It also restores the correct ncurses state (including arrow
> keypresses, thanks to Edward Z. Yang recent patch).

Thanks! Not redirecting stderr to /dev/null is probably fine. But how
about calling BufferManager.shell_out instead?

If you want to submit a proper git commit via git-format-email, I will
be happy to apply it and you can get your name in the illustrious Sup
contributor roster. Otherwise I will make this change for you.
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Benoît PIERRE)
Date: Wed, 12 Aug 2009 00:09:40 +0200

Some programs will fail to work correctly if this is done, like for
example: w3m --dump, to view HTML files.
---
 lib/sup/message-chunks.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
index 0d742d9..4c947e1 100644
--- a/lib/sup/message-chunks.rb
+++ b/lib/sup/message-chunks.rb
@@ -131,7 +131,7 @@ EOS
     def initial_state; :open end
     def viewable?; @lines.nil? end
     def view_default! path
-      cmd = "/usr/bin/run-mailcap --action=view '#{@content_type}:#{path}' 2>/dev/null"
+      cmd = "/usr/bin/run-mailcap --action=view '#{@content_type}:#{path}'"
       Redwood::log "running: #{cmd.inspect}"
       system cmd
       $? == 0
-- 
1.6.3.3

---

From: [email-masked] (Benoît PIERRE)
Date: Wed, 12 Aug 2009 00:09:41 +0200

This ensure ncurses state is correctly restored upon command completion.
---
 lib/sup/message-chunks.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
index 4c947e1..1910abd 100644
--- a/lib/sup/message-chunks.rb
+++ b/lib/sup/message-chunks.rb
@@ -133,7 +133,7 @@ EOS
     def view_default! path
       cmd = "/usr/bin/run-mailcap --action=view '#{@content_type}:#{path}'"
       Redwood::log "running: #{cmd.inspect}"
-      system cmd
+      BufferManager.shell_out(cmd)
       $? == 0
     end
 
-- 
1.6.3.3

---

From: [email-masked] (William Morgan)
Date: Fri, 14 Aug 2009 13:17:38 -0700

> This ensure ncurses state is correctly restored upon command completion.

Both patches applies to branch run-mailcap-fixes, merged into next.
Thanks!
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Benoît PIERRE)
Date: Sat, 15 Aug 2009 00:37:21 +0200

> Both patches applies to branch run-mailcap-fixes, merged into next.

Great!

One problem though, I tested next, and 3478e400ae31b459b2875cc226796a6d4bba11f9
(rewrap getch in select, handle sigwinch manually) introduced a regression: I
get some 'key not handled' errors after run-mail has been called when sup is
getting back control if I press for example an arrow... ;(

Arrows become usable again after I press a "normal" key (like 'a').

Cheers,

---

From: [email-masked] (Benoît PIERRE)
Date: Sat, 15 Aug 2009 01:08:48 +0200

This also happen to fix a regression after a call to run-mailcap, since
for some reason a screen resize event is triggered when we get control
back...
---
 lib/sup/buffer.rb |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index b3a256f..09281e9 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -270,6 +270,7 @@ EOS
 
     ## this magic makes Ncurses get the new size of the screen
     Ncurses.endwin
+    Ncurses.stdscr.keypad 1
     Ncurses.refresh
     @sigwinch_mutex.synchronize { @sigwinch_happened = false }
     Redwood::log "new screen size is #{Ncurses.rows} x #{Ncurses.cols}"
-- 
1.6.3.3
-- 
A: Because it destroys the flow of conversation.
Q: Why is top posting dumb?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090815/a67dfe70/attachment.bin>

---

From: [email-masked] (William Morgan)
Date: Sun, 16 Aug 2009 15:00:50 -0700

Reformatted excerpts from Beno?t PIERRE's message of 2009-08-14:
> This also happen to fix a regression after a call to run-mailcap,
> since for some reason a screen resize event is triggered when we get
> control back...

Applied to ncurses-fixes, merged into next. Thanks!
-- 
William <wmorgan-sup at masanjin.net>