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

From: Mitchell <m.att.foicica.com>
Date: Sat, 3 Nov 2018 23:14:45 -0400 (EDT)

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 Sat 03 Nov 2018 - 23:14:45 EDT

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