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>
This commit is contained in:
parent
83629b9991
commit
a36b726bde
15
src/text.c
15
src/text.c
@ -3061,12 +3061,14 @@ char *copy_completion(char *text)
|
|||||||
return word;
|
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
|
* the first word that starts with this fragment, and tentatively complete the
|
||||||
* fragment. If the user types 'Complete' again, search and paste the next
|
* fragment. If the user types 'Complete' again, search and paste the next
|
||||||
* possible completion. */
|
* possible completion. */
|
||||||
void complete_a_word(void)
|
void complete_a_word(void)
|
||||||
{
|
{
|
||||||
|
static openfilestruct *scouring = NULL;
|
||||||
|
/* The buffer that is being searched for possible completions. */
|
||||||
char *shard, *completion = NULL;
|
char *shard, *completion = NULL;
|
||||||
size_t start_of_shard, shard_length = 0;
|
size_t start_of_shard, shard_length = 0;
|
||||||
size_t i = 0, j = 0;
|
size_t i = 0, j = 0;
|
||||||
@ -3089,6 +3091,7 @@ void complete_a_word(void)
|
|||||||
openfile->last_action = OTHER;
|
openfile->last_action = OTHER;
|
||||||
|
|
||||||
/* Initialize the starting point for searching. */
|
/* Initialize the starting point for searching. */
|
||||||
|
scouring = openfile;
|
||||||
pletion_line = openfile->filetop;
|
pletion_line = openfile->filetop;
|
||||||
pletion_x = 0;
|
pletion_x = 0;
|
||||||
|
|
||||||
@ -3200,9 +3203,17 @@ void complete_a_word(void)
|
|||||||
|
|
||||||
pletion_line = pletion_line->next;
|
pletion_line = pletion_line->next;
|
||||||
pletion_x = 0;
|
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) {
|
if (list_of_completions != NULL) {
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
statusline(AHEM, _("No further matches"));
|
statusline(AHEM, _("No further matches"));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user