nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] warning the user that some keys cannot be rebound


From: Benno Schulenberg
Subject: Re: [Nano-devel] warning the user that some keys cannot be rebound
Date: Sun, 11 Sep 2016 17:16:38 +0200

On Sun, Sep 11, 2016, at 14:28, Rishabh Dave wrote:
> On Sun, Sep 11, 2016 at 3:40 PM, Benno Schulenberg
> <address@hidden> wrote:
> > And doing again a "keycopy[0] == '^'" when
> > it has just been done is a bit wasteful -- you can just || or extra 
> > conidtion
> > into the second one.  See attached patch.
> 
> But now instead of "keycopy[0] == '^'" we do "strcmp(keycopy,
> "^Space") != 0" twice,

No, it doesn't.  A valid keystring (we only care about the cost of
verifying valid keystrings, they must verify as quickly as possible;
invalid keystrings may take ages, we don't care) will be either ^X,
M-X or F12.

1) A ^X will execute neither of the strcmp()s, because it will stop
at the strlen()s.
2) An M-X also will not execute either of them; it will stop at the
== '^' and the strlen() > 3.
3) An F11 does the same thing as M-X.

In your version however, each ^X will run the first strcmp() and
strlen(), and each M-X the second strcmp() and strlen().  Or are
you judging a strlen() as costlier than a strcmp()?

Yes, your version might be quicker in verifying ^Space and M-Space,
but those are not the most frequent cases.

> >> Would it be better if we also disallow meta sequences where '-' is
> >> missing
> >
> > Yes.   But don't take it any further than that.
> 
> Your patch covers this too.

No, it doesn't.  If I put "bind Mxa help all" in my .nanorc,
it gets accepted -- but it shouldn't.  Please add a condition
for that, as the first condition in the series.

> I am attaching a signed patch, just in case this patch
> shan't/shouldn't be altered.  And I couldn't keep subject line less
> than 50 characters. Couldn't express in lesser words.

"rcfile: reject key names that are wrong or too long"

The 50 characters is an advice for the kernel.  For nano it
is fine when the first line is within 74 characters.

Benno

-- 
http://www.fastmail.com - A no graphics, no pop-ups email service




reply via email to

[Prev in Thread] Current Thread [Next in Thread]