--- pdksh-5.2.14/emacs.c.emacsmode 2005-06-21 15:09:55.000000000 +0200 +++ pdksh-5.2.14/emacs.c 2005-06-21 15:14:29.000000000 +0200 @@ -113,7 +113,9 @@ static int killsp, killtp; static int x_curprefix; static char *macroptr; -static int prompt_skip; +static int prompt_trunc; /* how much of prompt to truncate */ +static int prompt_skip; /* how much of prompt to skip */ +static int pwidth; /* width of prompt */ static int x_ins ARGS((char *cp)); static void x_delete ARGS((int nc, int force_push)); @@ -340,13 +342,21 @@ x_last_command = XFUNC_error; xx_cols = x_cols; - x_col = promptlen(prompt, &p); + x_col = pwidth = promptlen(prompt, &p); prompt_skip = p - prompt; + if (x_col > x_cols - 3 - MIN_EDIT_SPACE) + { + x_col = x_cols - 3 - MIN_EDIT_SPACE; + prompt_trunc = pwidth - x_col; + pwidth -= prompt_trunc; + } + else + prompt_trunc = 0; x_adj_ok = 1; x_displen = xx_cols - 2 - x_col; x_adj_done = 0; - pprompt(prompt, 0); + pprompt(prompt + prompt_skip, prompt_trunc); if (x_nextcmd >= 0) { int off = source->line - x_nextcmd; @@ -1046,11 +1056,10 @@ else x_e_putc('\r'); x_flush(); - if (xbp == xbuf) - { - pprompt(prompt + prompt_skip, 0); - x_col = promptlen(prompt, (const char **) 0); - } + pprompt(prompt + prompt_skip, prompt_trunc); + x_col = promptlen(prompt, (const char **) 0); + if (x_col > x_cols - 3 - MIN_EDIT_SPACE) + x_col = x_cols - 3 - MIN_EDIT_SPACE; x_displen = xx_cols - 2 - x_col; xlp_valid = FALSE; cp = x_lastcp();