On 2017-04-25 12:49:05 -0500, Derek Martin wrote:
> $ cat ~/prog/termsize 
> #!/bin/sh
> echo "lines = $LINES; cols = $COLUMNS"
> 
> $ export LINES COLUMNS
> $ ~/prog/termsize
> lines = 24; cols = 129
> $ echo $TERM
> screen
> $ mutt
> 
> Then, from within mutt, execute ~/prog/termsize:
> 
> ---Mutt: =Mailbox [Msgs:40 Flag:1  Post:1 Inc:13 
> 5.0M]-----------------------------------------------------(sanitized)---
> lines = 24; cols = 129
> Press any key to continue...

This won't work if you resize the terminal after starting Mutt.

> COLUMNS and LINES are not usually automaically exported by the shell,
> but once you export them, the shell maintains them when you resize the
> terminal window, and children get the most recent values.  In the
> past, there were some buggy versions of zsh that failed to do this,
> but in short if your shell doesn't it's broken.  Fix it.  
> 
> Note:  It's NOT maintained in the children (obviously), so if you
> resize your window with Mutt running in it they won't be maintained...
> so unless Mutt actually maintains them for you when it receives
> SIGWINCH, I'm not sure how this helps...  THAT would make this feature
> worthwhile, IMO.

This is what the current code does. See mutt_resize_screen()
in "resize.c".

> > Another issue is DISPLAY, e.g. when using Mutt in GNU screen or tmux
> > together with ssh.
> 
> DISPLAY is slightly harder, if you're connecting to an existing screen
> session and the value doesn't match what's already exported in the
> session, but the same principle applies.  Export it from your shell
> and set the value correctly before you start Mutt, and all is well.

No!!! This is wrong! Like the lines and columns of a terminal,
the physical screen can change *after* Mutt is started.

What I'm currently doing is to store the correct DISPLAY value in
a file via a wrapper. I'm using GNU screen, so I've aliased the
command to "escreen", which is a Perl script that sets up the new
environment (not just DISPLAY, but also for SSH and other things)
and stores it to a file. And I compiled Mutt with EXECSHELL set to
a wrapper to /bin/bash (not /bin/sh since this is dash in general
and dash is broken[*]); this wrapper reads the environment from
the file. So, basically, Mutt have have an obsolete environment,
but all its children will have an updated one.

[*] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=683671

Note: I wonder whether dbus was intended to solve things like that,
but it doesn't (and doesn't handle multiple displays anyway, so that
there's no chance to make it work as wanted).

-- 
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply via email to