-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's the deal with "useful" and "useless" buffers? #6683
Comments
@bmag FYI this distinction is (at least originally) from vanilla Emacs and its packages. E,g. code for managing buffers which should [not] be garbage collected. So it's not Spacemacs initiated term. |
Presumably the useless buffer regexp is too permissive. It should perhaps be Does anyone know what the default |
By default there's no
I thought so too, at first, but then I remembered buffers can start with space or end with |
Sorry if what I'm writing sounds trivial but I try to catch up on this issue. Two possibilities:
The current implementation may fit better the first possibility but the less intrusive solution is the second one. Maybe reversing the filter priority may allow to go with the second possibility which makes more sense: we allow a lot of buffers by default until one (or a family) becomes annoying and we filter it out. |
Having a blacklist and an overriding whitelist (the first option) implies that all buffers are white by default, unless matched by the blacklist. The first option is equivalent to a base regexp that is very permissive (it just matches everything), so I think the two possibilities are: (am I'm just rephrasing what you meant?)
|
What about moving away from just using regexps to specify this useful/useless distinction? I have some use cases where I want to mark some asterisk buffers as useful but there's really no regex that can catch all these buffers (the concrete use case is notmuch buffers if you're wondering). It would be a lot easier if I could just set usefulness based on the major mode instead (since all notmuch buffers inherit from 1 mode). What about upgrading this list of regexps to a list of predicates that take a buffer perhaps? It would still support all the old regexp patterns, but would allow to determine usefulness based on other properties. |
@rgrinberg indeed it would be better to do this. I think we should make this useful/unuseful buffer feature an explicit feature, I mean we should have dedicated key bindings to use these lists, or we could use the universal prefix argument to use these lists. For instance |
I've run into an issue where I would like to define dired buffers as generally not useful, in the context of switching between buffers. There is no way to catch these with a regexp, since the buffer name is simply the visited folder's name, but a predicate could probably catch these easily. I figured out a way to achieve this using (defun my-buffer-file-name (oldfun buffer)
"Advise spacemacs/useful-buffer-p to exclude dired buffers"
(if (funcall oldfun buffer)
(not (with-current-buffer buffer
(derived-mode-p 'dired-mode)))))
(advice-add 'spacemacs/useful-buffer-p :around #'my-buffer-file-name) Took me forever to figure out that I had to use How about adding a hook in |
Alternatively, we could use a buffer-local variable. You could then use Note: the problem with the current heuristic is that the |
I've recently changed to using only:
since I'd rather see, e.g., a |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid! |
Spacemacs has a concept of "useful" and "useless" buffers. The rules for usefuleness are defined and implemented by variables
spacemacs-useful-buffers-regexp
,spacemacs-useless-buffers-regexp
and functionsspacemacs/useful-buffer-p
,spacemacs/useless-buffer-p
. I'm trying to understand what is the rule-of-thumb to decide whether a buffer is useful.I thought the rule-of-thumb is "if it's normal for the user to want to see this buffer, then it's useful". According to this logic, I plugged
spacemacs/useful-buffer-p
intobuffer-predicate
in commit fe60d0f, so functions likenext-buffer
,other-buffer
, etc. skip useless buffers. The commit caused two unexpected issues (#6678, #6681), so the question is: am I wrong, andspacemacs/useful-buffer-p
shouldn't be plugged intobuffer-predicate
? or am I right and it's the current imlpementation just doesn't implement the rules we want?Usefulness rules, according to current implementation:
that don't derive from
comint-mode
)*cider-repl
,*ansi-term
,*eshell
,*terminal
and end with*
(REPLs/shells that might not derive fromcomint-mode
)*
In short, currently useful buffers are files, directories, REPLs, shells and the scratch buffer. This excludes also buffers that the user interacts with, like notmuch buffers (see #6681),
*IBuffer*
and magit buffers.For context, in the previous situation, useful/useless buffer distinction was only used by SPC b n and SPC b p which where bound to are own implementations of
next-buffer
andprevious-buffer
. My commit was discussed in #6574 and fixes #6159.The text was updated successfully, but these errors were encountered: