On 2023-12-12 15:17:29 -0500, Derek Martin wrote:
> On Wed, Dec 06, 2023 at 03:10:11PM +0100, Vincent Lefevre wrote:
> > The behavior of SIGINT (typically generated by Ctrl-C in the terminal)
> > is not documented.
> > 
> > It currently asks whether to exit, with MUTT_YES as the default:
> [...]
> > Why doesn't it use "query_quadoption (OPT_QUIT," like <quit> and <exit>?
> 
> I don't think your suggestion is completely crazy, but you asked, so I
> will provide the counterargument:
> 
> Mutt is a user application that already provides two methods of
> exiting the program "nicely" with two different behaviors:  Save state
> or don't.  CTRL-C/SIGINT allows for a third way to terminate the
> program when it is behaving in an incorrect/undesirable way, when for
> example you're not able to get to a menu, or Mutt is failing to
> process menu selections for whatever reason.

OK, but that's not the only use of Ctrl-C. It can also be used to
interrupt an ongoing operation, such as a search/limit, but it may
happen that the time the user hits Ctrl-C, the operation has just
finished, so that instead, Ctrl-C will attempt to terminate Mutt.
One may also hit Ctrl-C by mistake.

> Mutt already prompts to allow for the possibility that you've hit
> CTRL-C by mistake.  When you haven't, clearly the intention is to
> terminate immediately, so that is quite sensibly the default, whereas
> whatever you configured for OPT_QUIT doesn't necessarily apply in this
> circumstance, since the assumption there is that you are exiting under
> normal and expected circumstances.

There could be a new option, say OPT_SIGINT, which could have the same
default as the current behavior. So, for users who do not change this
option, there would still be the same behavior with the introduction
of "query_quadoption (OPT_SIGINT".

> If not for this distinction, you could simply ignore SIGINT
> entirely.

I don't understand what you mean. I can't tell Mutt to ignore it in
this particular case.

> One could argue that your actual problem is that you aren't adequately
> careful about reading and responding to prompts

But that's why there already exist confirmation prompts with a default
that can be set to "no".

I don't see any reason why there's a quadoption for <quit> and <exit>,
but not for Ctrl-C terminating Mutt (with a non-configurable prompt).

>--particularly when you
> obviously already realize this is a mistake you sometimes make--and
> as I'm certain you are aware, there are already solutions possible to
> help you deal with that (remapping Mutt's keys, remapping SIGINT in
> your terminal, etc.).

First, remapping Mutt's keys can't affect the intr character. And
changing the standard Ctrl-C for SIGINT would be more error-prone,
with no simple way to restore the behavior, e.g. after a Ctrl-Z,
or when running shell commands.

> > This would be safer in case one types Ctrl-C + <Return> by mistake.
> > I often do Shift-C + <Return> (very quickly), but I sometimes mistype
> > Shift-C as Ctrl-C, hence the issue.
> 
> Perhaps, but since 1995, I'm pretty sure I've personally made that
> mistake exactly zero times, nor have I ever noticed anyone complaining
> about this in the past, here or anywhere.  That leads me to think that
> rather than changing the current behavior--which seems already
> sensible--you should adapt to it yourself, as I suggested above.

Sorry, but this is silly. Software should adapt to the human, not the
other way round.

FYI, for some reasons, I use various machines, with various keyboards,
where the layout is not exactly the same. This may tend to increased
mistakes.

> > BTW, as mutt_query_exit() doesn't save, the message should be
> > "Exit Mutt without saving?" like with <exit>, IMHO.
> 
> This seems perfectly sensible, though I also think that to anyone
> who's familiar with what CTRL-C typically does on a Unix terminal (and
> plenty of other places), this is already implied and obvious.

Perhaps obvious, but what is already implied is with OP_QUIT,
where the question is just "Quit Mutt?" and saving is done.
So this is rather strange that "Exit Mutt?" has almost the same
behavior as "Exit Mutt without saving?", but is significantly
different from the "Quit Mutt?" behavior.

> I would note that if the issue is that you're hitting <enter> too
> quickly to read the prompt and respond to it appropriately, the
> wording doesn't matter much. =8^)

Indeed, but this is another issue.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - 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