Marking and acting on non-adjacent buffers
acegallagher opened this issue · 4 comments
Hey! Incredible job on this, you're a more tenacious person than I am. I tried to configure ibuffer to do exactly what you've made bufler do and your implementation is so much better. However there's one feature I miss.
Having the marking of buffers and all associated features would be absolutely killer. I often regex mark ibuffers by term mode, and other such things. In particular, the following functions are really useful for managing buffers. The keybindings also match the other killer emacs package, dired:
From ibuffer
‘S’ - Save the marked buffers.
‘A’ - View the marked buffers in the selected frame.
‘H’ - View the marked buffers in another frame.
‘V’ - Revert the marked buffers.
‘T’ - Toggle read-only state of marked buffers.
‘L’ - Toggle lock state of marked buffers.
‘D’ - Kill the marked buffers.
‘M-s a C-s’ - Do incremental search in the marked buffers.
‘M-s a C-M-s’ - Isearch for regexp in the marked buffers.
‘r’ - Replace by regexp in each of the marked
‘Q’ - Query replace in each of the marked buffers.
‘P’ - Print the marked buffers.
‘O’ - List lines in all marked buffers which match
‘X’ - Pipe the contents of the marked
‘N’ - Replace the contents of the marked
‘E’ - Evaluate a form in each of the marked buffers.
‘k’ - Remove the marked lines from the Ibuffer buffer,
‘x’ - Kill all buffers marked for deletion.
‘m’ - Mark the buffer at point.
‘t’ - Unmark all currently marked buffers, and mark all unmarked buffers.
‘* c’ - Change the mark used on marked buffers.
‘u’ - Unmark the buffer at point.
‘DEL’ - Unmark the previous buffer.
‘M -DEL’ - Unmark buffers marked with MARK.
‘U’ - Unmark all marked buffers.
‘* M’ - Mark buffers by major mode.
‘* u’ - Mark all "unsaved" buffers.
‘* m’ - Mark all modified buffers,
‘* s’ - Mark all buffers whose name begins and
‘* e’ - Mark all buffers which have
‘* r’ - Mark all read-only buffers.
‘* /’ - Mark buffers in ‘dired-mode’.
‘* h’ - Mark buffers in ‘help-mode’, ‘apropos-mode’, etc.
‘.’ - Mark buffers older than ‘ibuffer-old-time’.
‘d’ - Mark the buffer at point for deletion.
‘% n’ - Mark buffers by their name, using a regexp.
‘% m’ - Mark buffers by their major mode, using a regexp.
‘% f’ - Mark buffers by their filename, using a regexp.
‘% g’ - Mark buffers by their content, using a regexp.
‘% L’ - Mark all locked buffers.
From dired:
m dired-mark
t dired-toggle-marks
u dired-unmark
DEL dired-unmark-backward
C-t f image-dired-mark-tagged-files
M-{ dired-prev-marked-file
M-} dired-next-marked-file
% g dired-mark-files-containing-regexp
% m dired-mark-files-regexp
* ! dired-unmark-all-marks
* % dired-mark-files-regexp
* * dired-mark-executables
* / dired-mark-directories
* ? dired-unmark-all-files
* @ dired-mark-symlinks
* N dired-number-of-marked-files
* c dired-change-marks
* m dired-mark
* s dired-mark-subdir-files
Hi,
Thanks for the kind words. I'm glad you like it.
Yes, marking non-adjacent buffers would be a useful feature. However, Bufler uses magit-section
for displaying buffer lists, and it doesn't support that. Like Magit, it only supports marking entries that are adjacent.
This could probably be worked around by keeping a separate list of marked buffers and displaying marks in a column, similar to Ibuffer. Of course, that would need to be deconflicted with magit-section
's own markings.
That would be, I think, a non-trivial amount of work. And such work might be better aimed at enhancing magit-section
to support non-adjacent marking itself, so Bufler could get that feature "for free."
So, supporting non-adjacent marking is probably not a feature I will work on anytime soon, as I have many other ideas to get to first.
P.S. Re-reading your comment, I get the impression that you aren't aware that Bufler already supports marking of adjacent buffers and groups. Press C-SPC
on a buffer to mark it, then move point to continue marking others. Then you can act on marked entries, e.g. k
to kill buffers. It's also trivial to add additional commands that apply to marked buffers; see the source code.
Hey alphapapa,
Even more incredible that you take the time to write such a thoughtful reply to a github feature request.
I was aware of the marking feature in bufler, and I've been trying to use it. I'm a scientist that uses emacs as an IDE for data analysis development, and as such I typically have multiple terminals, code buffers, data files, and directories, all open for the same project. I'm working on customizing bufler groups to support this more easily but in the end the buffers I want to run an operation on are rarely next to each other and marking/filtering/regex is really powerful (to for example kill all terminals across all projects).
Right now I just fire up ibuffer manually and do these types of operations and that works alright-enough. Interesting implementation concerns, you're a sharp person for reusing the magit code and I'm sure your implementation greatly benefits. The selection of adjacent buffers makes sense when dealing with files committed in git, where neighboring in the filesystem probably means neighbors in git operations also. And I suppose you wrote bufler with primarily with VC projects in mind. Maybe I'll poke the magit creators about selecting non-adjacent files and see what they think.
I can't wait to see the other ideas you implement, happy coding, and thanks for responding here.
Thanks for the kind words.
I was aware of the marking feature in bufler, and I've been trying to use it. I'm a scientist that uses emacs as an IDE for data analysis development, and as such I typically have multiple terminals, code buffers, data files, and directories, all open for the same project. I'm working on customizing bufler groups to support this more easily but in the end the buffers I want to run an operation on are rarely next to each other and marking/filtering/regex is really powerful (to for example kill all terminals across all projects).
Right now I just fire up ibuffer manually and do these types of operations and that works alright-enough.
Thanks for sharing that, that sounds very interesting. I guess Bufler isn't yet suitable for that specific use case. As I wrote in the readme, Ibuffer is a mature project, and Bufler is far from feature parity with it.
Interesting implementation concerns, you're a sharp person for reusing the magit code and I'm sure your implementation greatly benefits. The selection of adjacent buffers makes sense when dealing with files committed in git, where neighboring in the filesystem probably means neighbors in git operations also
Yes, magit-section
grew out of Magit, so that's probably part of it.
I think what's needed is for either magit-section
to have more sophisticated marking tools, or we need another library that does similar things. I've been looking at the built-in Widget and tree-widget libraries for ideas. Those packages don't seem easy to use, and I can see why Jonas went with magit-section instead.
And I suppose you wrote bufler with primarily with VC projects in mind.
No, I just added a VC column because it was easy and useful.
Anyway, the idea is for Bufler to allow very flexible, powerful rules to group buffers as usefully as possible, automatically. I plan to make more enhancements to these tools in the future, e.g. to make it easier to have multiple bufler-list views with different grouping rules applied. That might be useful for your specific needs, so you could have different rules for different projects.
Maybe I'll poke the magit creators about selecting non-adjacent files and see what they think.
There's probably an issue about it already on the Magit repo, or something like it, ISTR. Please link it if you can dig it up again.
Please continue to share any feedback. Thanks.
FYI, I recently made https://github.com/alphapapa/taxy.el out of my plans to factor out parts of Bufler. I think implementing non-adjacent marking can be done fairly simply by defining a column in taxy-magit-section
and then writing commands that act appropriately, depending on whether any buffers are individually marked. I'll look at this in the future, after converting Bufler to use Taxy.