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

From: Richard Philips <richard.philips.att.gmail.com>
Date: Thu, 5 Feb 2015 16:31:56 +0100

Hello Mitchell,

thank you for your elaborate answer.

I understand that implementing (traditional) keyboard macro's are not the
way to go.

But perhaps we can do something else.

I have now a macro-like feature based on awk:

- I ask for an AWK one-liner
- I filter the region through awk and replace the region with the output of
the program.

All works flawlessly thanks to built-in Textadept features (especially the
undo :-)

This system has some drawbacks:

- it is accomplished by using the shell
- AWK is not for everyone
- one-liners are sometimes not sufficient
- it is not possible to use functions which reside in the module system of

If we (you :-) could come up with a system with:

- easy entry of a Lua function in textadept itself, without an installation
- which can use some prebuilt functions and variables which can be used in
the Lua code
  (e.g. Line contains the current line, Lineno is the linenumber, Tokens is
a list with the tokens found on the current line , ...)
- a way to name the function
- a standard way to execute this function
- a way to save this function

Just asking :-),


On Thursday, February 5, 2015, Mitchell <m.att.foicica.com> wrote:

> 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 there).
> Cheers,
> Mitchell
> --
> You are subscribed to code.att.foicica.com.
> To change subscription settings, send an e-mail to code+help.att.foicica.com.
> To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.

You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 05 Feb 2015 - 10:31:56 EST

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