Re: [textadept] I'd like to alter AutoPair's behaviour for some files

From: Robert <ro....at.web.de>
Date: Tue, 7 Dec 2010 09:34:44 +0100

On Tue, Dec 7, 2010 at 2:36 AM, phayz <russelldicken....at.gmail.com> wrote:
> I understand that when coding, it makes sense to ensure that
> characters such as " ' " or " " " are entered in pairs, as is done
> automatically by Textadept by default (via the AutoPair option). Most
> of my use of Textadept is not coding however but writing of structured
> documents. When I am writing and enter an apostrophe " ' ", I usually
> don't want two of them entered.
>
> A sample structured document format I work with is AsciiDoc, the home
> page of which can be found here - http://www.methods.co.nz/asciidoc/.
> It's very much like the Markdown markup language. For these files I
> have been giving them an extension of .ASC, although this is a
> personal convention. I know in the Textadept manual it explains how to
> create new MIME types for Textadept. I have looked at a few examples
> and I'm still unsure if this would allow me to customise the AutoPair
> option so that when editing an AsciiDoc document, this option is set
> to 'False'.
>
> Any help or suggestions are welcome.
>
>
> - Russell
>

You could try something like this, using the lua lexer as an example.

events.connect('buffer_after_switch',
  function()
    if buffer._lexer == 'lua' then
      _m.textadept.editing.AUTOPAIR = false
    else
      _m.textadept.editing.AUTOPAIR = true
    end
  end
  )

events.connect('file_opened',
  function()
    if buffer._lexer == 'lua' then
      _m.textadept.editing.AUTOPAIR = false
    end
  end
)

Mitchell,
I tried this with buffer:get_lexer(). This caused Textadept to hang
when I opened a new file. Is there something that needs to be checked
additionally in this "private_lexer_call", whatever that means?

Robert
Received on Tue 07 Dec 2010 - 03:34:44 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:55:15 EST