saka-key
saka-key copied to clipboard
Go to previous/next page
As mentioned in #18, it would be great to have a keybinding for 'prev', 'next' links.
This is useful for navigating forums, github issues, long articles, etc. On VimFx, the keybindings were [
, and ]
.
Just wanted to share my experience with this feature from VimFx, both as a user and as an implementor:
This is a VimFx feature I kinda liked, but also disliked a bit. The thing is that you more or less have to learn which pages it works on. When you press ]
in VimFx, one of three things happen:
- You’re taken to the next page as expected.
- You’re taken to an unexpected page (because some link happened to match a “next” pattern).
- Nothing at all happens.
So I mostly didn’t use it. Only on a few forums I often visit, for github issues listings, and for search results on a couple of pages.
Another weakness of the feature is that users mostly have to customize the default patterns for their language. For example, adding “nästa” as a “next” pattern and “föregående” as a “previous” pattern for Swedish.
Here’s the VimFx implementation. It’s mostly regex search. But also nasty a hardcoded hack to make things work on Google.
- https://github.com/akhodakivskiy/VimFx/blob/376486f4dc61d75add1c26263d1f4baf39d3abd4/extension/lib/commands-frame.coffee#L484-L539
- https://github.com/akhodakivskiy/VimFx/blob/376486f4dc61d75add1c26263d1f4baf39d3abd4/extension/lib/parse-prefs.coffee#L50-L69
- https://github.com/akhodakivskiy/VimFx/blob/376486f4dc61d75add1c26263d1f4baf39d3abd4/extension/lib/defaults.coffee#L151-L152
- https://github.com/akhodakivskiy/VimFx/blob/376486f4dc61d75add1c26263d1f4baf39d3abd4/extension/lib/defaults.coffee#L177-L180 (https://github.com/akhodakivskiy/VimFx/commit/b4e73c77b7b026a3bf5430f001c992f745e5066d)
Here are some tricky issues:
- https://github.com/akhodakivskiy/VimFx/issues/836
- https://github.com/akhodakivskiy/VimFx/issues/792
I guess what I’m trying to say is that copying VimFx is not super difficult. But then you also inherit that half-good experience, and open a can of worms. You can also try to come up with a better heuristic for finding the links. Or make a database of selectors for every site, like the old Autopagerize extension/userscript: http://wedata.net/databases/AutoPagerize/items_all.json. It also feels like machine learning would be appropriate for this challenge ... how far down this rabbit hole can we go?
I would be fine with it only working when there's a <link rel=prev/next/first/last>
(which honestly is how it should be implemented by websites anyway).
I agree with you that it was annoying that it didn't always work, but hey, that's not the plugin's fault necessarily.
I think even with the shortcomings that @lydell mentioned, it was a great feature, I would be perfectly okay with that implementation.
Placeholders for these commands actually already exist in Saka Key's source code. I'll probably end up porting VimFX's implementation when I get around to it.
https://key.saka.io/dev_docs/adding_commands
How about implementing the commands as site plug-in?
Access to Site mode on Space, and [ and ] commands to go to the previous and next page.
A global and naive implementation could be added.
The site could hijack the global implementation.
Interactive creation of plug-in would be neat for non-developers.
It would seamless allow the Next / Previous page functionalities creation.
All that on-the-fly.
@alexherbo2 FYI, rel=next/prev/etc...
is in the standard: https://www.w3.org/TR/html5/links.html#sequential-link-types (for what that's worth, anyways).
Yep, I don’t know for you, but none of the sites I use use that. XD
Ah. Sorry, I assumed you wanted sites to implement this. I agree it would be nice to be able to override commands (really, all commands) for arbitrary websites. However, I believe that discussion belongs in #45.
Since searching "bing" in 'issues' gave me nothing, I would like to mention the prev
and next
page did not work for me on Bing. It seems to be because their prev/next buttons don't have any text, and also lack something like rel="next"
.
I have created a greasyfork to have those buttons get the rel="prev"
and rel="next"
attribute needed to make them work with Saka: https://greasyfork.org/en/scripts/390762-bing-rel-next-prev
But it's a mystery for me why while the next button works perfectly with Saka (]
), the prev button ([
here) also acts as a next (and not a prev). Where's the bug? I already double checked the greasyscript and my mapping in Saka for [
and ]
but also find it hard to believe it would come from Saka.