Re: [code] [textadept] Disable modification flag of a buffer

From: Mitchell <m.att.foicica.com>
Date: Wed, 12 Sep 2018 08:49:59 -0400 (EDT)

Hi Lukas,

On Wed, 12 Sep 2018, Procházka Lukáš Ing. wrote:

> Hello,
>
> I'm using a buffer which has similar function as '[Message Buffer]' - it is
> read-only (and should have click-on-line functionality in the future).
>
> ---- (snip)
> buf = buffer.new()
> buf._type = '[CodExp]' -- Inspired by '[Message Buffer]'
> ----
>
> I modify the buffer content by:
>
> ---- (snip)
> buf.read_only = false
> buf:set_text(text or "")
> buf.read_only = true
> ----
>
> The problem is that anytime I modify the buffer content, its '.modify'
> (read-only value) changes to 'true' and so when quitting TA, TA is asking for
> a file name to save the buf content (or discard changes).
>
> How to:
>
> - set (force) buffer state to "not modified"?
>
> - tell TA to ignore this buffer when asking for saving changes?
> (suggestion: could be e.g. when 'buffer.ignore_changes' is 'true' or
> when buf has '._type' of mask '^%[.+%]$').

After setting your buffer text, call `buffer:set_save_point()`. That clears the modify flag.

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 Wed 12 Sep 2018 - 08:49:59 EDT

This archive was generated by hypermail 2.2.0 : Thu 13 Sep 2018 - 06:33:07 EDT