Re: [code][textadept] Match brackets - imp.

From: Mitchell <m.att.foicica.com>
Date: Sun, 9 Jun 2019 09:49:38 -0400 (EDT)

Hi Lukas,

On Sat, 8 Jun 2019, Procházka Lukáš Ing. wrote:

> Hello Mitchell,
>
> just slight improvement to your "Match Brackets" (Ctrl+M) - to handle also
> brackets just one pos left of the current cursor pos, if not matched exactly
> at pos (e.g. text editor TextPad works like that);
> to be placed probably into "menu.lua" around ln. 93:
>
> ...
> {_L['_Match Brace'], function()
> - local match_pos = buffer:brace_match(buffer.current_pos, 0)
> - if match_pos >= 0 then buffer:goto_pos(match_pos) end
> -
> + local c_pos = buffer.current_pos
> + local pos = buffer:brace_match(c_pos, 0)
> +
> + if pos < 0 and c_pos > 0 then pos = buffer:brace_match(c_pos - 1, 0) end
> +
> + if pos >= 0 then buffer:goto_pos(pos) end
> +
> end},
> ...

Thanks. I will consider this change, but I do like the simplicity of the default behavior. In the meantime, you can override this in your *~/.textadept/init.lua* via something like:

   textadept.menu.menubar[_L['_Edit']][_L['_Match Brace']][2] = function()
     ...
   end

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 Sun 09 Jun 2019 - 09:49:38 EDT

This archive was generated by hypermail 2.2.0 : Mon 10 Jun 2019 - 06:40:54 EDT