Browse files

Add some new editline bindings by default, and allow for user specifi…

…ed configuration.

I excluded the part of this patch that used the HOME environment variable since
the built-in editline library goes to great lengths to disallow that.  Instead
only settings the EDITRC environment variable will use a user specified file.

Also, the default environment variable use to determine the edit more is
AST_EDITMODE instead of AST_EDITOR (although the latter is still supported).

(closes issue #15929)
Reported by: kkm
      astcli-editrc-v2.diff uploaded by kkm (license 888)
      015929-astcli-editrc-trunk.240324.diff uploaded by kkm (license 888)
Tested by: seanbright

git-svn-id: 65c4cc65-6c06-0410-ace0-fbb531ad65f3
  • Loading branch information...
seanbright committed May 5, 2011
1 parent e98ac1f commit d508a921bf352714d6ea35e07cc9a49c74f1581d
Showing with 20 additions and 2 deletions.
  1. +20 −2 main/asterisk.c
@@ -2569,7 +2569,13 @@ static char *cli_complete(EditLine *editline, int ch)
static int ast_el_initialize(void)
HistEvent ev;
char *editor = getenv("AST_EDITOR");
char *editor, *editrc = getenv("EDITRC");

if (!(editor = getenv("AST_EDITMODE"))) {
if (!(editor = getenv("AST_EDITOR"))) {
editor = "emacs";

if (el != NULL)
@@ -2580,7 +2586,7 @@ static int ast_el_initialize(void)
el_set(el, EL_PROMPT, cli_prompt);

el_set(el, EL_EDITMODE, 1);
el_set(el, EL_EDITOR, editor ? editor : "emacs");
el_set(el, EL_EDITOR, editor);
el_hist = history_init();
if (!el || !el_hist)
return -1;
@@ -2597,6 +2603,18 @@ static int ast_el_initialize(void)
el_set(el, EL_BIND, "?", "ed-complete", NULL);
/* Bind ^D to redisplay */
el_set(el, EL_BIND, "^D", "ed-redisplay", NULL);
/* Bind Delete to delete char left */
el_set(el, EL_BIND, "\\e[3~", "ed-delete-next-char", NULL);
/* Bind Home and End to move to line start and end */
el_set(el, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL);
el_set(el, EL_BIND, "\\e[4~", "ed-move-to-end", NULL);
/* Bind C-left and C-right to move by word (not all terminals) */
el_set(el, EL_BIND, "\\eOC", "vi-next-word", NULL);
el_set(el, EL_BIND, "\\eOD", "vi-prev-word", NULL);

if (editrc) {
el_source(el, editrc);

return 0;

0 comments on commit d508a92

Please sign in to comment.