Skip to content
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

SPC TAB alternate-buffer-in-persp is broken #5129

Closed
syl20bnr opened this issue Feb 18, 2016 · 16 comments
Closed

SPC TAB alternate-buffer-in-persp is broken #5129

syl20bnr opened this issue Feb 18, 2016 · 16 comments

Comments

@syl20bnr
Copy link
Owner

Description

SPC TAB to go to back and forth to last buffer is broken.

Reproduction guide

  • Start Emacs
  • SPC f e i
  • SPC w V
  • SPC f f core/core-funcs.el RET
  • SPC 1
  • SPC f f core/core-debug.el RET
  • SPC 2
  • SPC TAB

Observed behaviour:
The displayed buffer is core-debug.el

Expected behaviour:
The displayed buffer should be init.el

System Info

  • OS: gnu/linux
  • Emacs: 24.4.1
  • Spacemacs: 0.105.9
  • Spacemacs branch: develop (rev. 2fef64e)
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(ansible
 (auto-completion :variables auto-completion-return-key-behavior 'complete auto-completion-tab-key-behavior 'cycle auto-completion-complete-with-key-sequence "jk")
 c-c  
 (colors :variables colors-enable-rainbow-identifiers t)
 django elixir elm emacs-lisp emoji erlang
 (evil-snipe :variables evil-snipe-enable-alternate-f-and-t-behaviors t)
 (eyebrowse :variables eyebrowse-display-help nil)
 (git :variables git-use-magit-next t git-magit-status-fullscreen nil)
 github html
 (javascript :variables javascript-disable-tern-port-files t)
 markdown
 (org :variables org-enable-github-support t)
 perforce php python ranger semantic
 (shell :variables shell-default-shell 'eshell)
 syntax-checking spell-checking vagrant version-control windows-scripts)

cc @CestDiego

@CestDiego
Copy link
Contributor

Why is the expected buffer core-debug.el ? I had to rewrite the alternate
buffer function so it doesn't use the evil one because it did something not
in the way emacs is supposed to (by checking the buffer list- which is
convenient because persp-mode changes the buffer list)

On Thu, Feb 18, 2016 at 2:13 PM Sylvain Benner notifications@github.com
wrote:

Description

SPC TAB to go to back and forth to last buffer is broken.
Reproduction guide

  • Start Emacs
  • SPC f e i
  • SPC w V
  • SPC f f core/core-funcs.el RET
  • SPC 1
  • SPC f f core/core-debug.el RET
  • SPC 2
  • SPC TAB

Observed behaviour:
The displayed buffer is core-debug.el

Expected behaviour:
The displayed buffer should be init.el
System Info

  • OS: gnu/linux
  • Emacs: 24.4.1
  • Spacemacs: 0.105.9
  • Spacemacs branch: develop (rev. 2fef64e
    2fef64e
    )
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:

(ansible
(auto-completion :variables auto-completion-return-key-behavior 'complete auto-completion-tab-key-behavior 'cycle auto-completion-complete-with-key-sequence "jk")
c-c
(colors :variables colors-enable-rainbow-identifiers t)
django elixir elm emacs-lisp emoji erlang
(evil-snipe :variables evil-snipe-enable-alternate-f-and-t-behaviors t)
(eyebrowse :variables eyebrowse-display-help nil)
(git :variables git-use-magit-next t git-magit-status-fullscreen nil)
github html
(javascript :variables javascript-disable-tern-port-files t)
markdown
(org :variables org-enable-github-support t)
perforce php python ranger semantic
(shell :variables shell-default-shell 'eshell)
syntax-checking spell-checking vagrant version-control windows-scripts)

cc @CestDiego https://github.com/CestDiego


Reply to this email directly or view it on GitHub
#5129.

Diego Berrocal
http://cestdiego.github.io

@syl20bnr
Copy link
Owner Author

SPC TAB should be scoped to the current window buffer list. When a buffer is changed in window 1, then it should not affect SPC TAB of window 2.

Say I have buffer A, B and C (opened in this order) in window 1 and D, E, F in windows 2.
Pressing SPC TAB in window 1 should cycle between B and C and in window 2 between E and F.

@CestDiego
Copy link
Contributor

this would not work with perspectives... :(

On Thu, Feb 18, 2016 at 11:56 PM Sylvain Benner notifications@github.com
wrote:

SPC TAB should be scoped to the current window buffer list. When a buffer
is changed in window 1, then it should not affect SPC TAB of window 2.

Say I have buffer A, B and C (opened in this order) in window 1 and D, E,
F in windows 2.
Pressing SPC TAB in window 1 should cycle between B and C and in window 2
between E and F.


Reply to this email directly or view it on GitHub
#5129 (comment)
.

Diego Berrocal
http://cestdiego.github.io

@syl20bnr syl20bnr added this to the release 0.200 milestone May 11, 2016
@toupeira
Copy link
Contributor

toupeira commented Jun 7, 2016

It looks like SPC TAB gets remapped back to spacemacs/alternate-buffer in layers/+distribution/spacemacs-base/keybindings.el, if I add some logging this gets executed after the :config hook from the use-package persp-mode in layers/+spacemacs/spacemacs-layouts/packages.el for some reason.

Calling spacemacs/alternate-buffer-in-persp manually still seems to work fine here on latest develop.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Jun 7, 2016

It looks like SPC TAB gets remapped back to spacemacs/alternate-buffer in layers/+distribution/spacemacs-base/keybindings.el

Honestly I prefer it to be like this, the other implementation is even more confusing when using multiple layouts (like no isolation at all).

@toupeira
Copy link
Contributor

toupeira commented Jun 7, 2016

Honestly I prefer it to be like this, the other implementation is even more confusing when using multiple layouts (like no isolation at all).

Right I misread the intent of your original issue :) I didn't realize that the alternate buffer is per-window, that's certainly very useful. But spacemacs/alternate-buffer sometimes gives me a buffer from a different perspective which is very jarring, so I'm trying out the following:

  (defun spacemacs/alternate-buffer ()
    (interactive)
    (let* ((current (current-buffer))
           (other (if (evil-alternate-buffer)
                      (car (evil-alternate-buffer))
                    (other-buffer (current-buffer) t)))
           (other (if (persp-contain-buffer-p other)
                      other
                    (car (delq current (persp-buffer-list))))))
      (if other
          (switch-to-buffer other)
        (spacemacs/switch-to-scratch-buffer))))

i.e. if the target buffer does not belong to the current perspective, switch to the first buffer of that perspective that is not the current one, and always fall back to the scratch buffer.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Jun 8, 2016

Interesting, let me try this a little while, thank you.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Jun 8, 2016

@toupeira It is not working :-(

Reproduction guide 🪲

  • Start Emacs
  • SPC f e i
  • SPC f f core/core-debug.el RET
  • SPC l 2 y foo RET
  • SPC f e i
  • SPC f f core/core-funcs.el RET
  • SPC l 1
  • SPC TAB

Observed behaviour: 💔
The current buffer is core-funcs.el

*Expected behaviour: 💜
*The current buffer is init.el

@toupeira
Copy link
Contributor

toupeira commented Jun 8, 2016

@syl20bnr I get the same behaviour with the old spacemacs/alternate-buffer though.

Isn't the default layout 1 special, in that all buffers are always members of it? That's why persp-contain-buffer-p doesn't seem to work here. If I do your example with layouts 2 and 3 I do end up with init.el.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Jun 8, 2016

ooooh nice catch, I'll test later with 2 and 3.

@agzam
Copy link
Contributor

agzam commented Aug 16, 2016

any status on this? SPC Tab still appears to be broken. (develop branch). Sad, because it is extremely useful feature

@toupeira
Copy link
Contributor

@agzam try my workaround above, haven't encountered any issues with it so far.

@syl20bnr I'd be happy to submit it in a PR if you think it's an acceptable solution, I'm still pretty new to Emacs so I might be missing something :)

@bmag
Copy link
Collaborator

bmag commented Aug 17, 2016

@agzam SPC TAB was changed in the past month by #6574. spacemacs/alternate-buffer now uses buffer-predicate for filtering buffers. If SPC TAB fails to show a buffer, there are now two possible reasons:

  • the buffer isn't part of the current layout. Can happen if the buffer isn't added automatically to the layout (for example Dired buffers might still suffer from this).
  • the buffer's name matches an entry in spacemacs-useless-buffers-regexp and doesn't match any entry in spacemacs-useful-buffers-regexp.

Currently, the second category includes all non-REPL buffers that have "*" in their name. It might be your case as well. I opened an issue to discuss those two variables in #6683 (though it has very few comments), you're welcome to suggest improvements.

@bmag
Copy link
Collaborator

bmag commented Aug 17, 2016

@syl20bnr regarding #5129 (comment), persp-mode's predicate doesn't update immediately when switching layouts (the predicate is byte-compiled on the fly with the current perspective). It could have a delay of ~2 seconds (at least that's what I saw about a month ago), so that's also something to consider in your recipe.

@syl20bnr
Copy link
Owner Author

Nice work @bmag, looks like it is fixed, at least the repro steps are now all good.

@syl20bnr
Copy link
Owner Author

Closing it as it is a 0.200 milestone issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants