nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] adding a word-completion feature to nano


From: Benno Schulenberg
Subject: Re: [Nano-devel] adding a word-completion feature to nano
Date: Wed, 26 Oct 2016 11:46:50 +0200

On Tue, Oct 25, 2016, at 22:29, Sumedh Pendurkar wrote:
> Some important modifications to code:
> 1) added pop_undo(undo_type) function. This functions the top element of 
> undo stack and also makes current_undo point to what undotop is pointing

Okay.  But you have to check that u != NULL.  In other words:
return immediately when u == NULL.  Unless you are sure that
this can never happen.

But... wouldn't it be enough to instead simply do?:

    if (openfile->current_undo != NULL) {
        discard_until(openfile->current_undo->next, openfile);
        openfile->current_undo = openfile->undotop;
    }

> 2) added a dummy struct undo so that we have the desired effect. Example
> file just contains "for" user types "f" and then ^] . so it would now be 
> "for for" in the file as well as in strdata of the undotop.

Wouldn't it be much simpler to just set last_action = OTHER
whenever ^] is typed?  (Which the above suggested popping
of the top item already does.)

> Therefore doing a single undo would remove everything which I think is 
> not desirable.

Correct.

> 3) added a linked list of words. Words vanish from memory once a fresh 
> attempt is made.

Okay.

By the way, please use a blank line between blocks of code.
Also, better not use "current" as the name of the pointer in
the list of completion words. And your inserting a new word
into this list contains some duplicated code; it can be written
shorter; and it is inserted into the middle of something else
(see the preceding comment -- keep related lines together).

Benno

-- 
http://www.fastmail.com - Does exactly what it says on the tin




reply via email to

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