1 /* bind.c -- key binding and startup file support for the readline library. */
3 /* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
8 The GNU Readline Library is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2, or
11 (at your option) any later version.
13 The GNU Readline Library is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 The GNU General Public License is often shipped with GNU software, and
19 is generally kept in a file called COPYING or LICENSE. If you do not
20 have a copy of the license, write to the Free Software Foundation,
21 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
23 #define READLINE_LIBRARY
25 #if defined (__TANDEM)
29 #if defined (HAVE_CONFIG_H)
34 #include <sys/types.h>
36 #if defined (HAVE_SYS_FILE_H)
37 # include <sys/file.h>
38 #endif /* HAVE_SYS_FILE_H */
40 #if defined (HAVE_UNISTD_H)
42 #endif /* HAVE_UNISTD_H */
44 #if defined (HAVE_STDLIB_H)
47 # include "ansi_stdlib.h"
48 #endif /* HAVE_STDLIB_H */
56 #include "posixstat.h"
58 /* System-specific feature definitions and include files. */
61 /* Some standard library routines. */
65 #include "rlprivate.h"
69 #if !defined (strchr) && !defined (__STDC__)
70 extern char *strchr (), *strrchr ();
71 #endif /* !strchr && !__STDC__ */
73 /* Variables exported by this file. */
74 Keymap rl_binding_keymap
;
76 static char *_rl_read_file
PARAMS((char *, size_t *));
77 static void _rl_init_file_error
PARAMS((const char *));
78 static int _rl_read_init_file
PARAMS((const char *, int));
79 static int glean_key_from_name
PARAMS((char *));
80 static int substring_member_of_array
PARAMS((char *, const char **));
82 static int currently_reading_init_file
;
84 /* used only in this file */
85 static int _rl_prefer_visible_bell
= 1;
87 /* **************************************************************** */
91 /* **************************************************************** */
93 /* rl_add_defun (char *name, rl_command_func_t *function, int key)
94 Add NAME to the list of named functions. Make FUNCTION be the function
95 that gets called. If KEY is not -1, then bind it. */
97 rl_add_defun (name
, function
, key
)
99 rl_command_func_t
*function
;
103 rl_bind_key (key
, function
);
104 rl_add_funmap_entry (name
, function
);
108 /* Bind KEY to FUNCTION. Returns non-zero if KEY is out of range. */
110 rl_bind_key (key
, function
)
112 rl_command_func_t
*function
;
117 if (META_CHAR (key
) && _rl_convert_meta_chars_to_ascii
)
119 if (_rl_keymap
[ESC
].type
== ISKMAP
)
123 escmap
= FUNCTION_TO_KEYMAP (_rl_keymap
, ESC
);
125 escmap
[key
].type
= ISFUNC
;
126 escmap
[key
].function
= function
;
132 _rl_keymap
[key
].type
= ISFUNC
;
133 _rl_keymap
[key
].function
= function
;
134 rl_binding_keymap
= _rl_keymap
;
138 /* Bind KEY to FUNCTION in MAP. Returns non-zero in case of invalid
141 rl_bind_key_in_map (key
, function
, map
)
143 rl_command_func_t
*function
;
151 result
= rl_bind_key (key
, function
);
156 /* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. Right
157 now, this is always used to attempt to bind the arrow keys, hence the
158 check for rl_vi_movement_mode. */
160 rl_bind_key_if_unbound_in_map (key
, default_func
, kmap
)
162 rl_command_func_t
*default_func
;
167 keyseq
[0] = (unsigned char)key
;
169 return (rl_bind_keyseq_if_unbound_in_map (keyseq
, default_func
, kmap
));
173 rl_bind_key_if_unbound (key
, default_func
)
175 rl_command_func_t
*default_func
;
179 keyseq
[0] = (unsigned char)key
;
181 return (rl_bind_keyseq_if_unbound_in_map (keyseq
, default_func
, _rl_keymap
));
184 /* Make KEY do nothing in the currently selected keymap.
185 Returns non-zero in case of error. */
190 return (rl_bind_key (key
, (rl_command_func_t
*)NULL
));
193 /* Make KEY do nothing in MAP.
194 Returns non-zero in case of error. */
196 rl_unbind_key_in_map (key
, map
)
200 return (rl_bind_key_in_map (key
, (rl_command_func_t
*)NULL
, map
));
203 /* Unbind all keys bound to FUNCTION in MAP. */
205 rl_unbind_function_in_map (func
, map
)
206 rl_command_func_t
*func
;
209 register int i
, rval
;
211 for (i
= rval
= 0; i
< KEYMAP_SIZE
; i
++)
213 if (map
[i
].type
== ISFUNC
&& map
[i
].function
== func
)
215 map
[i
].function
= (rl_command_func_t
*)NULL
;
223 rl_unbind_command_in_map (command
, map
)
227 rl_command_func_t
*func
;
229 func
= rl_named_function (command
);
232 return (rl_unbind_function_in_map (func
, map
));
235 /* Bind the key sequence represented by the string KEYSEQ to
236 FUNCTION, starting in the current keymap. This makes new
237 keymaps as necessary. */
239 rl_bind_keyseq (keyseq
, function
)
241 rl_command_func_t
*function
;
243 return (rl_generic_bind (ISFUNC
, keyseq
, (char *)function
, _rl_keymap
));
246 /* Bind the key sequence represented by the string KEYSEQ to
247 FUNCTION. This makes new keymaps as necessary. The initial
248 place to do bindings is in MAP. */
250 rl_bind_keyseq_in_map (keyseq
, function
, map
)
252 rl_command_func_t
*function
;
255 return (rl_generic_bind (ISFUNC
, keyseq
, (char *)function
, map
));
258 /* Backwards compatibility; equivalent to rl_bind_keyseq_in_map() */
260 rl_set_key (keyseq
, function
, map
)
262 rl_command_func_t
*function
;
265 return (rl_generic_bind (ISFUNC
, keyseq
, (char *)function
, map
));
268 /* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. Right
269 now, this is always used to attempt to bind the arrow keys, hence the
270 check for rl_vi_movement_mode. */
272 rl_bind_keyseq_if_unbound_in_map (keyseq
, default_func
, kmap
)
274 rl_command_func_t
*default_func
;
277 rl_command_func_t
*func
;
281 func
= rl_function_of_keyseq (keyseq
, kmap
, (int *)NULL
);
282 #if defined (VI_MODE)
283 if (!func
|| func
== rl_do_lowercase_version
|| func
== rl_vi_movement_mode
)
285 if (!func
|| func
== rl_do_lowercase_version
)
287 return (rl_bind_keyseq_in_map (keyseq
, default_func
, kmap
));
295 rl_bind_keyseq_if_unbound (keyseq
, default_func
)
297 rl_command_func_t
*default_func
;
299 return (rl_bind_keyseq_if_unbound_in_map (keyseq
, default_func
, _rl_keymap
));
302 /* Bind the key sequence represented by the string KEYSEQ to
303 the string of characters MACRO. This makes new keymaps as
304 necessary. The initial place to do bindings is in MAP. */
306 rl_macro_bind (keyseq
, macro
, map
)
307 const char *keyseq
, *macro
;
313 macro_keys
= (char *)xmalloc ((2 * strlen (macro
)) + 1);
315 if (rl_translate_keyseq (macro
, macro_keys
, ¯o_keys_len
))
320 rl_generic_bind (ISMACR
, keyseq
, macro_keys
, map
);
324 /* Bind the key sequence represented by the string KEYSEQ to
325 the arbitrary pointer DATA. TYPE says what kind of data is
326 pointed to by DATA, right now this can be a function (ISFUNC),
327 a macro (ISMACR), or a keymap (ISKMAP). This makes new keymaps
328 as necessary. The initial place to do bindings is in MAP. */
330 rl_generic_bind (type
, keyseq
, data
, map
)
343 /* If no keys to bind to, exit right away. */
344 if (!keyseq
|| !*keyseq
)
351 keys
= (char *)xmalloc (1 + (2 * strlen (keyseq
)));
353 /* Translate the ASCII representation of KEYSEQ into an array of
354 characters. Stuff the characters into KEYS, and the length of
355 KEYS into KEYS_LEN. */
356 if (rl_translate_keyseq (keyseq
, keys
, &keys_len
))
362 /* Bind keys, making new keymaps as necessary. */
363 for (i
= 0; i
< keys_len
; i
++)
365 unsigned char uc
= keys
[i
];
369 if (ic
< 0 || ic
>= KEYMAP_SIZE
)
372 if (_rl_convert_meta_chars_to_ascii
&& META_CHAR (ic
))
375 if (map
[ESC
].type
== ISKMAP
)
376 map
= FUNCTION_TO_KEYMAP (map
, ESC
);
379 if ((i
+ 1) < keys_len
)
381 if (map
[ic
].type
!= ISKMAP
)
383 /* We allow subsequences of keys. If a keymap is being
384 created that will `shadow' an existing function or macro
385 key binding, we save that keybinding into the ANYOTHERKEY
386 index in the new map. The dispatch code will look there
387 to find the function to execute if the subsequence is not
388 matched. ANYOTHERKEY was chosen to be greater than
392 map
[ic
].type
= ISKMAP
;
393 map
[ic
].function
= KEYMAP_TO_FUNCTION (rl_make_bare_keymap());
395 map
= FUNCTION_TO_KEYMAP (map
, ic
);
396 /* The dispatch code will return this function if no matching
397 key sequence is found in the keymap. This (with a little
398 help from the dispatch code in readline.c) allows `a' to be
399 mapped to something, `abc' to be mapped to something else,
400 and the function bound to `a' to be executed when the user
401 types `abx', leaving `bx' in the input queue. */
402 if (k
.function
&& ((k
.type
== ISFUNC
&& k
.function
!= rl_do_lowercase_version
) || k
.type
== ISMACR
))
404 map
[ANYOTHERKEY
] = k
;
410 if (map
[ic
].type
== ISMACR
)
411 free ((char *)map
[ic
].function
);
412 else if (map
[ic
].type
== ISKMAP
)
414 map
= FUNCTION_TO_KEYMAP (map
, ic
);
418 map
[ic
].function
= KEYMAP_TO_FUNCTION (data
);
422 rl_binding_keymap
= map
;
428 /* Translate the ASCII representation of SEQ, stuffing the values into ARRAY,
429 an array of characters. LEN gets the final length of ARRAY. Return
430 non-zero if there was an error parsing SEQ. */
432 rl_translate_keyseq (seq
, array
, len
)
437 register int i
, c
, l
, temp
;
439 for (i
= l
= 0; c
= seq
[i
]; i
++)
448 /* Handle \C- and \M- prefixes. */
449 if ((c
== 'C' || c
== 'M') && seq
[i
+ 1] == '-')
451 /* Handle special case of backwards define. */
452 if (strncmp (&seq
[i
], "C-\\M-", 5) == 0)
454 array
[l
++] = ESC
; /* ESC is meta-prefix */
456 array
[l
++] = CTRL (_rl_to_upper (seq
[i
]));
463 array
[l
++] = ESC
; /* ESC is meta-prefix */
468 /* Special hack for C-?... */
469 array
[l
++] = (seq
[i
] == '?') ? RUBOUT
: CTRL (_rl_to_upper (seq
[i
]));
474 /* Translate other backslash-escaped characters. These are the
475 same escape sequences that bash's `echo' and `printf' builtins
476 handle, with the addition of \d -> RUBOUT. A backslash
477 preceding a character that is not special is stripped. */
487 array
[l
++] = RUBOUT
; /* readline-specific */
496 array
[l
++] = NEWLINE
;
510 case '0': case '1': case '2': case '3':
511 case '4': case '5': case '6': case '7':
513 for (temp
= 2, c
-= '0'; ISOCTAL (seq
[i
]) && temp
--; i
++)
514 c
= (c
* 8) + OCTVALUE (seq
[i
]);
515 i
--; /* auto-increment in for loop */
516 array
[l
++] = c
& largest_char
;
520 for (temp
= 2, c
= 0; ISXDIGIT ((unsigned char)seq
[i
]) && temp
--; i
++)
521 c
= (c
* 16) + HEXVALUE (seq
[i
]);
524 i
--; /* auto-increment in for loop */
525 array
[l
++] = c
& largest_char
;
527 default: /* backslashes before non-special chars just add the char */
529 break; /* the backslash is stripped */
543 rl_untranslate_keyseq (seq
)
546 static char kseq
[16];
558 else if (CTRL_CHAR (c
))
563 c
= _rl_to_lower (UNCTRL (c
));
565 else if (c
== RUBOUT
)
578 else if (c
== '\\' || c
== '"')
583 kseq
[i
++] = (unsigned char) c
;
589 _rl_untranslate_macro_value (seq
)
595 r
= ret
= (char *)xmalloc (7 * strlen (seq
) + 1);
596 for (s
= seq
; *s
; s
++)
606 else if (CTRL_CHAR (c
) && c
!= ESC
)
611 c
= _rl_to_lower (UNCTRL (c
));
613 else if (c
== RUBOUT
)
626 else if (c
== '\\' || c
== '"')
629 *r
++ = (unsigned char)c
;
635 /* Return a pointer to the function that STRING represents.
636 If STRING doesn't have a matching function, then a NULL pointer
639 rl_named_function (string
)
644 rl_initialize_funmap ();
646 for (i
= 0; funmap
[i
]; i
++)
647 if (_rl_stricmp (funmap
[i
]->name
, string
) == 0)
648 return (funmap
[i
]->function
);
649 return ((rl_command_func_t
*)NULL
);
652 /* Return the function (or macro) definition which would be invoked via
653 KEYSEQ if executed in MAP. If MAP is NULL, then the current keymap is
654 used. TYPE, if non-NULL, is a pointer to an int which will receive the
655 type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap),
656 or ISMACR (macro). */
658 rl_function_of_keyseq (keyseq
, map
, type
)
668 for (i
= 0; keyseq
&& keyseq
[i
]; i
++)
670 unsigned char ic
= keyseq
[i
];
672 if (META_CHAR (ic
) && _rl_convert_meta_chars_to_ascii
)
674 if (map
[ESC
].type
!= ISKMAP
)
677 *type
= map
[ESC
].type
;
679 return (map
[ESC
].function
);
683 map
= FUNCTION_TO_KEYMAP (map
, ESC
);
688 if (map
[ic
].type
== ISKMAP
)
690 /* If this is the last key in the key sequence, return the
697 return (map
[ic
].function
);
700 map
= FUNCTION_TO_KEYMAP (map
, ic
);
705 *type
= map
[ic
].type
;
707 return (map
[ic
].function
);
710 return ((rl_command_func_t
*) NULL
);
713 /* The last key bindings file read. */
714 static char *last_readline_init_file
= (char *)NULL
;
716 /* The file we're currently reading key bindings from. */
717 static const char *current_readline_init_file
;
718 static int current_readline_init_include_level
;
719 static int current_readline_init_lineno
;
721 /* Read FILENAME into a locally-allocated buffer and return the buffer.
722 The size of the buffer is returned in *SIZEP. Returns NULL if any
723 errors were encountered. */
725 _rl_read_file (filename
, sizep
)
734 if ((stat (filename
, &finfo
) < 0) || (file
= open (filename
, O_RDONLY
, 0666)) < 0)
735 return ((char *)NULL
);
737 file_size
= (size_t)finfo
.st_size
;
739 /* check for overflow on very large files */
740 if (file_size
!= finfo
.st_size
|| file_size
+ 1 < file_size
)
747 return ((char *)NULL
);
750 /* Read the file into BUFFER. */
751 buffer
= (char *)xmalloc (file_size
+ 1);
752 i
= read (file
, buffer
, file_size
);
758 return ((char *)NULL
);
768 /* Re-read the current keybindings file. */
770 rl_re_read_init_file (count
, ignore
)
774 r
= rl_read_init_file ((const char *)NULL
);
775 rl_set_keymap_from_edit_mode ();
779 /* Do key bindings from a file. If FILENAME is NULL it defaults
780 to the first non-null filename from this list:
781 1. the filename used for the previous call
782 2. the value of the shell variable `INPUTRC'
784 If the file existed and could be opened and read, 0 is returned,
785 otherwise errno is returned. */
787 rl_read_init_file (filename
)
788 const char *filename
;
790 /* Default the filename. */
793 filename
= last_readline_init_file
;
795 filename
= sh_get_env_value ("INPUTRC");
797 filename
= DEFAULT_INPUTRC
;
801 filename
= DEFAULT_INPUTRC
;
803 #if defined (__MSDOS__)
804 if (_rl_read_init_file (filename
, 0) == 0)
806 filename
= "~/_inputrc";
808 return (_rl_read_init_file (filename
, 0));
812 _rl_read_init_file (filename
, include_level
)
813 const char *filename
;
817 char *buffer
, *openname
, *line
, *end
;
820 current_readline_init_file
= filename
;
821 current_readline_init_include_level
= include_level
;
823 openname
= tilde_expand (filename
);
824 buffer
= _rl_read_file (openname
, &file_size
);
830 if (include_level
== 0 && filename
!= last_readline_init_file
)
832 FREE (last_readline_init_file
);
833 last_readline_init_file
= savestring (filename
);
836 currently_reading_init_file
= 1;
838 /* Loop over the lines in the file. Lines that start with `#' are
839 comments; all other lines are commands for readline initialization. */
840 current_readline_init_lineno
= 1;
842 end
= buffer
+ file_size
;
845 /* Find the end of this line. */
846 for (i
= 0; line
+ i
!= end
&& line
[i
] != '\n'; i
++);
848 #if defined (__CYGWIN__)
849 /* ``Be liberal in what you accept.'' */
850 if (line
[i
] == '\n' && line
[i
-1] == '\r')
854 /* Mark end of line. */
857 /* Skip leading whitespace. */
858 while (*line
&& whitespace (*line
))
864 /* If the line is not a comment, then parse it. */
865 if (*line
&& *line
!= '#')
866 rl_parse_and_bind (line
);
868 /* Move to the next line. */
870 current_readline_init_lineno
++;
874 currently_reading_init_file
= 0;
879 _rl_init_file_error (msg
)
882 if (currently_reading_init_file
)
883 fprintf (stderr
, "readline: %s: line %d: %s\n", current_readline_init_file
,
884 current_readline_init_lineno
, msg
);
886 fprintf (stderr
, "readline: %s\n", msg
);
889 /* **************************************************************** */
891 /* Parser Directives */
893 /* **************************************************************** */
895 typedef int _rl_parser_func_t
PARAMS((char *));
897 /* Things that mean `Control'. */
898 const char *_rl_possible_control_prefixes
[] = {
899 "Control-", "C-", "CTRL-", (const char *)NULL
902 const char *_rl_possible_meta_prefixes
[] = {
903 "Meta", "M-", (const char *)NULL
908 /* Calling programs set this to have their argv[0]. */
909 const char *rl_readline_name
= "other";
911 /* Stack of previous values of parsing_conditionalized_out. */
912 static unsigned char *if_stack
= (unsigned char *)NULL
;
913 static int if_stack_depth
;
914 static int if_stack_size
;
916 /* Push _rl_parsing_conditionalized_out, and set parser state based
924 /* Push parser state. */
925 if (if_stack_depth
+ 1 >= if_stack_size
)
928 if_stack
= (unsigned char *)xmalloc (if_stack_size
= 20);
930 if_stack
= (unsigned char *)xrealloc (if_stack
, if_stack_size
+= 20);
932 if_stack
[if_stack_depth
++] = _rl_parsing_conditionalized_out
;
934 /* If parsing is turned off, then nothing can turn it back on except
935 for finding the matching endif. In that case, return right now. */
936 if (_rl_parsing_conditionalized_out
)
939 /* Isolate first argument. */
940 for (i
= 0; args
[i
] && !whitespace (args
[i
]); i
++);
945 /* Handle "$if term=foo" and "$if mode=emacs" constructs. If this
946 isn't term=foo, or mode=emacs, then check to see if the first
947 word in ARGS is the same as the value stored in rl_readline_name. */
948 if (rl_terminal_name
&& _rl_strnicmp (args
, "term=", 5) == 0)
952 /* Terminals like "aaa-60" are equivalent to "aaa". */
953 tname
= savestring (rl_terminal_name
);
954 tem
= strchr (tname
, '-');
958 /* Test the `long' and `short' forms of the terminal name so that
959 if someone has a `sun-cmd' and does not want to have bindings
960 that will be executed if the terminal is a `sun', they can put
961 `$if term=sun-cmd' into their .inputrc. */
962 _rl_parsing_conditionalized_out
= _rl_stricmp (args
+ 5, tname
) &&
963 _rl_stricmp (args
+ 5, rl_terminal_name
);
966 #if defined (VI_MODE)
967 else if (_rl_strnicmp (args
, "mode=", 5) == 0)
971 if (_rl_stricmp (args
+ 5, "emacs") == 0)
973 else if (_rl_stricmp (args
+ 5, "vi") == 0)
978 _rl_parsing_conditionalized_out
= mode
!= rl_editing_mode
;
981 /* Check to see if the first word in ARGS is the same as the
982 value stored in rl_readline_name. */
983 else if (_rl_stricmp (args
, rl_readline_name
) == 0)
984 _rl_parsing_conditionalized_out
= 0;
986 _rl_parsing_conditionalized_out
= 1;
990 /* Invert the current parser state if there is anything on the stack. */
997 if (if_stack_depth
== 0)
999 _rl_init_file_error ("$else found without matching $if");
1004 /* Check the previous (n - 1) levels of the stack to make sure that
1005 we haven't previously turned off parsing. */
1006 for (i
= 0; i
< if_stack_depth
- 1; i
++)
1008 /* Check the previous (n) levels of the stack to make sure that
1009 we haven't previously turned off parsing. */
1010 for (i
= 0; i
< if_stack_depth
; i
++)
1012 if (if_stack
[i
] == 1)
1015 /* Invert the state of parsing if at top level. */
1016 _rl_parsing_conditionalized_out
= !_rl_parsing_conditionalized_out
;
1020 /* Terminate a conditional, popping the value of
1021 _rl_parsing_conditionalized_out from the stack. */
1027 _rl_parsing_conditionalized_out
= if_stack
[--if_stack_depth
];
1029 _rl_init_file_error ("$endif without matching $if");
1034 parser_include (args
)
1037 const char *old_init_file
;
1039 int old_line_number
, old_include_level
, r
;
1041 if (_rl_parsing_conditionalized_out
)
1044 old_init_file
= current_readline_init_file
;
1045 old_line_number
= current_readline_init_lineno
;
1046 old_include_level
= current_readline_init_include_level
;
1048 e
= strchr (args
, '\n');
1051 r
= _rl_read_init_file ((const char *)args
, old_include_level
+ 1);
1053 current_readline_init_file
= old_init_file
;
1054 current_readline_init_lineno
= old_line_number
;
1055 current_readline_init_include_level
= old_include_level
;
1060 /* Associate textual names with actual functions. */
1063 _rl_parser_func_t
*function
;
1064 } parser_directives
[] = {
1065 { "if", parser_if
},
1066 { "endif", parser_endif
},
1067 { "else", parser_else
},
1068 { "include", parser_include
},
1069 { (char *)0x0, (_rl_parser_func_t
*)0x0 }
1072 /* Handle a parser directive. STATEMENT is the line of the directive
1073 without any leading `$'. */
1075 handle_parser_directive (statement
)
1079 char *directive
, *args
;
1081 /* Isolate the actual directive. */
1083 /* Skip whitespace. */
1084 for (i
= 0; whitespace (statement
[i
]); i
++);
1086 directive
= &statement
[i
];
1088 for (; statement
[i
] && !whitespace (statement
[i
]); i
++);
1091 statement
[i
++] = '\0';
1093 for (; statement
[i
] && whitespace (statement
[i
]); i
++);
1095 args
= &statement
[i
];
1097 /* Lookup the command, and act on it. */
1098 for (i
= 0; parser_directives
[i
].name
; i
++)
1099 if (_rl_stricmp (directive
, parser_directives
[i
].name
) == 0)
1101 (*parser_directives
[i
].function
) (args
);
1105 /* display an error message about the unknown parser directive */
1106 _rl_init_file_error ("unknown parser directive");
1110 /* Read the binding command from STRING and perform it.
1111 A key binding command looks like: Keyname: function-name\0,
1112 a variable binding command looks like: set variable value.
1113 A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */
1115 rl_parse_and_bind (string
)
1118 char *funname
, *kname
;
1120 int key
, equivalency
;
1122 while (string
&& whitespace (*string
))
1125 if (!string
|| !*string
|| *string
== '#')
1128 /* If this is a parser directive, act on it. */
1131 handle_parser_directive (&string
[1]);
1135 /* If we aren't supposed to be parsing right now, then we're done. */
1136 if (_rl_parsing_conditionalized_out
)
1140 /* If this keyname is a complex key expression surrounded by quotes,
1141 advance to after the matching close quote. This code allows the
1142 backslash to quote characters in the key expression. */
1147 for (i
= 1; c
= string
[i
]; i
++)
1164 /* If we didn't find a closing quote, abort the line. */
1165 if (string
[i
] == '\0')
1167 _rl_init_file_error ("no closing `\"' in key binding");
1172 /* Advance to the colon (:) or whitespace which separates the two objects. */
1173 for (; (c
= string
[i
]) && c
!= ':' && c
!= ' ' && c
!= '\t'; i
++ );
1175 equivalency
= (c
== ':' && string
[i
+ 1] == '=');
1177 /* Mark the end of the command (or keyname). */
1181 /* If doing assignment, skip the '=' sign as well. */
1185 /* If this is a command to set a variable, then do that. */
1186 if (_rl_stricmp (string
, "set") == 0)
1188 char *var
= string
+ i
;
1191 /* Make VAR point to start of variable name. */
1192 while (*var
&& whitespace (*var
)) var
++;
1194 /* Make VALUE point to start of value string. */
1196 while (*value
&& !whitespace (*value
)) value
++;
1199 while (*value
&& whitespace (*value
)) value
++;
1201 rl_variable_bind (var
, value
);
1205 /* Skip any whitespace between keyname and funname. */
1206 for (; string
[i
] && whitespace (string
[i
]); i
++);
1207 funname
= &string
[i
];
1209 /* Now isolate funname.
1210 For straight function names just look for whitespace, since
1211 that will signify the end of the string. But this could be a
1212 macro definition. In that case, the string is quoted, so skip
1213 to the matching delimiter. We allow the backslash to quote the
1214 delimiter characters in the macro body. */
1215 /* This code exists to allow whitespace in macro expansions, which
1216 would otherwise be gobbled up by the next `for' loop.*/
1217 /* XXX - it may be desirable to allow backslash quoting only if " is
1218 the quoted string delimiter, like the shell. */
1219 if (*funname
== '\'' || *funname
== '"')
1221 int delimiter
= string
[i
++], passc
;
1223 for (passc
= 0; c
= string
[i
]; i
++)
1244 /* Advance to the end of the string. */
1245 for (; string
[i
] && !whitespace (string
[i
]); i
++);
1247 /* No extra whitespace at the end of the string. */
1250 /* Handle equivalency bindings here. Make the left-hand side be exactly
1251 whatever the right-hand evaluates to, including keymaps. */
1257 /* If this is a new-style key-binding, then do the binding with
1258 rl_bind_keyseq (). Otherwise, let the older code deal with it. */
1262 register int j
, k
, passc
;
1264 seq
= (char *)xmalloc (1 + strlen (string
));
1265 for (j
= 1, k
= passc
= 0; string
[j
]; j
++)
1267 /* Allow backslash to quote characters, but leave them in place.
1268 This allows a string to end with a backslash quoting another
1269 backslash, or with a backslash quoting a double quote. The
1270 backslashes are left in place for rl_translate_keyseq (). */
1271 if (passc
|| (string
[j
] == '\\'))
1273 seq
[k
++] = string
[j
];
1278 if (string
[j
] == '"')
1281 seq
[k
++] = string
[j
];
1285 /* Binding macro? */
1286 if (*funname
== '\'' || *funname
== '"')
1288 j
= strlen (funname
);
1290 /* Remove the delimiting quotes from each end of FUNNAME. */
1291 if (j
&& funname
[j
- 1] == *funname
)
1292 funname
[j
- 1] = '\0';
1294 rl_macro_bind (seq
, &funname
[1], _rl_keymap
);
1297 rl_bind_keyseq (seq
, rl_named_function (funname
));
1303 /* Get the actual character we want to deal with. */
1304 kname
= strrchr (string
, '-');
1310 key
= glean_key_from_name (kname
);
1312 /* Add in control and meta bits. */
1313 if (substring_member_of_array (string
, _rl_possible_control_prefixes
))
1314 key
= CTRL (_rl_to_upper (key
));
1316 if (substring_member_of_array (string
, _rl_possible_meta_prefixes
))
1319 /* Temporary. Handle old-style keyname with macro-binding. */
1320 if (*funname
== '\'' || *funname
== '"')
1323 int fl
= strlen (funname
);
1325 useq
[0] = key
; useq
[1] = '\0';
1326 if (fl
&& funname
[fl
- 1] == *funname
)
1327 funname
[fl
- 1] = '\0';
1329 rl_macro_bind (useq
, &funname
[1], _rl_keymap
);
1331 #if defined (PREFIX_META_HACK)
1332 /* Ugly, but working hack to keep prefix-meta around. */
1333 else if (_rl_stricmp (funname
, "prefix-meta") == 0)
1339 rl_generic_bind (ISKMAP
, seq
, (char *)emacs_meta_keymap
, _rl_keymap
);
1341 #endif /* PREFIX_META_HACK */
1343 rl_bind_key (key
, rl_named_function (funname
));
1347 /* Simple structure for boolean readline variables (i.e., those that can
1348 have one of two values; either "On" or 1 for truth, or "Off" or 0 for
1351 #define V_SPECIAL 0x1
1357 } boolean_varlist
[] = {
1358 { "blink-matching-paren", &rl_blink_matching_paren
, V_SPECIAL
},
1359 { "byte-oriented", &rl_byte_oriented
, 0 },
1360 { "completion-ignore-case", &_rl_completion_case_fold
, 0 },
1361 { "convert-meta", &_rl_convert_meta_chars_to_ascii
, 0 },
1362 { "disable-completion", &rl_inhibit_completion
, 0 },
1363 { "enable-keypad", &_rl_enable_keypad
, 0 },
1364 { "expand-tilde", &rl_complete_with_tilde_expansion
, 0 },
1365 { "history-preserve-point", &_rl_history_preserve_point
, 0 },
1366 { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode
, 0 },
1367 { "input-meta", &_rl_meta_flag
, 0 },
1368 { "mark-directories", &_rl_complete_mark_directories
, 0 },
1369 { "mark-modified-lines", &_rl_mark_modified_lines
, 0 },
1370 { "mark-symlinked-directories", &_rl_complete_mark_symlink_dirs
, 0 },
1371 { "match-hidden-files", &_rl_match_hidden_files
, 0 },
1372 { "meta-flag", &_rl_meta_flag
, 0 },
1373 { "output-meta", &_rl_output_meta_chars
, 0 },
1374 { "page-completions", &_rl_page_completions
, 0 },
1375 { "prefer-visible-bell", &_rl_prefer_visible_bell
, V_SPECIAL
},
1376 { "print-completions-horizontally", &_rl_print_completions_horizontally
, 0 },
1377 { "show-all-if-ambiguous", &_rl_complete_show_all
, 0 },
1378 { "show-all-if-unmodified", &_rl_complete_show_unmodified
, 0 },
1379 #if defined (VISIBLE_STATS)
1380 { "visible-stats", &rl_visible_stats
, 0 },
1381 #endif /* VISIBLE_STATS */
1382 { (char *)NULL
, (int *)NULL
}
1386 find_boolean_var (name
)
1391 for (i
= 0; boolean_varlist
[i
].name
; i
++)
1392 if (_rl_stricmp (name
, boolean_varlist
[i
].name
) == 0)
1397 /* Hooks for handling special boolean variables, where a
1398 function needs to be called or another variable needs
1399 to be changed when they're changed. */
1401 hack_special_boolean_var (i
)
1406 name
= boolean_varlist
[i
].name
;
1408 if (_rl_stricmp (name
, "blink-matching-paren") == 0)
1409 _rl_enable_paren_matching (rl_blink_matching_paren
);
1410 else if (_rl_stricmp (name
, "prefer-visible-bell") == 0)
1412 if (_rl_prefer_visible_bell
)
1413 _rl_bell_preference
= VISIBLE_BELL
;
1415 _rl_bell_preference
= AUDIBLE_BELL
;
1419 typedef int _rl_sv_func_t
PARAMS((const char *));
1421 /* These *must* correspond to the array indices for the appropriate
1422 string variable. (Though they're not used right now.) */
1423 #define V_BELLSTYLE 0
1424 #define V_COMBEGIN 1
1425 #define V_EDITMODE 2
1426 #define V_ISRCHTERM 3
1432 /* Forward declarations */
1433 static int sv_bell_style
PARAMS((const char *));
1434 static int sv_combegin
PARAMS((const char *));
1435 static int sv_compquery
PARAMS((const char *));
1436 static int sv_editmode
PARAMS((const char *));
1437 static int sv_isrchterm
PARAMS((const char *));
1438 static int sv_keymap
PARAMS((const char *));
1443 _rl_sv_func_t
*set_func
;
1444 } string_varlist
[] = {
1445 { "bell-style", V_STRING
, sv_bell_style
},
1446 { "comment-begin", V_STRING
, sv_combegin
},
1447 { "completion-query-items", V_INT
, sv_compquery
},
1448 { "editing-mode", V_STRING
, sv_editmode
},
1449 { "isearch-terminators", V_STRING
, sv_isrchterm
},
1450 { "keymap", V_STRING
, sv_keymap
},
1455 find_string_var (name
)
1460 for (i
= 0; string_varlist
[i
].name
; i
++)
1461 if (_rl_stricmp (name
, string_varlist
[i
].name
) == 0)
1466 /* A boolean value that can appear in a `set variable' command is true if
1467 the value is null or empty, `on' (case-insenstive), or "1". Any other
1468 values result in 0 (false). */
1473 return (value
== 0 || *value
== '\0' ||
1474 (_rl_stricmp (value
, "on") == 0) ||
1475 (value
[0] == '1' && value
[1] == '\0'));
1479 rl_variable_bind (name
, value
)
1480 const char *name
, *value
;
1485 /* Check for simple variables first. */
1486 i
= find_boolean_var (name
);
1489 *boolean_varlist
[i
].value
= bool_to_int (value
);
1490 if (boolean_varlist
[i
].flags
& V_SPECIAL
)
1491 hack_special_boolean_var (i
);
1495 i
= find_string_var (name
);
1497 /* For the time being, unknown variable names or string names without a
1498 handler function are simply ignored. */
1499 if (i
< 0 || string_varlist
[i
].set_func
== 0)
1502 v
= (*string_varlist
[i
].set_func
) (value
);
1510 if (_rl_strnicmp (value
, "vi", 2) == 0)
1512 #if defined (VI_MODE)
1513 _rl_keymap
= vi_insertion_keymap
;
1514 rl_editing_mode
= vi_mode
;
1515 #endif /* VI_MODE */
1518 else if (_rl_strnicmp (value
, "emacs", 5) == 0)
1520 _rl_keymap
= emacs_standard_keymap
;
1521 rl_editing_mode
= emacs_mode
;
1531 if (value
&& *value
)
1533 FREE (_rl_comment_begin
);
1534 _rl_comment_begin
= savestring (value
);
1541 sv_compquery (value
)
1546 if (value
&& *value
)
1548 nval
= atoi (value
);
1552 rl_completion_query_items
= nval
;
1562 kmap
= rl_get_keymap_by_name (value
);
1565 rl_set_keymap (kmap
);
1572 sv_bell_style (value
)
1575 if (value
== 0 || *value
== '\0')
1576 _rl_bell_preference
= AUDIBLE_BELL
;
1577 else if (_rl_stricmp (value
, "none") == 0 || _rl_stricmp (value
, "off") == 0)
1578 _rl_bell_preference
= NO_BELL
;
1579 else if (_rl_stricmp (value
, "audible") == 0 || _rl_stricmp (value
, "on") == 0)
1580 _rl_bell_preference
= AUDIBLE_BELL
;
1581 else if (_rl_stricmp (value
, "visible") == 0)
1582 _rl_bell_preference
= VISIBLE_BELL
;
1589 sv_isrchterm (value
)
1592 int beg
, end
, delim
;
1598 /* Isolate the value and translate it into a character string. */
1599 v
= savestring (value
);
1600 FREE (_rl_isearch_terminators
);
1601 if (v
[0] == '"' || v
[0] == '\'')
1604 for (beg
= end
= 1; v
[end
] && v
[end
] != delim
; end
++)
1609 for (beg
= end
= 0; whitespace (v
[end
]) == 0; end
++)
1615 /* The value starts at v + beg. Translate it into a character string. */
1616 _rl_isearch_terminators
= (char *)xmalloc (2 * strlen (v
) + 1);
1617 rl_translate_keyseq (v
+ beg
, _rl_isearch_terminators
, &end
);
1618 _rl_isearch_terminators
[end
] = '\0';
1624 /* Return the character which matches NAME.
1625 For example, `Space' returns ' '. */
1632 static assoc_list name_key_alist
[] = {
1635 { "Escape", '\033' },
1637 { "Newline", '\n' },
1648 glean_key_from_name (name
)
1653 for (i
= 0; name_key_alist
[i
].name
; i
++)
1654 if (_rl_stricmp (name
, name_key_alist
[i
].name
) == 0)
1655 return (name_key_alist
[i
].value
);
1657 return (*(unsigned char *)name
); /* XXX was return (*name) */
1660 /* Auxiliary functions to manage keymaps. */
1664 } keymap_names
[] = {
1665 { "emacs", emacs_standard_keymap
},
1666 { "emacs-standard", emacs_standard_keymap
},
1667 { "emacs-meta", emacs_meta_keymap
},
1668 { "emacs-ctlx", emacs_ctlx_keymap
},
1669 #if defined (VI_MODE)
1670 { "vi", vi_movement_keymap
},
1671 { "vi-move", vi_movement_keymap
},
1672 { "vi-command", vi_movement_keymap
},
1673 { "vi-insert", vi_insertion_keymap
},
1674 #endif /* VI_MODE */
1675 { (char *)0x0, (Keymap
)0x0 }
1679 rl_get_keymap_by_name (name
)
1684 for (i
= 0; keymap_names
[i
].name
; i
++)
1685 if (_rl_stricmp (name
, keymap_names
[i
].name
) == 0)
1686 return (keymap_names
[i
].map
);
1687 return ((Keymap
) NULL
);
1691 rl_get_keymap_name (map
)
1695 for (i
= 0; keymap_names
[i
].name
; i
++)
1696 if (map
== keymap_names
[i
].map
)
1697 return ((char *)keymap_names
[i
].name
);
1698 return ((char *)NULL
);
1712 return (_rl_keymap
);
1716 rl_set_keymap_from_edit_mode ()
1718 if (rl_editing_mode
== emacs_mode
)
1719 _rl_keymap
= emacs_standard_keymap
;
1720 #if defined (VI_MODE)
1721 else if (rl_editing_mode
== vi_mode
)
1722 _rl_keymap
= vi_insertion_keymap
;
1723 #endif /* VI_MODE */
1727 rl_get_keymap_name_from_edit_mode ()
1729 if (rl_editing_mode
== emacs_mode
)
1731 #if defined (VI_MODE)
1732 else if (rl_editing_mode
== vi_mode
)
1734 #endif /* VI_MODE */
1739 /* **************************************************************** */
1741 /* Key Binding and Function Information */
1743 /* **************************************************************** */
1745 /* Each of the following functions produces information about the
1746 state of keybindings and functions known to Readline. The info
1747 is always printed to rl_outstream, and in such a way that it can
1748 be read back in (i.e., passed to rl_parse_and_bind ()). */
1750 /* Print the names of functions known to Readline. */
1752 rl_list_funmap_names ()
1755 const char **funmap_names
;
1757 funmap_names
= rl_funmap_names ();
1762 for (i
= 0; funmap_names
[i
]; i
++)
1763 fprintf (rl_outstream
, "%s\n", funmap_names
[i
]);
1765 free (funmap_names
);
1769 _rl_get_keyname (key
)
1775 keyname
= (char *)xmalloc (8);
1778 /* Since this is going to be used to write out keysequence-function
1779 pairs for possible inclusion in an inputrc file, we don't want to
1780 do any special meta processing on KEY. */
1783 /* XXX - Experimental */
1784 /* We might want to do this, but the old version of the code did not. */
1786 /* If this is an escape character, we don't want to do any more processing.
1787 Just add the special ESC key sequence and return. */
1797 /* RUBOUT is translated directly into \C-? */
1809 /* Now add special prefixes needed for control characters. This can
1810 potentially change C. */
1813 keyname
[i
++] = '\\';
1816 c
= _rl_to_lower (UNCTRL (c
));
1819 /* XXX experimental code. Turn the characters that are not ASCII or
1820 ISO Latin 1 (128 - 159) into octal escape sequences (\200 - \237).
1822 if (c
>= 128 && c
<= 159)
1824 keyname
[i
++] = '\\';
1827 keyname
[i
++] = (c
/ 8) + '0';
1831 /* Now, if the character needs to be quoted with a backslash, do that. */
1832 if (c
== '\\' || c
== '"')
1833 keyname
[i
++] = '\\';
1835 /* Now add the key, terminate the string, and return it. */
1836 keyname
[i
++] = (char) c
;
1842 /* Return a NULL terminated array of strings which represent the key
1843 sequences that are used to invoke FUNCTION in MAP. */
1845 rl_invoking_keyseqs_in_map (function
, map
)
1846 rl_command_func_t
*function
;
1851 int result_index
, result_size
;
1853 result
= (char **)NULL
;
1854 result_index
= result_size
= 0;
1856 for (key
= 0; key
< KEYMAP_SIZE
; key
++)
1858 switch (map
[key
].type
)
1861 /* Macros match, if, and only if, the pointers are identical.
1862 Thus, they are treated exactly like functions in here. */
1864 /* If the function in the keymap is the one we are looking for,
1865 then add the current KEY to the list of invoking keys. */
1866 if (map
[key
].function
== function
)
1870 keyname
= _rl_get_keyname (key
);
1872 if (result_index
+ 2 > result_size
)
1875 result
= (char **)xrealloc (result
, result_size
* sizeof (char *));
1878 result
[result_index
++] = keyname
;
1879 result
[result_index
] = (char *)NULL
;
1888 /* Find the list of keyseqs in this map which have FUNCTION as
1889 their target. Add the key sequences found to RESULT. */
1890 if (map
[key
].function
)
1892 rl_invoking_keyseqs_in_map (function
, FUNCTION_TO_KEYMAP (map
, key
));
1899 for (i
= 0; seqs
[i
]; i
++)
1901 char *keyname
= (char *)xmalloc (6 + strlen (seqs
[i
]));
1905 sprintf (keyname
, "\\e");
1907 /* XXX - experimental */
1908 sprintf (keyname
, "\\M-");
1910 else if (CTRL_CHAR (key
))
1911 sprintf (keyname
, "\\C-%c", _rl_to_lower (UNCTRL (key
)));
1912 else if (key
== RUBOUT
)
1913 sprintf (keyname
, "\\C-?");
1914 else if (key
== '\\' || key
== '"')
1917 keyname
[1] = (char) key
;
1922 keyname
[0] = (char) key
;
1926 strcat (keyname
, seqs
[i
]);
1929 if (result_index
+ 2 > result_size
)
1932 result
= (char **)xrealloc (result
, result_size
* sizeof (char *));
1935 result
[result_index
++] = keyname
;
1936 result
[result_index
] = (char *)NULL
;
1947 /* Return a NULL terminated array of strings which represent the key
1948 sequences that can be used to invoke FUNCTION using the current keymap. */
1950 rl_invoking_keyseqs (function
)
1951 rl_command_func_t
*function
;
1953 return (rl_invoking_keyseqs_in_map (function
, _rl_keymap
));
1956 /* Print all of the functions and their bindings to rl_outstream. If
1957 PRINT_READABLY is non-zero, then print the output in such a way
1958 that it can be read back in. */
1960 rl_function_dumper (print_readably
)
1967 names
= rl_funmap_names ();
1969 fprintf (rl_outstream
, "\n");
1971 for (i
= 0; name
= names
[i
]; i
++)
1973 rl_command_func_t
*function
;
1976 function
= rl_named_function (name
);
1977 invokers
= rl_invoking_keyseqs_in_map (function
, _rl_keymap
);
1982 fprintf (rl_outstream
, "# %s (not bound)\n", name
);
1987 for (j
= 0; invokers
[j
]; j
++)
1989 fprintf (rl_outstream
, "\"%s\": %s\n",
2000 fprintf (rl_outstream
, "%s is not bound to any keys\n",
2006 fprintf (rl_outstream
, "%s can be found on ", name
);
2008 for (j
= 0; invokers
[j
] && j
< 5; j
++)
2010 fprintf (rl_outstream
, "\"%s\"%s", invokers
[j
],
2011 invokers
[j
+ 1] ? ", " : ".\n");
2014 if (j
== 5 && invokers
[j
])
2015 fprintf (rl_outstream
, "...\n");
2017 for (j
= 0; invokers
[j
]; j
++)
2026 /* Print all of the current functions and their bindings to
2027 rl_outstream. If an explicit argument is given, then print
2028 the output in such a way that it can be read back in. */
2030 rl_dump_functions (count
, key
)
2034 fprintf (rl_outstream
, "\r\n");
2035 rl_function_dumper (rl_explicit_arg
);
2041 _rl_macro_dumper_internal (print_readably
, map
, prefix
)
2047 char *keyname
, *out
;
2050 for (key
= 0; key
< KEYMAP_SIZE
; key
++)
2052 switch (map
[key
].type
)
2055 keyname
= _rl_get_keyname (key
);
2056 out
= _rl_untranslate_macro_value ((char *)map
[key
].function
);
2059 fprintf (rl_outstream
, "\"%s%s\": \"%s\"\n", prefix
? prefix
: "",
2063 fprintf (rl_outstream
, "%s%s outputs %s\n", prefix
? prefix
: "",
2072 prefix_len
= prefix
? strlen (prefix
) : 0;
2075 keyname
= (char *)xmalloc (3 + prefix_len
);
2077 strcpy (keyname
, prefix
);
2078 keyname
[prefix_len
] = '\\';
2079 keyname
[prefix_len
+ 1] = 'e';
2080 keyname
[prefix_len
+ 2] = '\0';
2084 keyname
= _rl_get_keyname (key
);
2087 out
= (char *)xmalloc (strlen (keyname
) + prefix_len
+ 1);
2088 strcpy (out
, prefix
);
2089 strcpy (out
+ prefix_len
, keyname
);
2095 _rl_macro_dumper_internal (print_readably
, FUNCTION_TO_KEYMAP (map
, key
), keyname
);
2103 rl_macro_dumper (print_readably
)
2106 _rl_macro_dumper_internal (print_readably
, _rl_keymap
, (char *)NULL
);
2110 rl_dump_macros (count
, key
)
2114 fprintf (rl_outstream
, "\r\n");
2115 rl_macro_dumper (rl_explicit_arg
);
2121 rl_variable_dumper (print_readably
)
2127 for (i
= 0; boolean_varlist
[i
].name
; i
++)
2130 fprintf (rl_outstream
, "set %s %s\n", boolean_varlist
[i
].name
,
2131 *boolean_varlist
[i
].value
? "on" : "off");
2133 fprintf (rl_outstream
, "%s is set to `%s'\n", boolean_varlist
[i
].name
,
2134 *boolean_varlist
[i
].value
? "on" : "off");
2138 switch (_rl_bell_preference
)
2141 kname
= "none"; break;
2143 kname
= "visible"; break;
2146 kname
= "audible"; break;
2149 fprintf (rl_outstream
, "set bell-style %s\n", kname
);
2151 fprintf (rl_outstream
, "bell-style is set to `%s'\n", kname
);
2155 fprintf (rl_outstream
, "set comment-begin %s\n", _rl_comment_begin
? _rl_comment_begin
: RL_COMMENT_BEGIN_DEFAULT
);
2157 fprintf (rl_outstream
, "comment-begin is set to `%s'\n", _rl_comment_begin
? _rl_comment_begin
: RL_COMMENT_BEGIN_DEFAULT
);
2159 /* completion-query-items */
2161 fprintf (rl_outstream
, "set completion-query-items %d\n", rl_completion_query_items
);
2163 fprintf (rl_outstream
, "completion-query-items is set to `%d'\n", rl_completion_query_items
);
2167 fprintf (rl_outstream
, "set editing-mode %s\n", (rl_editing_mode
== emacs_mode
) ? "emacs" : "vi");
2169 fprintf (rl_outstream
, "editing-mode is set to `%s'\n", (rl_editing_mode
== emacs_mode
) ? "emacs" : "vi");
2171 /* isearch-terminators */
2172 if (_rl_isearch_terminators
)
2176 disp
= _rl_untranslate_macro_value (_rl_isearch_terminators
);
2179 fprintf (rl_outstream
, "set isearch-terminators \"%s\"\n", disp
);
2181 fprintf (rl_outstream
, "isearch-terminators is set to \"%s\"\n", disp
);
2187 kname
= rl_get_keymap_name (_rl_keymap
);
2189 kname
= rl_get_keymap_name_from_edit_mode ();
2191 fprintf (rl_outstream
, "set keymap %s\n", kname
? kname
: "none");
2193 fprintf (rl_outstream
, "keymap is set to `%s'\n", kname
? kname
: "none");
2196 /* Print all of the current variables and their values to
2197 rl_outstream. If an explicit argument is given, then print
2198 the output in such a way that it can be read back in. */
2200 rl_dump_variables (count
, key
)
2204 fprintf (rl_outstream
, "\r\n");
2205 rl_variable_dumper (rl_explicit_arg
);
2210 /* Return non-zero if any members of ARRAY are a substring in STRING. */
2212 substring_member_of_array (string
, array
)
2218 if (_rl_strindex (string
, *array
))