abo-abo / avy

Jump to things in Emacs tree-style
1.72k stars 110 forks source link

Feature request: ability to select objects in overlays #255

Closed yyoncho closed 5 years ago

yyoncho commented 5 years ago

One of the drawbacks of displaying actions in overlays similar to what lsp-ui is doing is that you cannot "trigger" to them using keyboard. It would be good if avy supports overlay as a target location. See https://github.com/noctuid/link-hint.el/issues/24 for more detailed discussion.

@noctuid

abo-abo commented 5 years ago

It's not clear for me what you're trying to do. Please elaborate.

I saw your example with "link in overlay" button. But navigating there might not be a well posed problem, since the overlay doesn't occupy a point, it's not possible to move the point there, only to some other point close to it.

At that point, you can just detect where your overlays are and use plain-old avy--process for the real point positions before the overlay.

yyoncho commented 5 years ago

Sorry for the vague description. In lsp-mode and lsp-ui we use overlays to present Code Actions and Lenses - see screenshot.

I want to be able to make them accessible with the keyboard and link-hint(which uses avy display engine) seems to be a good fit for solving this problem.

I want to achieve the following: Pass a list of overlays + position in overlay and avy will allow selecting the item just like you can do that with avy-goto-word-1. Please let me know whether this makes sense from avy point of view. I haven't checked avy code yet.

emacs myoncho_084

abo-abo commented 5 years ago

Pass a list of overlays + position in overlay and avy will allow selecting the item just like you can do that with avy-goto-word-1

This is doable, maybe in a slightly different way. Like I said, overlays don't occupy a point, so it doesn't make sense for me to splice an avy overlay in the middle of a different overlay. But adding it at the beginning or the end of an overlay is fine. In fact, you simply pass the point position where the existing overlay is located.

Here's an example:

(avy--process '(10 20 30))
;; => 20

Just pass the point positions of the overlay, get the selected position back and locate the overlay by position.

yyoncho commented 5 years ago

@abo-abo One overlay could have multiple actions in it, and at one point we could have multiple overlays. Check the following screenshot:

https://user-images.githubusercontent.com/13259670/51136922-4ff8e600-1846-11e9-9275-c668314082e5.png

yyoncho commented 5 years ago

I followed the avy--process handling and I believe that passing custom display-fn and cleanup-fn will possibly be able to handle our case. Thanks for the pointer