Hi, This patch adds some intelligence to emacs mode filename completion when dealing with quotes in ksh.
Example:
$ ls '/boo<TAB>
$ ls 'boot <point>
becomes:
$ ls 'boot' <point>
Index: emacs.c
===================================================================
RCS file: /cvs/src/bin/ksh/emacs.c,v
retrieving revision 1.48
diff -u -p -r1.48 emacs.c
--- emacs.c 17 Dec 2013 16:37:05 -0000 1.48
+++ emacs.c 23 Jun 2014 15:00:41 -0000
@@ -1799,12 +1799,31 @@ do_complete(int flags, /* XCF_{COMMAND,F
nlen = x_longest_prefix(nwords, words);
/* complete */
if (nwords == 1 || nlen > olen) {
+ int isdir;
+
x_goto(xbuf + start);
x_delete(olen, false);
x_escape(words[0], nlen, x_emacs_putbuf);
x_adjust();
completed = 1;
+
+ isdir = words[0][nlen - 1] == '/';
+
+ /* add matching quote if we began with one */
+ if (start > 0 && xbuf[start - 1] == '\'') {
+ if (xbuf[start + nlen] != '\'' && !isdir)
+ x_ins("'");
+ if (!isdir)
+ x_mv_forw(0);
+ }
+ if (start > 0 && xbuf[start - 1] == '"') {
+ if (xbuf[start + nlen] != '"' && !isdir)
+ x_ins("\"");
+ if (!isdir)
+ x_mv_forw(0);
+ }
}
+
/* add space if single non-dir match */
if (nwords == 1 && words[0][nlen - 1] != '/') {
x_ins(space);
pgpqTFCCq500X.pgp
Description: PGP signature
