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: Rishabh Dave
Subject: Re: [Nano-devel] warning the user that some keys cannot be rebound
Date: Mon, 12 Sep 2016 22:26:02 +0530

On Sun, Sep 11, 2016 at 8:46 PM, Benno Schulenberg
<address@hidden> wrote:
>
> 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()?

I really liked that spot on explaination! :)   I wasn't thinking so..
intricately.

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

Yes, this is the case I was considering.

>> >> 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.

Okay, I was only considering cases like MSpaces (missing hyphen).
Cases like Mxa are also covered this time.

Attachment: 0001-rcfile-reject-key-names-that-are-wrong-or-too-long.patch
Description: Text Data


reply via email to

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