[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, 19 Oct 2016 16:10:29 +0200 |
On Tue, Oct 18, 2016, at 21:52, Sumedh Pendurkar wrote:
> I have attached the patched after making the changes as you said.
Hmm... This doesn't work as I thought it would. It now suggests
the same completion several times, but it shouldn't do that.
So it should remember which words it already suggested... Hrm...
annoying, another global var, a linked list of words to be freed.
Below follow some comments about details in your patch.
+ const char *auto_complete_tag = N_("Auto Complete");
The function is not an auto-complete. Auto-complete is what
LibreOffice and such do: you type a few letters and without
giving any command, the program tentatively fills in (in grey)
a possible completion of the fragment, which you can accept
by typing <Enter>. But nano doesn't do this, not automatically:
you have to type ^] for it to suggest a completion. So it is a
Completion function, not an Auto-completion one.
+ filestruct *check_line = openfile->current;
Hm. You use check_line both for extracting the current fragment
and for searching the file for possible completions... Confusing.
Better use variables for a single purpose.
+ /*remove the previous suggestion*/
+ for (i = 0; i < prev_len; i++)
+ do_backspace();
No, you shouldn't do this with do_backspace(), but should
simply obliterate the inserted bytes by memory-moving the
tail part of the line over it.
Also, at a later stage, proper markers for undo() should be
inserted, so the completion can be undone.
+ blank_statusbar();
+ wnoutrefresh(bottomwin);
There is no need to blank the statusbar any more.
+ int curpos = openfile->current_x, len_to_find = 0;
+ int to_find_start_pos = curpos;
+ int to_find_end_pos = curpos,
Too many variables. Instead of curpos and to_find_end_pos
you can just use openfile->current_x.
+/*Finding the current word in the entire file*/
+ while (check_line != NULL) {
Please align the comments with the lines that they refer to.
And use more blank lines to separate blocks of code, to get
some air.
Attached is a partially cleaned up patch.
Benno
--
http://www.fastmail.com - A fast, anti-spam email service.
0001-new-feature-complete-a-preceding-fragment-to-a-longe.patch
Description: Text Data
- Re: [Nano-devel] adding a word-completion feature to nano, (continued)
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/12
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/12
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/12
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/13
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/15
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/17
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/17
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/17
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/18
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/18
- Re: [Nano-devel] adding a word-completion feature to nano,
Benno Schulenberg <=
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/19
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/19
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/24
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/24
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/25
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/26
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/26
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/27
- Re: [Nano-devel] adding a word-completion feature to nano, Sumedh Pendurkar, 2016/10/27
- Re: [Nano-devel] adding a word-completion feature to nano, Benno Schulenberg, 2016/10/28