-
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
Never auto-switch to helm menu buffers #6159
Comments
I'm only half kidding when I say the easiest way to do this is to switch to ivy. |
I just got used to helm (coming from vim) so I'd rather not switch again... |
I believe I encountered this behaviour once in a layout and I was a bit confused since the helm buffer takes the whole screen. |
Yes. That's exactly what I'm talking about. As @sooheon pointed out, this doesn't happen with ivy. |
CC @bmag, our windows/buffers specialist 😃 |
Well, normally Helm buffers aren't killed after the Helm session ends. The problem here is that (defun spacemacs/alternate-buffer ()
"Switch back and forth between current and last buffer in the
current window."
(interactive)
(if (evil-alternate-buffer)
(switch-to-buffer (car (evil-alternate-buffer)))
(switch-to-buffer (other-buffer (current-buffer) t)))) We can replace |
Something more or less like this ? (do not trust this code too much) |
Spacemacs did define spacemacs-useless-buffers-regexp but it looks like it's not being used at much places. |
And btw, why is Helm not killing these annoying buffers after use in the first place ? Wouldn't it be better if we made Helm kill these buffers, either by adding some hook somewhere or directly from the upstream code ? |
You'll break |
SPC r l ? Cannot find this one in the docs or in spacemacs |
Or whatever |
@nixmaniack thanks for pointing that out, it led me to find (cl-loop for buffer in (window-prev-buffers)
;; with is evaluated once in the beginning of the loop
with displayed-buffer = (window-buffer)
;; return first non-useless buffer that isn't the window's current buffer
unless (or (eq buffer displayed-buffer)
(spacemacs/useless-buffer-p buffer))
return buffer)
I missed this part earlier. The function that replaces a killed buffer in all relevant windows is called Another approach we could use is to set the frame parameter |
As a side note, |
And so is there a clean way of burying these buffers somewhere, so that we don't have them in the way when cycling around ? I am not familiar with workspaces and layouts, is there a way of isolating all of the useless buffers (Helm, messages, etc...) in a separate layout / workspace in a way that we would not encounter them when using In addition, Helm generates quite a lot of these and does not seem to ever clean them. Are they really all needed for |
Yes, the clean way is to use
I don't know, but I won't be surprised if they are needed. Besides, sometimes it's useful to manually switch to helm buffers. For example, viewing the results of |
@deb0ch @Stebalien I think adding the following to (defun spacemacs/useful-buffer-p (buffer)
(not (spacemacs/useless-buffer-p buffer)))
(let ((buf-pred-entry (assq 'buffer-predicate default-frame-alist)))
(if buf-pred-entry
;; `buffer-predicate' entry exists, modify it
(setcdr buf-pred-entry #'spacemacs/useful-buffer-p)
;; `buffer-predicate' entry doesn't exist, create it
(push '(buffer-predicate . spacemacs/useful-buffer-p) default-frame-alist))) Edit: this seems to work as long as you only use one frame and don't create other frames |
@bmag Thanks. Unfortunately, I use emacs in daemon mode and almost always have multiple frames open. |
In that case, overriding It is the solution I am currently using (in my previous link) and it works quite well. When I want to purposely access a "useless" buffer I just use |
That depends on the problem you are trying to solve. The original issue is about However, I want to make it clear to everyone following this thread that once the issue with |
The bug in persp-mode was fixed, but it turns out I was wrong when I said that using
When I press I'd appreciate it if someone else would step up to solve this issue, as I will probably be too busy to work on it in the next few weeks. Otherwise, I'll get back to the issue when I'm less busy. |
Reported possible bug in |
I have addressed this bug in #6574: SPC TAB switching to random helm buffer: This is fixed.
SPC b d switching to random helm buffer: Partially fixed. When killing a buffer, it will be replaced by a useful buffer from the current layout. If there's no such buffer (e.g. last buffer in a layout), the killed buffer is replaced by a useful buffer from another layout. A scratch buffer is created in this case, but I couldn't get Emacs to switch to it. To make it show the scratch buffer we will need to modify |
Why wouldnt we want to do that ? |
It's probably not a good idea to redefine core Emacs functions that are relied upon by many packages to work a specific way. |
What @TheBB wrote, plus Emacs creates and kills a ton of temporary buffers, so |
Oh I see, in these conditions I agree it would be better not messing it up. But I find that showing the scratch buffer when you killed the last buffer of your layout is pretty important. It is very disconcerting to see a buffer from another layout appear, then you don't know if that buffer belonged to that layout in the first place. |
We could force each layout to have a scratch buffer, and make the buffer "unkillable" (or just generate a new scratch buffer immediately after the scratch buffer is killed). This way only the scratch buffer can be a "last buffer", and I think I've encountered the term "unkillable scratch buffer" somewhere. |
#6574 has been merged. |
NICE! I'm happy with this fix if you want to close this issue (I don't know if you want to keep it open for tracking reasons...). |
Fixed with released of Spacemacs v0.200. Let us know if you still have any problems with this issue. |
Description![:octocat: :octocat:](https://github.githubassets.com/images/icons/emoji/octocat.png)
If there's only one normal buffer left,
spacemacs/alternate-buffer
will switch to a random helm menu (if it exists). After deleting all buffers, spacemacs will switch to an old helm menu.Preferably, these would never be displayed. I don't know how fixable this is but it's kind of an annoying papercut.
Reproduction guide 🪲
SPC SPC
thenESC
to open and close a helm menu.SPC bd
to close all open buffers.Observed behaviour: 👀
I switch to old helm menus.
Expected behaviour: 💔
When deleting the last normal buffer, I expect to see a new
*scratch*
buffer. When callingspacemacs/alternate-buffer
on the last buffer, I expect nothing to happen.System Info 💻
The text was updated successfully, but these errors were encountered: