Hello dear mutt developers,

I prepared a merge request that needs some consideration.

Why? I use mutt on OpenBSD with heavily customized vi-like key bindings and colouring. Especially I'm used to line-wise scrolling being bound to \Ce and \Cy. \Cy can not be bound using the ncurses backend on OpenBSD because the terminal will interpret \Cy as delayed suspend (stty dsusp). Because of this problem I used to use the slang backend. But this in turn messes up colouring (I don't know why and didn't try to figure it out). To improve colouring I just switched back to curses and finally found out about `stty dsusp undef`, which does fix the \Cy issue. But I was also wondering why vim had no problems binding \Cy. After some research I found out about curses' raw and cbreak modes[1]. Mutt uses cbreak and therefore the terminal will still catch and interpret \Cc (SIGINT), \034 (SIGQUIT), \Cy (SIGSTOP on next read), \Cz (SIGSTOP). Those keys can't be bound.

Because users should not need to understand terminal intrinsics to that depth mutt should maybe rather use the raw mode to interpret those characters on its own. The merge request[2] does just that and will switch to use raw instead of cbreak mode.

New functions `suspend` and `interrupt` are implemented.
`suspend` is used to trigger SIGTSTP and is bound to \Cz by default. `interrupt` calls `mutt_query_exit` and is used to mimic the \Cc behaviour. The latter function is almost superfluous because there already is `quit` and `exit`. It's only really needed to quit from the line editor and might have a slightly different behaviour depending on the `quit` quadoption.

[1] https://man.openbsd.org/cbreak#DESCRIPTION
[2] https://gitlab.com/muttmua/mutt/-/merge_requests/90


Kevin J. McCarthy commented on the pull request:
Thanks for the merge request.

To be honest, I'm not too excited about making this kind of change. Mutt has a long history, and (at least some of) its users expect compatibility with stty settings, including support for SIGQUIT. This also won't work with some of the other SIGINT processors, such as during IMAP header downloading.

I'm not familiar enough with the code base to know about other places that would need protection by a cbreak() [...] raw(). I only added it for Yes/No queries.

If you'd like to make an argument for it, please send it to the mutt-dev mailing list instead, but I would need to see strong support there before considering this.

I can see the point of being able to send SIGINT to a process whether it listens or not. This is still possible by using `pkill -SIGQUIT mutt` for example. If one wants to keep the ability to generate signals by pressing `CTRL-[CYZ\]`, you could use the _opposite_ way of switching to raw mode. What I'm thinking of is keeping cbreak mode the default, and only switch to raw mode when we actually may use key mappings or really want to see the keys pressed like in `what-key`.

I added a commit to the merge request implementing this behaviour of as little raw mode as possible.

Of coures a point could also be made that I could use my \Cy and \Cs mappings by something like `alias mutt='stty dsusp undef; mutt'`. But honestly I tried several times to get curses mutt to accept those keycodes and only figured out this time where the problem lies. Users should not need to know such deep intrinsics of terminals these days. I'm using Unix systems for ~20 years now and never needed to care about such terminal intrinsics.


Christopher Zimmermann


--
http://gmerlin.de
OpenPGP: http://gmerlin.de/christopher.pub
CB07 DA40 B0B6 571D 35E2  0DEF 87E2 92A7 13E5 DEE1

Reply via email to