syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

"Selecting deleted buffer" error upon common commands #8729

Open mathpunk opened 7 years ago

mathpunk commented 7 years ago

"Selecting deleted buffer" error upon many commands (search, buffer, file, help...)

Description :octocat:

Everything works normally on startup. But at some point --- I have not found the triggering condition --- commands like SPC f f or SPC b b or even / result in a "Selecting deleted buffer" message instead of the desired behavior.

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: "Selecting deleted buffer" is the response to many basic commands. Sometimes, but not always, one or more sometimes-incorrectly closed (defun dotspacemacs/emacs-custom-settings ()) ...) forms appear in the .spacemacs file, which I've been deleting manually to get the .spacemacs file to not crash so my configuration gets loaded correctly. Maybe this issue is like #7898 ?

Expected behaviour: :heart: :smile: Stuff works.

System Info :computer:

Backtrace :paw_prints:

I don't know how to find a backtrace because the bug kills my ability to navigate buffers.
mathpunk commented 7 years ago

Update: I'm trying to find a minimal example of something that breaks everything. I went from working state, to deleting rows from one org-mode table and pasting them below another org-mode table, and saved, and that resulted in breakage. I have a couple functions that run on save which I will also try commenting out from my config.

mathpunk commented 7 years ago

A-ha! With these two functions no longer running after save, pasting rows and saving no longer breaks everything. These are the only 'after-save-hook functions I had.

;; Tangle Org files when we save them
;; (defun tangle-on-save-org-mode-file()
;;   (when (string= (message "%s" major-mode) "org-mode")
;;     (org-babel-tangle)))

;; (add-hook 'after-save-hook 'tangle-on-save-org-mode-file)
(defun to-agenda-on-save-org-mode-file()
  (when (string= (message "%s" major-mode) "org-mode")
    (org-agenda-file-to-front)))

;; (add-hook 'after-save-hook 'to-agenda-on-save-org-mode-file)
jdelStrother commented 7 years ago

I've found that simply running org-agenda-file-to-front is enough to trigger this

fiveNinePlusR commented 7 years ago

The selecting deleted buffer happens to me from time to time as well and I cannot do a spc b b or pretty much anything until I restart emacs.

duianto commented 7 years ago

Killing a ranger buffer and closing the new frame that was opened, puts you in a state where a lot of key bindings show the message: Selecting deleted buffer

Reproduction steps with the ranger layer installed

Open a ranger "session": SPC a r Kill the selected ranger buffer: SPC b d The messages buffer shows:

Ranger window was overwritten. Redirecting window to new frame

and a new frame opens, where the key bindings seem to work as expected. But when the new frame is closed: SPC q f (SPC q z in the master branch). Then the initial frame gets selected and when SPC is pressed, then this message is shown:

Error running timer ‘which-key--update’: (error "Selecting deleted buffer")

The frame splits with the bottom window showing <M> where the window number used to be. The top window shows 1 as the window number. The <M> window doesn't close when the cursor is in the top window and SPC w m is pressed to maximize that window.

A lot of key bindings show these messages (without opening a new frame):

Ranger window was overwritten. Redirecting window to new frame apply: Selecting deleted buffer

SPC q r doesn't restart, it just shows the selecting deleted buffer message. But one way of restarting, is to open a new frame SPC w F, where SPC q r works.

Sometimes it's also possible to get back to normal, without restarting, by pressing SPC b n to switch to the ranger buffer. Or if the ranger buffer isn't found then open a new ranger buffer SPC a r. Press q to close it.

System Info :computer:

duianto commented 7 years ago

I'm unable to reproduce the "Selecting deleted buffer" issue with ranger. The steps above, seems to have been related to another ranger issue, where the middle column, didn't show any text for files and some folders. That issue was fixed a couple of days ago.

duianto commented 7 years ago

Maybe this could be helpful:

It seems most likely that you've captured the buffer object for the original (and now deleted) buffer, and have passed that object to with-current-buffer, rather than the object for the new buffer. – phils Jun 27 '14 at 5:52

https://stackoverflow.com/questions/24443236/selecting-deleted-buffer-error-in-elisp?rq=1#comment37825323_24443236

hendrikcech commented 7 years ago

I encountered this bug for the first time a few days ago. Mostly happens when working in org-mode, but can't nail it down any further yet. I can confirm that running org-agenda-file-to-front is enough to trigger this behavior. I'm on the develop branch, using Emacs 25.1 on OS X 10.11.6 if that helps.

Has anyone found a workaround that isn't "restart emacs"?

jb55 commented 6 years ago

This happens a lot for me recently. Only way to fix is to restart. Really annoying.

jb55 commented 6 years ago

This reproduces it for me every time:

  1. Start Spacemacs
  2. SPC : customize-variable
  3. org-adapt-indentation
  4. Set to off
  5. Click Apply and Save
wizmer commented 6 years ago

Any call to customize-variable followed by Apply and Save triggers the bug for me.

jb55 commented 6 years ago

Yeah this is getting exceedingly annoying. It sometimes works and sometimes doesn't. Mostly doesn't.

I even tried wiping my .spacemacs to a clean slate and it was still doing it ???

tekacs commented 6 years ago

This occurs for me if I open a multi-term and kill the buffer (with SPC b d). The only way I can close multi-terms is by sending an EOF to the terminal, which isn't feasible if the application in the terminal has crashed or is spewing a lot of output, for example (but this fails even if the shell is responding).

As above, having to kill the entire session and resurrect is... not fun. :confused:

kprav33n commented 6 years ago

Turning off the Spacemacs layer nlinum made my problem go away. Looks like some timer in nlinum implementation was causing this issue. By default, Spacemacs comes with nlinum-relative to enable line number support. I didn't know why I added nlinum layer. I didn't notice any functionality missing after I removed that layer from my configuration.

jb55 commented 6 years ago

Turning off the Spacemacs layer nlinum made my problem go away

I don't have this layer and I still have this problem :[

jb55 commented 6 years ago

I was able to fix this my moving my custom-set-variables into their own file as described here: https://github.com/syl20bnr/spacemacs/issues/7891#issuecomment-285958745

PhoenixStarEclipse commented 6 years ago

I had the same problem, and triggering it only needs moving the cursor to some space character and wait for a few seconds.

soverton commented 5 years ago

I get this when calling "cider-jack-in" and the command "sesman-quit" seems to fix it.

temco commented 5 years ago

I get this when calling "cider-jack-in" and the command "sesman-quit" seems to fix it.

Yes, it works. I cider-jack-in the cider-nrepl and then cider-connect to another repl, then I kill the latter buffer. When I cider-connect the latter repl again, the problem is produced. Then I new a frame, sesman-quit it, and cider-connect again, it works.

npit commented 4 years ago

I'm getting this error when invoking any agenda view. Using the develop branch.

duianto commented 4 years ago

Opening org agenda views under the prefix: SPC a o o

works for me without any errors.

Windows 1903
#### System Info :computer:
- OS: windows-nt
- Emacs: 26.3
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. c3f13d039)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(autohotkey auto-completion command-log emacs-lisp git helm helpful html imenu-list
            (java :variables java-backend 'meghanda)
            javascript latex lsp
            (markdown :variables markdown-live-preview-engine 'vmd markdown-command "vmd")
            multiple-cursors
            (org :variables org-agenda-files
                 '("~/org/notes.org"))
            pdf python
            (shell :variables shell-default-shell 'shell shell-default-height 30 shell-default-position 'bottom)
            spell-checking
            (syntax-checking :variables syntax-checking-enable-by-default nil)
            treemacs version-control)
```
- System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS THREADS LCMS2

@npit If you meant something else, then could you provide some reproduction steps. And it might help to narrow down when the issue is occurring if you include your system info. Press SPC h d s to copy your system info to the clipboard.

npit commented 4 years ago

Currently, I'm getting the error when I invoke the GUI version of spacemacs, eg:

On the other hand, running emacsclient ~/path/to/file.org from the terminal successfully spawns spacemacs, but in a terminal environment.

FWIW, after the *ERROR*: Selecting deleted buffer error, the messages buffer displays a warning: [persp-mode] Warning: Can not restore the window configuration, because of the error -- (error Window #<window 49 on *scratch*> too small to accommodate state)

The system info:

#### System Info :computer:
- OS: gnu/linux
- Emacs: 26.3
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 3a1bfc2a9)
- Graphic display: nil
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
‘‘‘elisp
(windows-scripts sql vimscript javascript shell-scripts dap helm html lsp search-engine git neotree
                 (auto-completion :variables auto-completion-enable-snippets-in-popup t auto-completion-enable-help-tooltip t)
                 c-c++ better-defaults emacs-lisp yaml csv themes-megapack markdown
                 (python :variables python-backend ’lsp python-lsp-server ’mspyls python-fill-column 99 python-formatter ’yapf python-format-on-save nil python-sort-imports-on-save t python-pipenv-activate t)
                 (ranger :variables ranger-cleanup-on-disable t ranger-show-literal nil ranger-show-preview t)
                 imenu-list colors
                 (colors :variables colors-enable-nyan-cat-progress-bar t)
                 org
                 (latex :variables latex-enable-auto-fill nil org-startup-indented t org-pretty-entities t latex-enable-folding t)
                 (shell :variables shell-default-height 30 shell-default-position ’bottom)
                 (spell-checking :variables spell-checking-enable-auto-dictionary t spell-checking-enable-by-default nil)
                 (languagetool :variables langtool-java-classpath "/usr/share/languagetool:/usr/share/java/languagetool/*" langtool-default-language "en-US")
                 (syntax-checking :variables syntax-checking-enable-by-default t)
                 mu4e)
‘‘‘
- System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES T\
HREADS LIBSYSTEMD LCMS2
duianto commented 4 years ago

I haven't been able to reproduce the error: Selecting deleted buffer.

But I'm able to reproduce the warning (In Linux, but not in Windows):

[persp-mode] Warning: Can not restore the window configuration, because of the error -- (error Window #<window 5 on scratch> too small to accommodate state)

By first starting Spacemacs with a Gui client, then with a terminal client:

The warning is shown for a split second in the minibuffer during startup, then it's visible in the messages buffer.

PopOS 19.10
#### System Info :computer:
- OS: gnu/linux
- Emacs: 26.3.50
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 0a7ab7873)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(auto-completion command-log emacs-lisp git helm markdown multiple-cursors
                 (org :variables org-agenda-files
                      '("~/org/notes.org"))
                 pdf python
                 (shell :variables shell-default-shell 'term shell-default-height 30 shell-default-position 'bottom)
                 spell-checking syntax-checking treemacs version-control)
```
- System configuration features: XPM JPEG TIFF GIF PNG SOUND DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS

Anton-Latukha commented 3 years ago

Same.

Just updated packages.

Agenda and Magit buffers do not work.

duianto commented 3 years ago

I have updated packages on the latest develop branch and both org agenda and magit sems to be working.

Can you:

Manjaro, System Info (Click to expand)
#### System Info :computer:
- OS: gnu/linux
- Emacs: 27.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. b606d82df)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(emacs-lisp git helm lsp multiple-cursors org rust spell-checking syntax-checking version-control treemacs)
```
- System configuration features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 GMP

Windows 10, System Info (Click to expand)
#### System Info :computer:
- OS: windows-nt
- Emacs: 27.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. b606d82df)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(autohotkey emacs-lisp git helm javascript lsp multiple-cursors
            (org :variables org-agenda-files "c:/Users/username/org/notes.org")
            python rust spell-checking syntax-checking version-control treemacs)
```
- System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY W32NOTIFY ACL GNUTLS LIBXML2 HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS JSON PDUMPER LCMS2 GMP

Anton-Latukha commented 3 years ago

Dodged the bullet.

-> Nuke&paving ~/.emacs helped. <-

Happens.

I can no longer provide info.

mtyzz commented 3 years ago

Just hit this issue after: cider-jack-in spc-b-d to kill buffer cider-jack-in attempt to start new repl

Running sesman-quit cleared the error for me and allowed cider-jack-in to work again.

togakangaroo commented 3 years ago

when this happens it prevents me from even closing emacs in a standard way

dschrempf commented 3 years ago

I had the same problem (mostly using SPC g s for magit status). I had to delete ~/.emacs.d/elpa and ~/.emacs.d/.cache. Now it works. I also reset the environement variables using spacemacs/force-init-spacemacs-env.

AleXoundOS commented 2 years ago

For me ~/.emacs.d deletion does not help (while keeping the same ~/.spacemacs.d). emacs version 27.2. Very annoying when having to open files 2 times with "HELM Find Files" (succeeds on the second run).

AleXoundOS commented 2 years ago

After upgrading to emacs 28.0.90 the issue has gone!

bzy-debug commented 1 year ago

experiencing this issue when using tree-sitter. adding (global-tree-sitter-mode) to dotspacemacs/user-config triggers this issue when start up spacemacs

lebensterben commented 1 year ago

experiencing this issue when using tree-sitter.

adding (global-tree-sitter-mode) to dotspacemacs/user-config triggers this issue when start up spacemacs

@bzy-debug Cannot reproduce.

stites commented 1 year ago

@bzy-debug I saw this (just with a vanilla config) but I think this gets fixed in more recent versions of emacs

sid-kap commented 8 months ago

adding (global-tree-sitter-mode) to dotspacemacs/user-config triggers this issue when start up spacemacs

This happens to me too