[code] Textadept: scripting a 'close-all-tabs-but-this' contextmenu command

From: Phil S. <accountz.att.mailbox.org>
Date: Sat, 3 Nov 2018 23:24:53 +0100

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?

(An ugly hack would be to close-all then reopen-current but would lose
caret pos ---no prob, easily restorable--- and undo history --- probably
not anywhere as easily restorable?)

Thoughts?

On 11/3/18 12:51 AM, Mitchell wrote:
> Hi Phil,
>
> On Sat, 3 Nov 2018, Phil S. wrote:
>
>> Thanks much, somehow this notation didn't quite occur to me this way
>> during
>> experimentations. Much obliged!
>>
>>
>> Other one-off question: there's seemingly no FILE_CLOSED event and a
>> BUFFER_DELETED handler does not get any (non-nil) args. To figure out
>> which
>> file was just closed, do I need to manually keep track of open buffers
>> and
>> then diff between previous-all-open-buffers and
>> current-all-open-buffers on
>> every BUFFER_DELETED firing?
>
> Yes, unfortunately that is the way to go for now.
>
> 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 Sat 03 Nov 2018 - 18:24:53 EDT

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