Re: [textadept] Feature request: intelligently exclude single quote character from AUTOPAIR

From: Robert <ro....at.web.de>
Date: Mon, 5 Sep 2011 21:15:36 +0200

On Mon, Sep 5, 2011 at 3:52 PM, mitchell <c....at.caladbolg.net> wrote:
> Hi,
>
> On Sun, 4 Sep 2011, phayz wrote:
>
>> I often use Textadept not for code editing but for editing of files in
>> XML format, most often documentation. Within this documentation I'm
>> often using the single quote character (') in English to indicate
>> ownership - e.g. Mitchell's dog. :D When I type the single quote
>> character here though, it's automatically paired and I need to delete
>> the second one.
>>
>> My feature request is that the single quote character only be AUTOPAIR-
>> ed if the character is not immediately followed by the letter 's'.
>
> When you are not writing code, are you using the default 'container' lexer?
> If so, I will add logic to the code to not autopair quotes in the
> 'container' lexer. That would solve your problem and not require any
> complicated logic.
>

Something along the lines of

events.connect(events.CHAR_ADDED, function()
  local buffer = buffer
  local s_char = string.char
  if s_char(buffer.char_at[buffer.current_pos - 3]):match('%w\\') then
    if s_char(buffer.char_at[buffer.current_pos - 2]) == "'" and
       s_char(buffer.char_at[buffer.current_pos]) == "'" then
         buffer.clear()
    end
  end
end)

might work. Should delete the ' to the right if before the left ' is
either a char or a escape character when inserting another char or a
space.
Howeever, no idea if it's a good idea to check this on every char insert.

Robert

> mitchell
>
>>
>> The logic behind this might be something like:
>>
>> (In a-character-has-been-pressed module)
>> if previous character was a single quote then
>>  if the current character is "s"
>>   then insert into the buffer "s"
>>  else to the standard AUTOPAIR logic
>>
>> I'm re-evaluating Textadept as my primary editor and if I stick with
>> it I'll try adding this logic to AUTOPAIR code myself. If someone else
>> wants to try it themselves I'd be happy for that too.
>>
>> --
Received on Mon 05 Sep 2011 - 15:15:36 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:22:18 EST