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

Info mode keybindings / follow links with o #458

Closed
dalanicolai opened this issue Feb 10, 2021 · 13 comments
Closed

Info mode keybindings / follow links with o #458

dalanicolai opened this issue Feb 10, 2021 · 13 comments

Comments

@dalanicolai
Copy link

dalanicolai commented Feb 10, 2021

I am opening this issue because, in Spacemacs I was used to scrolling through info nodes using [ ], but now that Spacemacs switched to using this package I find that even without using the evil-collection-info-setup , those bindings have been altered. And when I do setup evil-collection bindings, then the functionality is under C-j and C-k which conflict with other personal bindings. As I very much like the idea of this package, I came here to discuss/suggest possible solutions.

A little background... to ease switching between more than only the current and last visited buffers I have recently proposed to add C-tab buffer switching to Spacemacs (see here and here, check code for the straightforward implementation details). However, after adding those bindings I realized that I actually never used C-j and C-k in evil. So I looked up those bindings in vim and found they are rather redundant. So then I figured that these would be even more convenient bindings for cycling through recent buffers (using Ivy or Helm) confirming with C-l (or RET).

So in the end, I guess I would like to ask you to consider other keybindings for this functionality (as I see that single [/] are already taken, I would like to mention that from the firefox vimium plugin I am used to scroll through nodes using ] ] and [ [).

Moreover, from the zathura pdf viewer, I was used to flipping pages using J/K(capitals). I actually use these bindings myself everywhere to scroll full page, but I guess it would be too much to force this on all evil users.
However, I did propose to add these bindings to scroll through the Info pages (see here.

Also, I have found that after evaluating evil-collection-info-setup, the bindings to follow links by pressing o are gone. Now I have found that both Spacemacs (using ace-link) and Doom (using link-hint) use these bindings, so maybe you could just add them here conditionally (if ace-link/link-hint package installed. link-hint seems to be more "powerful" b.t.w.).

Well, I just wanted to share my thoughts about these bindings here and I hope you will seriously consider their convenience and logic. Of course, I am not here to tell you about which keybindings I am used to. I really think that these bindings make a lot of sense and are, objectively, very convenient.

I am happy to create a PR for (some of) the bindings if you like some of them. Otherwise, no problem of course, I can just set them in my personal setup.

Finally, thanks for this very useful initiative/package! 👍

@jojojames
Copy link
Collaborator

then the functionality is under C-j and C-k which conflict with other personal bindings.

I recommend using the blacklist for that to avoid conflicts.

proposed to add C-tab buffer switching to Spacemacs

If there was some sort of vim-like precedent for that pattern, it would be welcomed. Otherwise, it would seem to be more spacemacsy.

I was used to flipping pages using J/K(capitals).

That does seem a little much, I think the C-d/C-u scrolling commands are pretty good. Having said that, I don't often us the pdf/help type modes that often.

the bindings to follow links by pressing o are gone.

I believe from some discussion a while back when this project was started to put 'o' on sorting type functionality and 'go' on types of open links commands.

Now I have found that both Spacemacs (using ace-link) and Doom (using link-hint) use these bindings,

Example?

@dalanicolai
Copy link
Author

dalanicolai commented Feb 11, 2021

Well about the vim-like precedent for C-tab I would say it is C-j/C-k. Those keys are more or less redundant bindings in vim. C-j is an 'alias' for j, while regarding C-k it might say enough that its vim functionality until now has not been ported to evil. As switching buffers is one of my main activities I find it very reasonable to bind these C-j/C-k bindings to helm/ivy switch buffer. With Ivy calling mode/helm follow mode enabled, you can just continue cycling+previewing buffers using C-j/C-k. Just try these lines (I am assuming you are using Ivy) and then switch buffers with one or more C-js followed by C-l:

  (defun trigger-ivy-switch-buffer ()
    (interactive)
    (minibuffer-with-setup-hook
        (lambda () (run-at-time nil nil #'ivy-toggle-calling))
      (ivy-switch-buffer)))

  (evil-global-set-key 'motion (kbd "C-j") 'trigger-ivy-switch-buffer)
  (evil-global-set-key 'motion (kbd "C-k") 'trigger-ivy-switch-buffer)

(see how it works, and compare it to how you are cycling through recent buffers now)
So I am not asking to implement this buffer switch mechanism (although I would recommend it), but was just discussing if scrolling nodes might better be placed under [ [ and ] ] .

About J/K it might seem much, but the same could be said about using j/k instead of the arrow keys. But every vim user will agree that j/k just becomes more convenient (I would say the same about J/K, besides being, arguably, more logical). Also, you could say that C-d C-u bindings are actually Emacsy (within vim).
Anyway, I already expected that it would not be fit for evil in general, therefore I only suggested it (additionally) for Info buffer scrolling.

Examples of o usage in Doom and Spacemacs:
Here are the default bindings for Doom help and Info mode
and
Here are the default bindings for Spacemacs (this is a default i.e. non-optional layer).
As you can see both use o

Anyway, I am not trying to be stubborn, just thoroughly discussing;) I am very happy to otherwise use the blacklist. Thanks for that suggestion.

@jojojames
Copy link
Collaborator

Well about the vim-like precedent for C-tab I would say it is C-j/C-k.

The precedence for C-j/C-k is mostly from predecessor packages like evil-magit/evil-mu4e.

As switching buffers is one of my main activities I find it very reasonable to bind these C-j/C-k bindings to helm/ivy switch buffer.

I see. On the other hand, for me, buffer switching is a solved problem for me using a prefix key + b to trigger ivy/counsel/etc directly. I'm usually not interested in cycling buffers. This suggestion, I think lends better to personal customization.

but was just discussing if scrolling nodes might better be placed under [ [ and ] ] .

Could you clarify what you expect ]] and [[ to be bound to?

FWIW, we have this section related:

[ and ]: Use [- and ]- prefixed keys for navigation between sections.
If the mode makes no difference between the end of a section and the beginning of the next, use [ and ].

The unimpaired style keys also take some precedence with [ and ] being prefixes.

About J/K it might seem much, but the same could be said about using j/k instead of the arrow keys. But every vim user will agree that j/k just becomes more convenient (I would say the same about J/K, besides being, arguably, more logical). Also, you could say that C-d C-u bindings are actually Emacsy (within vim).

I don't think everyone will be happy will every set of binding decisions we make so it's better to "pick one and go with it", in my opinion.

Also, you could say that C-d C-u bindings are actually Emacsy (within vim).

Right, but they are still vim style bindings, and because of that, would be reasonable for us to bind in a similar way. Which allows vim users that migrate to emacs to be able to use C-u/C-d in a DWIM way.

Here are the default bindings for Doom help and Info mode

I would've liked in the past to use "o" for open but I think we settled on it being related to sorting instead, and "go" being "open".

Sorting
o: Change the sort [o]rder.
O: Sort in reverse order.
There is no real consensus around which key to bind to sorting. What others do by default:

package-menu uses S.
M-x proced and Dired use s.
profiler uses A and D.
mu4e uses O.
ranger uses o, inspired from Mutt.

I think for modes, that don't have sorting involved, binding open to both 'go' and 'o' might be a reasonable solution.

As for implementing this -link-hint-open-link-, it would involve creating a new evil-collection-[PACKAGE] and writing with-eval-after-loads on those other packages to bind those keys.

Anyway, I am not trying to be stubborn, just thoroughly discussing;) I am very happy to otherwise use the blacklist. Thanks for that suggestion.

Thanks for the suggestions, they are definitely appreciated. I don't think all bindings are perfectly polished yet so suggestions/PRs are always welcome.

@jojojames
Copy link
Collaborator

Spacemacs switched to using this package I find that even without using the evil-collection-info-setup , those bindings have been altered.

Forgot to ask about this, but I wonder why that is.

@dalanicolai
Copy link
Author

We can switch buffers in Spacemacs also with SPC b b, but still many people (including myself) prefer to additionally have the C-tab style. SPC b b becomes cumbersome if you switch frequently while working on three/four buffers simultaneously. Anyway, I am fine with any choice you make.

So the [ [ /] ] would have the same functionality as C-j/C-k have now. ([ prefix makes sense as you describe it is meant for navigating between sections). But I agree they don't add much if you already bind C-j C-k` for it.

The J/K would be only additional bindings in the Info buffers for Info-scroll-up and Info-scroll-down. I think they are more evil than the current bindings " " and DEL. Also, they do not break anything. I did not mention anywhere that C-d/C-u functionality should get discarded.

So I guess for the o bindings it probably is easier to bind those keys in the distributions themselves then.

Okay, thanks for answering and considering the suggestions.

@dalanicolai
Copy link
Author

dalanicolai commented Feb 11, 2021

The ] get "hijacked", because Spacemacs is calling evil-collection-init which is calling evil-collection-unimpaired-setup that binds C-u.

@tshu-w
Copy link
Contributor

tshu-w commented Feb 13, 2021

Forgot to ask about this, but I wonder why that is.

Because evil-magit is a part of evil-collection and removed from MELPA.

@jojojames
Copy link
Collaborator

Because evil-magit is a part of evil-collection and removed from MELPA.

That should be clear from the post itself but doesn't explain anything.

The ] get "hijacked", because Spacemacs is calling evil-collection-init which is calling evil-collection-unimpaired-setup that binds C-u.

I think spacemacs' integration probably needs some tweaking then. As I understand it, spacemacs has its own set of unimpaired bindings. In that case, the integration for evil-collection's unimpaired should be turned off.

@jojojames
Copy link
Collaborator

We can switch buffers in Spacemacs also with SPC b b, but still many people (including myself) prefer to additionally have the C-tab style.

Totally understand, the question is, are vim users going to expect c-tab to do what you've set it it to or is it just a convenience thing that you've set up?

Until this thread, I didn't realize there was even a 'c-tab' 'style' and I'd be surprised if c-tab started being bound to buffer switching related actions.

So the [ [ /] ] would have the same functionality as C-j/C-k have now. ([ prefix makes sense as you describe it is meant for navigating between sections). But I agree they don't add much if you already bind C-j C-k` for it.

These should probably be reasonable to add and wouldn't conflict with unimpaired.

The J/K would be only additional bindings in the Info buffers for Info-scroll-up and Info-scroll-down.

Can you take a look at the other modes and see which ones could use these J/K style bindings -without conflict- so we can potentially form a pattern and build a new consensus binding. If we only bind J/K for info, I don't think that's very useful and should be kept to a personal config. If we can find multiple modes to J/K without conflict, there may be more value there. Additionally, I am thinking we can gate the J/K bindings under something like evil-collection-want-JK-to-scroll.

To be clear, I'm not for it yet, but I'm not against it either.

@dalanicolai
Copy link
Author

dalanicolai commented Feb 13, 2021

@jojojames Thanks for coming back to it. I agree that Spacemacs settings require some tweaking. But before tweak things there, I thought let's discuss things first here. Just to be clear, I would not call myself a Spacemacs developer, I just like to suggest/implement improvements there also. (So my suggestions/opinions/requests are on my personal account).

So about the C-tab/C-S-tab I just pointed mentioned it because it led me to the C-j/C-k recent buffer cycle keybindings. Quite remarkable that you have never encountered those bindings. They are the default in Windows and in any of the well known web browser (try C-tab in firefox/chrome). Anyway, I did not suggest to implement it in evil-collection (I did also not suggest to implement C-j/C-k buffer switch. I just mentioned it as a very convenient binding, so I requested to implement an alternative to C-j/C-k paging in Info (i.e. the [ [/] ], "borrowed from firefox/chrome's vimium plugin, or some other nice alternative).

Well I think J/K are also nice bindings for scrolling pages in pdf-view, doc-view, eww, mail readers. Actually most read-only buffer modes where they are not bound yet. As I mentioned before, I "borrowed" these bindings from the venerable zathura pdf viewer. (Also I use them in all my buffers, but I do not suggest that for evil-collection. I have swapped the functionalities between C-f/C-b and J/K)

@jojojames
Copy link
Collaborator

Hi @dalanicolai , sounds good. Since there's a mix of potential suggestions and personal user config bindings, if you could list which bindings you'd put the in "suggest category", that'd be very helpful for me.

@dalanicolai
Copy link
Author

dalanicolai commented Feb 17, 2021

Ah yes sure. So I would suggest to bind:

  • J/K for scrolling full page in read-only buffers (Info-scroll-up/down in Info buffers)
  • [[/]] for info-node-backward/forward in Info buffers (and possibly similar for other buffers)

COMMENT
I like the C-j/k bindings for scrolling nodes also, but I prefer to use those bindings for switching buffers:

  (defun trigger-ivy-switch-buffer ()
    (interactive)
    (minibuffer-with-setup-hook
        (lambda () (run-at-time nil nil #'ivy-toggle-calling))
      (ivy-switch-buffer)))

  (defun spacemacs/evilified-buffer-switch ()
    (interactive)
    (define-key evil-evilified-state-map (kbd "C-j") 'trigger-ivy-switch-buffer)
    (define-key evil-evilified-state-map (kbd "C-k") 'trigger-ivy-switch-buffer))

; FOR SPACEMACS (WITH IVY) SPECIFICALLY
  (evil-global-set-key 'motion (kbd "C-j") 'trigger-ivy-switch-buffer)
  (evil-global-set-key 'motion (kbd "C-k") 'trigger-ivy-switch-buffer)
  (add-hook 'evil-evilified-state-entry-hook 'spacemacs/evilified-buffer-switch)

@jojojames
Copy link
Collaborator

J/K for scrolling full page in read-only buffers (Info-scroll-up/down in Info buffers)

This should be possible, I'd ask for a PR here. It would probably look something like:

evil-collection-want-JK-scrolling for a defcustom and then in each mode you'd like the J/K bindings to appear, you can bind those if evil-collection-want-JK-scrolling is true.

[[/]] for info-node-backward/forward in Info buffers (and possibly similar for other buffers)

This should be doable, I don't remember off the top of my head if we're using ]] for anything, since unimpared doesn't have those bound right now.

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

No branches or pull requests

3 participants