nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit a36b726bdecf898d4a390367ef72a0e049c49a87
parent 83629b999189f507761d1efe697e622ec089869d
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon,  8 Aug 2022 08:56:11 +0200

completion: search through all open buffers for possible completions

This allows one to complete also words that are present in other files
(when these are open in other buffers).

This fulfills https://savannah.gnu.org/bugs/?61691.
Requested-by: Tasos Papastylianou <tpapastylianou@hotmail.com>

Original-patch-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>

Diffstat:
Msrc/text.c | 15+++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -3061,12 +3061,14 @@ char *copy_completion(char *text) return word; } -/* Look at the fragment the user has typed, then search the current buffer for +/* Look at the fragment the user has typed, then search all buffers for * the first word that starts with this fragment, and tentatively complete the * fragment. If the user types 'Complete' again, search and paste the next * possible completion. */ void complete_a_word(void) { + static openfilestruct *scouring = NULL; + /* The buffer that is being searched for possible completions. */ char *shard, *completion = NULL; size_t start_of_shard, shard_length = 0; size_t i = 0, j = 0; @@ -3089,6 +3091,7 @@ void complete_a_word(void) openfile->last_action = OTHER; /* Initialize the starting point for searching. */ + scouring = openfile; pletion_line = openfile->filetop; pletion_x = 0; @@ -3200,9 +3203,17 @@ void complete_a_word(void) pletion_line = pletion_line->next; pletion_x = 0; + +#ifdef ENABLE_MULTIBUFFER + /* When at end of buffer and there is another, search that one. */ + if (pletion_line == NULL && scouring->next != openfile) { + scouring = scouring->next; + pletion_line = scouring->filetop; + } +#endif } - /* The search has reached the end of the file. */ + /* The search has gone through all buffers. */ if (list_of_completions != NULL) { edit_refresh(); statusline(AHEM, _("No further matches"));