Re: [code] [textadept] Keyboard macro's

From: Mitchell <>
Date: Thu, 5 Feb 2015 08:44:19 -0500 (EST)

Hi Richard,

On Thu, 5 Feb 2015, Richard Philips wrote:

> Hi All,
> the one thing I miss in Textadept are keyboard macro's.
> I wrote Lua code to start up sed scripts and awk scripts on regions of text
> but keyboard macro's remain very useful.
> Now, I seem to remember that, once upon a time, there were keyboard macro's
> in Textadept: Scintilla certainly has support for them.
> Am I the only person missing this feature ?
> What would it take to bring them back ?

Caution: long technical stuff ahead :)

I've actually spent a good chunk of time looking into this. The main
problem is that Scintilla's macros operate at the "message level" and many
messages that Textadept makes use of are not recorded. In some simple
cases, such as moving the caret and inserting some text, Scintilla reports
the movement and insertion separately. So far, no problem, and the macro
can be recorded. However, many of Textadept's features combine calls to
Scintilla that are not recorded, and not recorded in context. For example,
take something simple like Textadept's character transpose: it uses some
checks to determine whether the caret is at a line ending and based on
that, transposes characters using a call that Scintilla does not record.
Not only is the actual transposition not recorded, but the end-of-line
checking is also not recorded. The only solution is to use Scintilla's
macro recording in conjunction with hooking into Textadept's key bindings
to determine which functions are called. This can be done, but it's messy.
The real problem comes with event handlers. Consider
`textadept.editing.AUTOINDENT`. When Scintilla macros are enabled, a bunch
of messages called by the autoindent feature will be recorded when "Enter"
is pressed! This is highly undesirable in macro playback because
autoindent may indent wrongly, not at all, or do something bizarre in a
different context. The solution here is to wrap all event handlers in a
global "if macro_is_recording then return end" construction, which is
tedious and hard to maintain. It's also worth considering whether or not
events should be emitted during macro playback (e.g. when entering an
autopaired character like '[', its complement is entered too).

All of that puts me in a very difficult position to implement macros
effectively, and I'm not confident it would behave as expected in all
instances. I think we must stick to writing Lua code to function as
macros, even though I know it's undesirable in some cases (I've been


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Thu 05 Feb 2015 - 08:44:19 EST

This archive was generated by hypermail 2.2.0 : Fri 06 Feb 2015 - 06:26:47 EST