Ilya Zakharevich on Sat, 7 Nov 1998 02:01:03 -0500 (EST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Electric parens in GP


This patch leaves the default state of electric parens as it is,
leaves `pari-matched-insert' .initrc command as it is, but enables
switching electric parens off/on at run time by 

   meta 0 (

and 

   meta - (

correspondingly.

Enjoy,
Ilya

--- ./src/gp/gp_rl.c~	Fri Nov  6 10:08:30 1998
+++ ./src/gp/gp_rl.c	Sat Nov  7 01:54:22 1998
@@ -50,7 +50,8 @@ static entree *current_ep = NULL;
 static int pari_rl_back;
 extern RLCI rl_last_func;
 static int do_args_complete = 1;
-static int do_matched_insert = 1;
+static int do_matched_insert = 0;
+static int did_init_matched = 0;
 
 #ifndef HAS_RL_SAVE_PROMPT
 void _rl_save_prompt() {}
@@ -121,6 +122,16 @@ pari_rl_matched_insert(int count, int ke
 }
 
 static int
+pari_rl_default_matched_insert(int count, int key)
+{
+    if (!did_init_matched) {
+	did_init_matched = 1;
+	do_matched_insert = 1;
+    }
+    return pari_rl_matched_insert(count, key);
+}
+
+static int
 pari_rl_forward_sexp(int count, int key)
 {
   int deep = 0, dir = 1, move_point, lfail;
@@ -557,7 +568,7 @@ init_readline()
   Defun("short-help", (Function*) rl_short_help, -1);
   Defun("long-help", (Function*) rl_long_help, -1);
   Defun("pari-complete", (Function*) pari_rl_complete, '\t');
-  Defun("pari-matched-insert", (Function*) pari_rl_matched_insert, -1);
+  Defun("pari-matched-insert", (Function*) pari_rl_default_matched_insert, -1);
   Defun("pari-forward-sexp", (Function*) pari_rl_forward_sexp, -1);
   Defun("pari-backward-sexp", (Function*) pari_rl_backward_sexp, -1);
 
@@ -565,10 +576,8 @@ init_readline()
   Bind('H', (Function*) rl_long_help,  emacs_meta_keymap);
   Bind('h', (Function*) rl_short_help, vi_movement_keymap);
   Bind('H', (Function*) rl_long_help,  vi_movement_keymap);
-#if 0
   Bind('(', (Function*) pari_rl_matched_insert, emacs_standard_keymap);
   Bind('[', (Function*) pari_rl_matched_insert, emacs_standard_keymap);
-#endif
   Bind(6, (Function*) pari_rl_forward_sexp,  emacs_meta_keymap); /* M-C-f */
   Bind(2, (Function*) pari_rl_backward_sexp, emacs_meta_keymap); /* M-C-b */