bug-texinfo
[Top][All Lists]
Advanced

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

Re: address@hidden: Bug#122594: info: Index isn't sure if it should be c


From: Eli Zaretskii
Subject: Re: address@hidden: Bug#122594: info: Index isn't sure if it should be case sensitive or not]
Date: Thu, 06 Dec 2001 22:35:33 +0200

> From: Josip Rodin <address@hidden>
> Date: Thu, 6 Dec 2001 17:51:33 +0100
> 
> 1) info bison
> 2) type 'i'
> 3) type YY <tab>
>       ... note it now displays YY ...
> 4) type E <tab>
>       ... note it now displays YYE ...
> 5) type R <tab>
>       ... now it displays yyerro ...
>       ... and tab tab shows there is both a YYERROR and yyerro ...

Do the two changes below, applied one after the other, help solve
this problem?

> I'd suggest a much nicer (at least for me) algorithm would be to do case
> insensitive on all-lowercase entries, but once I start typing in all
> caps, I mean it. YYER <tab>, for example, should get me YYERROR. 

Alas, it's not that simple, both because Info is generally
case-insensitive on its lowest level of search, and because the
letter-case of index entries is unpredictable.  For example, there
are manuals where all index entries begin with a capital letter;
users shouldn't be expected to know that.

2001-09-09  Eli Zaretskii  <address@hidden>

        * info/echo-area.c (build_completions): Look for a candidate
        completion which matches user's request including the letter-case,
        use that as the value of LCD_completion.

--- info/echo-area.c~1  Sat Jun  2 16:12:10 2001
+++ info/echo-area.c    Sun Sep  9 14:00:24 2001
@@ -1261,7 +1261,24 @@ build_completions ()
 
     maybe_free (LCD_reference.label);
     LCD_reference.label = (char *)xmalloc (1 + shortest);
-    strncpy (LCD_reference.label, completions_found[0]->label, shortest);
+    /* Since both the sorting done inside remove_completion_duplicates
+       and all the comparisons above are case-insensitive, it's
+       possible that the completion we are going to return is
+       identical to what the user typed but for the letter-case.  This
+       is confusing, since the user could type FOOBAR<TAB> and get her
+       string change letter-case for no good reason.  Sp try to find a
+       possible completion whose letter-case is identical, and if so,
+       use that.  */
+    if (completions_found_index > 1)
+      {
+        for (i = 0; i < completions_found_index; i++)
+          if (strncmp (request, completions_found[i]->label, shortest) == 0)
+            break;
+        /* If none of the candidates match exactly, use the first one.  */
+        if (i >= completions_found_index)
+          i = 0;
+      }
+    strncpy (LCD_reference.label, completions_found[i]->label, shortest);
     LCD_reference.label[shortest] = '\0';
     LCD_completion = &LCD_reference;
   }


2001-12-06  Eli Zaretskii  <address@hidden>

        * info/echo-area.c (build_completions): When looking for the best
        completion candidate, only compare as much characters as the user
        typed.

--- info/echo-area.c~2  Sun Sep  9 14:00:24 2001
+++ info/echo-area.c    Thu Dec  6 22:27:24 2001
@@ -1266,13 +1266,15 @@ build_completions ()
        possible that the completion we are going to return is
        identical to what the user typed but for the letter-case.  This
        is confusing, since the user could type FOOBAR<TAB> and get her
-       string change letter-case for no good reason.  Sp try to find a
+       string change letter-case for no good reason.  So try to find a
        possible completion whose letter-case is identical, and if so,
        use that.  */
     if (completions_found_index > 1)
       {
+       int req_len = strlen (request);
+
         for (i = 0; i < completions_found_index; i++)
-          if (strncmp (request, completions_found[i]->label, shortest) == 0)
+          if (strncmp (request, completions_found[i]->label, req_len) == 0)
             break;
         /* If none of the candidates match exactly, use the first one.  */
         if (i >= completions_found_index)



reply via email to

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