nano-devel
[Top][All Lists]
Advanced

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

[PATCH] completion: search through all open buffers for possible complet


From: Benno Schulenberg
Subject: [PATCH] completion: search through all open buffers for possible completions
Date: Tue, 9 Aug 2022 17:47:19 +0200

This allows one to complete words or names that are used or defined
in another file that is open in another buffer.

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>
---
 src/text.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/text.c b/src/text.c
index 38041add..2222a5b4 100644
--- 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"));
-- 
2.35.3




reply via email to

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