[code] Textadept: BUFFER_AFTER_SWITCH vs FILE_OPENED

From: Phil S. <accountz.att.mailbox.org>
Date: Sun, 4 Nov 2018 11:50:29 +0100

Thanks Mitchell, that's a good suggestion, have done so and there's no
noticable flickering as I feared, so that's cool.

I noticed the BUFFER_AFTER_SWITCH event isn't being triggered when a
(different than current-buf) file is opened which does tend to switch to
its new buffer. Can I assume this will stay that way (and script
accordingly with handlers for both when the former is to be caught) or
is there a risk of that changing so that whatever causes a buffer-switch
will trigger the buffer-switch events? (Well I guess I'd see it in the
release notes anyway.. =)

On 11/4/18 4:14 AM, Mitchell wrote:
> Hi Phil,
>
> On Sat, 3 Nov 2018, Phil S. wrote:
>
>> Hi Mitchell,
>>
>>> Yes, unfortunately that is the way to go for now.
>>
>> thanks & no prob, doing so was trivial and a breeze in the end. Next
>> question
>> popping up right now from the trenches  =)  I'm trying to implement the
>> editor-tab-context-menu-item "Close Others" (aka
>> close-all-but-this-tab) that
>> I've gotten quite accustomed to from most tabbed-GUIs out there
>> (including
>> numerous editors as well as browsers).
>>
>> Now, io.close_all_buffers won't help and io.close_buffer always
>> assumes the
>> current-buffer (it has no optional 'buffer_to_close' arg, so to
>> speak), so
>> I'd close in on buffer.delete but it comes with a FAT warning: "Do not
>> call
>> this function". Begging the question: what's the worst that could happen?
>
> I think the worst that could happen is data loss for unsaved changes.
>
> I would iterate through buffers, call `view:goto_buffer()` for each
> buffer you want to close, then call `buffer:close()`. In the end, you'll
> wind up with only one buffer -- the one you want to keep.
>
> 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 04 Nov 2018 - 05:50:29 EST

This archive was generated by hypermail 2.2.0 : Sun 04 Nov 2018 - 06:42:21 EST