nano-devel
[Top][All Lists]
Advanced

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

[PATCH] files: list possible completions after just one <Tab> instead of


From: Benno Schulenberg
Subject: [PATCH] files: list possible completions after just one <Tab> instead of two
Date: Sat, 20 Jun 2020 18:48:27 +0200

This gives quicker feedback, and spares the user unnecessary beeps
and typing.  Also, now a beep after a <Tab> means just one thing:
there are NO completions.

This fulfills https://savannah.gnu.org/bugs/?58627.
---
 src/files.c      | 10 ++--------
 src/prompt.c     |  9 +--------
 src/prototypes.h |  3 +--
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/src/files.c b/src/files.c
index c8130b42..1b69b71e 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2481,8 +2481,7 @@ char **filename_completion(const char *buf, size_t 
length, size_t *num_matches)
 
 /* Do tab completion.  'place' is the position of the status-bar cursor, and
  * 'refresh_func' is the function to be called to refresh the edit window. */
-char *input_tab(char *buf, size_t *place, bool *lastwastab,
-                               void (*refresh_func)(void), bool *listed)
+char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool 
*listed)
 {
        size_t num_matches = 0;
        char **matches = NULL;
@@ -2547,9 +2546,6 @@ char *input_tab(char *buf, size_t *place, bool 
*lastwastab,
                if (num_matches == 1 && (is_dir(mzero) || is_dir(glued)))
                        mzero[common_len++] = '/';
 
-               if (num_matches > 1 && (common_len != *place || !*lastwastab))
-                       beep();
-
                /* If the matches have something in common, show that part. */
                if (common_len != *place) {
                        buf = charealloc(buf, common_len + 1);
@@ -2558,9 +2554,7 @@ char *input_tab(char *buf, size_t *place, bool 
*lastwastab,
                        *place = common_len;
                }
 
-               if (!*lastwastab)
-                       *lastwastab = TRUE;
-               else if (num_matches > 1) {
+               if (num_matches > 1) {
                        size_t longest_name = 0, ncols;
                        int row = 0;
 
diff --git a/src/prompt.c b/src/prompt.c
index b7ba97b3..f5936834 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -409,10 +409,6 @@ functionptrtype acquire_an_answer(int *actual, bool 
*listed,
        int kbinput = ERR;
        bool finished;
        functionptrtype func;
-#ifdef ENABLE_TABCOMP
-       bool tabbed = FALSE;
-               /* Whether we've pressed Tab. */
-#endif
 #ifdef ENABLE_HISTORIES
        char *history = NULL;
                /* The current history string. */
@@ -453,9 +449,6 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
                        break;
 
 #ifdef ENABLE_TABCOMP
-               if (func != do_tab)
-                       tabbed = FALSE;
-
                if (func == do_tab) {
 #ifdef ENABLE_HISTORIES
                        if (history_list != NULL) {
@@ -472,7 +465,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
                        /* Allow tab completion of filenames, but not in 
restricted mode. */
                        if ((currmenu == MINSERTFILE || currmenu == MWRITEFILE 
||
                                                                currmenu == 
MGOTODIR) && !ISSET(RESTRICTED))
-                               answer = input_tab(answer, &typing_x, &tabbed, 
refresh_func, listed);
+                               answer = input_tab(answer, &typing_x, 
refresh_func, listed);
                } else
 #endif /* ENABLE_TABCOMP */
 #ifdef ENABLE_HISTORIES
diff --git a/src/prototypes.h b/src/prototypes.h
index d325340f..6d91adbb 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -320,8 +320,7 @@ char *real_dir_from_tilde(const char *path);
 int diralphasort(const void *va, const void *vb);
 #endif
 #ifdef ENABLE_TABCOMP
-char *input_tab(char *buf, size_t *place, bool *lastwastab,
-               void (*refresh_func)(void), bool *listed);
+char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool 
*listed);
 #endif
 
 /* Some functions in global.c. */
-- 
2.25.4




reply via email to

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