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

From: ardi <ardillasdelmonte.att.gmail.com>
Date: Sat, 13 Oct 2018 16:33:57 +0200

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.

Thanks!

ardi

-- 
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 - 10:33:57 EDT

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