Re: [bugs] Allow using :x instead of :wq

Je Sun, 21 Oct 2018 01:46:20 -0400 skribis Subramaniyam:
> This is a simple bug fix for Calcurse.
> In Vim, the :x command is the same* as :wq, and while Calcurse 
> implements :wq, it doesn't recognize :x and an 'unrecognized command' 
> error message pops up if :x is used.
> This patch just makes :x the same as :wq.

I didn't known that calcurse implemented vi bindings – useful to know!
Except for a mention of the vi displacement keys, the :-commands are not
documented in calcurse(1).  The bindings could be documented.  One
could refer with a single line to (the right section of) a vi manual,
or I might inspect the code, and update the manual with existing

I was confused about the "wq" option (and in the patched version "x"
as well) being there two times in the code, but now it's clear to me.

	if (!strcmp(cmd_name, "write") || !strcmp(cmd_name, "w") ||
	    !strcmp(cmd_name, "wq")) {
		valid = 1;

Here calcurse saves everything.

	if (!strcmp(cmd_name, "quit") || !strcmp(cmd_name, "q") ||
	    !strcmp(cmd_name, "wq")) {
		if (force || !conf.confirm_quit || status_ask_bool(
				_("Do you really want to quit?")) == 1)
		valid = 1;

And here the program exits (if not user says no in case of
confirm_quit).  So both must be done for "wq" (and "x").

> Thanks,
> Sub Raizada
> * :x in Vim only writes out the current buffer if it has been changed, 

It works the same for OpenBSD's vi, though :x is not documented in
vi(1).  I never use :x.

> whereas :wq always writes, but making it an alias for :wq should be 
> 'good enough' here.

Agreed, OK for me.