Re: [code] [textadept] Buffer/view properties

From: Mitchell <>
Date: Tue, 3 Feb 2015 13:41:44 -0500 (EST)

Hi Robert,

On Sat, 31 Jan 2015, Robert Gieseke wrote:

> Hi Mitchell,
> Am 30/01/15 um 17:41 schrieb Mitchell:
>> On Mon, 26 Jan 2015, Mitchell wrote:
>>> On Mon, 26 Jan 2015, Robert Gieseke wrote:
>>>> would you consider a patch that made Textadept buffers remember
>>>> properties that are now view-specific like margins, wrap mode, eol etc.?
>>>> Likely similar to what's already done for caret and selection position.
>> I've thought some more on this and come up with a potential problem. If,
>> for example, `buffer.wrap_mode` would be a per-buffer setting, what
>> happens when you select it from the menu? Would the menu only change that
>> buffer's setting? If so, then the user would have to toggle the setting
>> for all buffers, which obviously is undesirable. If on the other hand
>> Textadept were to iterate through existing buffers and toggle wrap mode,
>> what happens for new buffers? They would be unwrapped by default. This
>> issue seems to require keeping track of a general state (or perhaps a
>> "per-view" state, as is the default when it comes to these things) and
>> applying it to new buffers. I'm not sure how comfortable I am with an idea
>> like that. (Also, Textadept would need to keep track of a list of
>> properties that may change with each release of Scintilla; I'm not a fan
>> of such bookkeeping.)
>> It's an interesting problem that has no immediate solution, but I'm still
>> open to a good one.
> In my testing I already had some issues (with margins for example) I
> have to investigate further, but the following seems to do what I had in
> mind for `wrap_mode` (should be using functions of course).
> -- Save buffer properties.
> events.connect(events.BUFFER_BEFORE_SWITCH, function()
> local buffer = buffer
> buffer._wrap_mode = buffer.wrap_mode
> end)
> events.connect(events.VIEW_BEFORE_SWITCH, function()
> local buffer = buffer
> buffer._wrap_mode = buffer.wrap_mode
> end)
> -- Restore buffer properties.
> events.connect(events.BUFFER_AFTER_SWITCH, function()
> local buffer = buffer
> if type(buffer._wrap_mode) == 'number' then
> buffer.wrap_mode = buffer._wrap_mode
> end
> end)
> events.connect(events.VIEW_AFTER_SWITCH, function()
> local buffer = buffer
> if type(buffer._wrap_mode) == 'number' then
> buffer.wrap_mode = buffer._wrap_mode
> end
> end)
> When I change the setting in one view, it is updated as well, once I
> switch to the same buffer in another view.
> I would have thought that the buffer-specific settings would move to the
> buffer menu for changing a buffer for a session. For me it's mainly
> being able to view a file with settings, an Ascii table or badly
> indented code with very long lines when otherwise having wrap_mode enabled.
> For new buffers or opening a file the default from `properties.lua`
> would apply. Maybe one could make editing `properties.lua` more visible
> by adding it to the menu (though this would require auto-creating it (if
> not existing) similar to the main `init.lua`).

Okay, that all is reasonable. Looking at the "View" menu, I think "Toggle
View EOL", "Toggle Wrap Mode", and "Toggle View Whitespace" can be tweaked
to be buffer-specific properties based on your method.

Does anyone have any objections? Consider "wrap mode": currently toggling
wrap mode wraps *all* buffers in *a particular view* -- even newly
created/opened buffers. The new proposal makes toggling wrap mode wrap
*only* the current buffer in *any* other view -- newly created/opened
views will have wrap mode turned off by default (unless overridden in
`~/.textadept/properties.lua`.) I know some editors like SciTE toggle wrap
mode for all buffers at once, so this is why I'm asking for objections.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Tue 03 Feb 2015 - 13:41:44 EST

This archive was generated by hypermail 2.2.0 : Wed 04 Feb 2015 - 06:44:40 EST