aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/qregisters.cpp23
-rw-r--r--teco.ini2
2 files changed, 23 insertions, 2 deletions
diff --git a/src/qregisters.cpp b/src/qregisters.cpp
index 223a707..89b2afd 100644
--- a/src/qregisters.cpp
+++ b/src/qregisters.cpp
@@ -366,11 +366,32 @@ QRegisterStack::~QRegisterStack()
void
QRegisters::hook(Hook type)
{
+ QRegister *reg;
+
if (!(Flags::ed & Flags::ED_HOOKS))
return;
+ reg = globals["ED"];
+ if (!reg)
+ throw Error("Undefined ED-hook register (\"ED\")");
+
+ /*
+ * ED-hook execution should not see any
+ * integer parameters but the hook type.
+ * Such parameters could confuse the ED macro
+ * and macro authors do not expect side effects
+ * of ED macros on the expression stack.
+ * Also make sure it does not leave behind
+ * additional arguments on the stack.
+ *
+ * So this effectively executes:
+ * (typeM[ED]^[)
+ */
+ expressions.push(Expressions::OP_BRACE);
expressions.push(type);
- globals["0"]->execute();
+ reg->execute();
+ expressions.discard_args();
+ expressions.eval(true);
}
void
diff --git a/teco.ini b/teco.ini
index 73ca3a7..498bb67 100644
--- a/teco.ini
+++ b/teco.ini
@@ -8,7 +8,7 @@ EMQ[$SCITECOPATH]/color.tes
EMQ[$SCITECOPATH]/lexer.tes
! Automatic lexing using ED hooks !
-@0{
+@#ED{
Oadd,edit,close,quit
!add!
M[lexer.auto]