- Subject: after_key_hook not run by do_key()
- From: Jörg Sommer <joerg@xxxxxxxxxxxx>
- Date: Tue, 14 Nov 2006 20:39:43 +0000 (UTC)
Hi,
why is the before_key_hook but not the after_key_hook run by
keymap.c:do_key()? I would propose the following patch for register.sl,
but it does not work as I expected it.
#v+
Index: ../svn/jed-upstream/lib/register.sl
===================================================================
--- ../svn/jed-upstream/lib/register.sl (Revision 49)
+++ ../svn/jed-upstream/lib/register.sl (Arbeitskopie)
@@ -51,8 +51,44 @@
}
}
+private variable old_line, completion;
+private define reg_after_key_hook()
+{
+ variable oldbuf = whatbuf();
+ setbuf("*traceback*");
+ insert("reg_after_key_hook: -$oldbuf-\n"$);
+ setbuf(oldbuf);
+
+ if (whatbuf() != " <mini>")
+ return;
+
+ variable line = line_as_string();
+ if (line != old_line)
+ {
+ variable match = array_map(Integer_Type,
+ &strncmp(), completion, line, strlen(line));
+ match = match != 0;
+ if (sum(match) == 1)
+ {
+ delete_line();
+ insert( completion[wherefirst(match)] );
+ mini_exit_minibuffer();
+ }
+ }
+}
+
public define reg_insert_register ()
{
+ variable oldbuf = whatbuf();
+ setbuf("*traceback*");
+ insert("reg_insert_register: hook registered\n");
+ setbuf(oldbuf);
+
+ add_to_hook("_jed_after_key_hooks", ®_after_key_hook());
+ old_line = "";
+ completion = assoc_get_keys (Register_Buffer_Arrays);
+ try
+ {
variable name = get_register_name ();
if (name == NULL)
return;
@@ -66,6 +102,12 @@
insert (Register_Buffer_Arrays[name]);
vmessage ("Register '%s' inserted.", name);
}
+ catch UserBreakError;
+ finally
+ {
+ remove_from_hook("_jed_after_key_hooks", ®_after_key_hook());
+ }
+}
private variable Reg_Mark;
private variable Reg_Cline = color_number ("menu_selection");
#v-
Bye, Jörg.
--
Angenehme Worte sind nie wahr,
wahre Worte sind nie angenehm.
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2006 date index]
[2006 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]