Hi!
----
Attached is a pach for ksh93r+_alpha
("ksh93r+_alpha_tab_tab_patch_001.diff.txt") which changes the TAB-TAB
behaviour for "emacs" editing mode as proposed in
http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2006-June/000382.html
- TAB-TAB now works generates a list of choices at spaces (e.g. % cd
<TAB><TAB> # now works) and TAB can only be entered via the general
quoting sequence "<CTRL-V>" [1], e.g. "<CTRL-V><TAB>". <TAB> after
<TAB><TAB> now redisplays the list of choices etc.
[1]=I've re-used CTRL-V here, the original idea to use CTRL-Q fails
because the shell never sees this key - it seems to be intercepted by
the terminal for flow control (CTRL-S, CTRL-Q) ... and then the number
of options becomes very limited as most other CTRL-? combinations are
already in use for other work... finally I decided to use CTRL-V since
displaying the shell version is IMO something which is very rarely
needed in daily work, % echo ${.sh.version} # can be used instead and
it's compatible to bash/readline...
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 7950090
(;O/ \/ \O;)
-------------- next part --------------
Index: src/lib/libshell/common/include/edit.h
===================================================================
--- src/lib/libshell/common/include/edit.h (revision 267)
+++ src/lib/libshell/common/include/edit.h (working copy)
@@ -109,7 +109,8 @@
int e_lbuf[LOOKAHEAD];/* pointer to look-ahead buffer */
int e_fd; /* file descriptor */
int e_ttyspeed; /* line speed, also indicates tty parms are
valid */
- int e_tabcount;
+ int e_tabcount; /* number of <TAB>s in a row */
+ int e_quotechar; /* boolean: quote next character */
#ifdef _hdr_utime
ino_t e_tty_ino;
dev_t e_tty_dev;
Index: src/lib/libshell/common/edit/edit.c
===================================================================
--- src/lib/libshell/common/edit/edit.c (revision 267)
+++ src/lib/libshell/common/edit/edit.c (working copy)
@@ -972,7 +972,8 @@
/*** map '\r' to '\n' ***/
if(c == '\r' && mode!=2)
c = '\n';
- if(ep->e_tabcount && !(c=='\t'||c==ESC || c=='\\'))
+ /* '=' is needed for emacs mode "<ESC>=" sequence*/
+ if(ep->e_tabcount && !(c=='\t'||c==ESC || c=='\\' || c=='='))
ep->e_tabcount = 0;
}
else
Index: src/lib/libshell/common/edit/emacs.c
===================================================================
--- src/lib/libshell/common/edit/emacs.c (revision 267)
+++ src/lib/libshell/common/edit/emacs.c (working copy)
@@ -306,10 +306,20 @@
count = 1;
adjust = -1;
i = cur;
+
+ /* CTRL-V is used to quote special characters
+ * (which otherwise would have a special meaning/function) */
+ if(ep->ed->e_quotechar)
+ {
+ ep->ed->e_quotechar = 0;
+ goto do_default_processing;
+ }
+
switch(c)
{
case cntl('V'):
- show_info(ep,fmtident(e_version));
+ /* Quote the character following CTRL-V */
+ ep->ed->e_quotechar = 1;
continue;
case '\0':
ep->mark = i;
@@ -327,21 +337,21 @@
continue;
#endif /* u370 */
case '\t':
- if(cur>0 && cur>=eol && out[cur-1]!='\t' &&
out[cur-1]!=' ' && ep->ed->sh->nextprompt)
+ if(cur>0 && cur>=eol && ep->ed->sh->nextprompt)
{
- if(ep->ed->e_tabcount==0)
- {
- ep->ed->e_tabcount=1;
+ ep->ed->e_tabcount++;
+ if(ep->ed->e_tabcount == 1)
+ {
ed_ungetchar(ep->ed,ESC);
goto do_escape;
}
- else if(ep->ed->e_tabcount==1)
+ else if(ep->ed->e_tabcount > 1)
{
ed_ungetchar(ep->ed,'=');
goto do_escape;
}
- ep->ed->e_tabcount = 0;
}
+ do_default_processing:
default:
if ((eol+1) >= (scend)) /* will not fit on line */
{
@@ -920,15 +930,7 @@
case '=': /* escape = - list all matching file names */
ep->mark = cur;
if(ed_expand(ep->ed,(char*)out,&cur,&eol,i,count) < 0)
- {
- if(ep->ed->e_tabcount==1)
- {
- ep->ed->e_tabcount=2;
- ed_ungetchar(ep->ed,cntl('\t'));
- return(-1);
- }
beep();
- }
else if(i=='=')
draw(ep,REFRESH);
else