|
From: | Sumedh Pendurkar |
Subject: | Re: [Nano-devel] adding a word-completion feature to nano |
Date: | Wed, 12 Oct 2016 13:23:23 +0530 |
On Tue, Oct 11, 2016, at 10:09, Sumedh Pendurkar wrote:
> Fixed all issues mentioned in previous mail. (I have put message importance
> to ALERT only if the malloc fails for some reason, for every other call to
> statusline() i have set the message importance to HUSH.)
I liked your previous message better: "Insufficient memory", because
it is clear. "Internal error" could mean anything.
+#define WORDLEN_MAX 64
Why limit the word length? Completion becomes more useful
the longer the words are. So I think you will have to allocate
space for each word dynamically.
#define WORD_MAX 20
On the statusbar you can at most show COLS/3 possible completions
(I think one space between the words is enough, and the minimum
completion is two characters). But fine, in general completions
will be somewhat longer, so it is fine to gather at most twenty.
But... it is silly to show "More than 20 words are not supported yet"
when there are more than these twenty possible completions. If there
are more than twenty, I would drop the shortest one in the list and
continue -- doing completion is most useful for long words.
(Alternatively you could ask the user to type more characters.)
+ char *to_print;
+ if ((to_print = (char *)malloc(65 * match)) == NULL) {
Why 65? Surely you mean WORDLEN_MAX+1?
Also, I would write the above as:
+ char *to_print = malloc(65 * match));
+
+ if (to_print == NULL) {
(There should be a blank line after declarations.)
> Another thing I wanted to add is do we need to consider '_' as word forming
> character?
The user can choose to consider '_' as word forming, by specifying
it with 'set wordchars "_"' in their nanorc.
Benno
--
http://www.fastmail.com - Access all of your messages and folders
wherever you are
0001-made-to_find-and-maxlen-of-a-word-dynamic-changed-er.patch
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |