rgieseke / textredux

Text-based interfaces for Textadept
http://rgieseke.github.io/textredux/
Other
59 stars 11 forks source link

Add function to close all currently selected buffers #68

Closed snoopy closed 3 years ago

snoopy commented 3 years ago

This function is a middle ground between closing all files from a directory and closing all buffers.
Useful because often times the close_directory function does not close enough but closing all would be too much.

rgieseke commented 3 years ago

That's a neat idea! How about checking if files are selected in the regular ctrl-d close buffer function? This would avoid having another short-cut.

rgieseke commented 3 years ago

And if it's nicely generalizable, it could also be used to open all selected files in the open dialog.

snoopy commented 3 years ago

That's a neat idea! How about checking if files are selected in the regular ctrl-d close buffer function? This would avoid having another short-cut.

How should this work exactly?
The close-selected functionality replaces the directory one or complements it via options? Can you clarify this?

rgieseke commented 3 years ago

I thought it could complement the single ctrl-d close file option. Check if there are multiple lines selected, if yes, close all selected ones.

rgieseke commented 3 years ago

I haven't really thought this through. There could be a handler for lists in general, which would be called if there are multiple lines selected.

snoopy commented 3 years ago

I thought it could complement the single ctrl-d close file option. Check if there are multiple lines selected, if yes, close all selected ones.

The current function doesn't check for multiple lines. It simply closes the currently selected file and does that until there is nothing selected anymore. Don't really see how to combine the two.

And if it's nicely generalizable, it could also be used to open all selected files in the open dialog.

I haven't really thought this through. There could be a handler for lists in general, which would be called if there are multiple lines selected.

IMO this would require a lot more work. Also opening and closing buffers is done in two different files so the handler would have to be added to some lower level file like buffer or list (instead of buffer_list as is done right now).

rgieseke commented 3 years ago

To be more precise, is it possible to check if there is a selection, then loop to close these selected buffers? I like the idea, but i think we should avoid having another short-cut. I think it could be integrated into the current close buffer functionality of the buffer-list.

Generalizing could happen later.

rgieseke commented 3 years ago

Are you using this at the moment? I think it's closing all open (or multiple) files if there is no current selection.

snoopy commented 3 years ago

Are you using this at the moment? I think it's closing all open (or multiple) files if there is no current selection.

Yes and yes. However this can be fixed easily so it will only close buffers once the user has entered something to filter the list.

However I think there is still a misunderstanding about this based on what each of us means by "selected".
When I say selected I mean the buffers that appear after the user entered something in the filter. Currently the function will then close all those "selected" buffers. This works by closing the buffer that the cursor is currently on until there are no more buffers.
Not sure what you meant by selected.

I do agree that introducing yet another keybind is a bad idea. Ideally it would simply replace the "close from directory" function (ctrl+D) as quite frankly it doesn't seem very useful. Especially when considering that the keybind for it was broken for a long time without anyone noticing.
A disadvantage I see currently is that because of the fuzzy filtering you sometimes end up closing buffers you didn't want to close. I had the idea to introduce a tagging feature that enables the user to select exactly the buffers he wants to close (something like nnn has). However that is probably a lot of work to implement so this is the next best thing if you want to quickly close a lot of same-ish buffers.

rgieseke commented 3 years ago

Ah, i see! I meant, selecting by using shift-cursor-down or -up. Which is kind-a going in that tagging direction you mention.

rgieseke commented 3 years ago

This pattern might be relevant for Textredux, too.

https://github.com/orbitalquark/textadept/commit/fcb9c717b3721251c52921b123687aa4d62174b1

rgieseke commented 3 years ago

Committed and removed the "close directory" function, thank you!