Re: [code] [textadept] Macros/add-ons for quick C/C++ function traversal?

From: Mitchell <m.att.foicica.com>
Date: Sat, 13 Oct 2018 16:26:09 -0400 (EDT)

Hi,

On Sat, 13 Oct 2018, Mitchell wrote:

> Hi ardi,
>
> On Sat, 13 Oct 2018, ardi wrote:
>
>> On Thu, Oct 11, 2018 at 2:55 PM Mitchell <m.att.foicica.com> wrote:
>> [...]
>>>
>>> buffer:search_anchor()
>>> local pos = buffer:search_next(buffer.FIND_REGEXP, regex)
>>> if pos ~= -1 then
>>> buffer:goto_pos(pos)
>>> else
>>> -- try another regex
>>> end
>>>
>>> where `regex` is your regex to match a function block. I'm pretty sure
>>> multi-line regex searches do not work,
>>> but you'd have to double-check. You can also use a loop to iterate over a
>>> table of regexes to try.
>>
>> I tried to start by implementing a simple function that searches the
>> '^{' regex backwards. I put it inside a "init.lua" file in
>> "~/.textadept/modules/common" while performing a require("common") in
>> my ~/.textadept/init.lua but however I'm making TA crash.
>>
>> The code in "~/.textadept/modules/common/init.lua" is as follows. Any
>> idea on why it's making TA crash?
>>
>> local function PrevCFunction()
>> buffer:search_anchor()
>> local pos = buffer:search_prev(buffer.FIND_REGEXP, '^{')
>> if pos ~= -1 then
>> buffer:goto_pos(pos)
>> end
>> end
>>
>> keys.f3 = PrevCFunction
>>
>> If the regex is '^[a-zA-Z]' then it doesn't crash...
>>
>> I'm guessing I'm doing something in an obviously wrong way, perhaps
>> I'm trying to do things quicker than I should.
>
> When I open up the command entry and type `buffer:search_prev(buffer.REGEXP,
> '^{')`, I'm not seeing a crash. Are you on Linux? If so, and if you have gdb
> installed, you can fetch a nightly build, run `gdb textadept` from a terminal
> in the Textadept directory, type the `r` command and hit enter, trigger the
> crash, and then type `bt` followed by enter for a stacktrace. Post the
> stacktrace here.

Never mind. You are not on Linux, you are on Mac. I should have known. Sorry for the brain fart.

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.
Received on Sat 13 Oct 2018 - 16:26:09 EDT

This archive was generated by hypermail 2.2.0 : Sun 14 Oct 2018 - 06:31:40 EDT