Hello,
This is the first time I am sending a patch to the OpenBSD project,
so please let me know if I should read any docs for future patches.

I ditched GNU Emacs in favour of Mg, but I needed certain changes on Mg for 
personal use.
Below is a patch I have been using for several days; it makes makes find-file 
completion case-insensitive.
Please feel free to reject, suggest and/or apply changes if necessary.

Thank you,
Sina

--- a/echo.c
+++ b/echo.c
@@ -571,13 +571,13 @@ complt(int flags, int c, char *buf, size_t nbuf, int 
cpos, int *nx)
        nxtra = HUGE;

        for (; lh != NULL; lh = lh->l_next) {
-               if (memcmp(buf, lh->l_name, cpos) != 0)
+               if (strncasecmp(buf, lh->l_name, cpos) != 0)
                        continue;
                if (nhits == 0)
                        lh2 = lh;
                ++nhits;
                if (lh->l_name[cpos] == '\0')
-                       nxtra = -1; /* exact match */
+                       nxtra = 0; /* exact match */
                else {
                        bxtra = getxtra(lh, lh2, cpos, wflag);
                        if (bxtra < nxtra)
@@ -594,12 +594,15 @@ complt(int flags, int c, char *buf, size_t nbuf, int 
cpos, int *nx)
                 * Being lazy - ought to check length, but all things
                 * autocompleted have known types/lengths.
                 */
-               if (nxtra < 0 && nhits > 1 && c == ' ')
-                       nxtra = 1; /* ??? */
-               for (i = 0; i < nxtra && cpos < nbuf; ++i) {
-                       buf[cpos] = lh2->l_name[cpos];
-                       eputc(buf[cpos++]);
+               for (i = 0; i < cpos + nxtra && cpos + nxtra < nbuf; i++) {
+                       buf[i] = lh2->l_name[i];
+                       if (i < cpos) {
+                               ttputc('\b');
+                               ttcol--;
+                       }
                }
+               buf[i] = '\0';
+               eputs(buf);
                /* XXX should grow nbuf */
                ttflush();
                free_file_list(wholelist);

--- a/fileio.c
+++ b/fileio.c
@@ -516,7 +517,7 @@ make_file_list(char *buf)

        while ((dent = readdir(dirp)) != NULL) {
                int isdir;
-               if (strncmp(cp, dent->d_name, len) != 0)
+               if (strncasecmp(cp, dent->d_name, len) != 0)
                        continue;
                isdir = 0;
                if (dent->d_type == DT_DIR) {


Reply via email to