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

Leverage actions-on-current-suggestion as a list. #2632

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions source/mode/hint.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,17 @@ For instance, to include images:
:key #'prompter:value)
(append matching-hints other-hints))))
(prompter:selection-actions
(unless (fit-to-prompt-p (find-submode 'hint-mode))
(lambda (suggestion)
(highlight-selected-hint :element suggestion
:scroll nil))))
(list (unless (fit-to-prompt-p (find-submode 'hint-mode))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are NIL values deleted from the selection-actions list? Maybe they should be...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point! I think they should. Should have been part of #2555...

(lambda-command highlight-selected-hint* (suggestion)
"Highlight hint."
(highlight-selected-hint :element suggestion)))
(lambda-command scroll-to-selected-hint* (suggestion)
"Highlight and scroll to hint."
(highlight-selected-hint :element suggestion :scroll t))
(lambda-command copy-selected-hint* (suggestion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it actually make sense as a selection action?

A crazy idea: make both selection-actions and return-actions accessible in the return-marks-action and set-selection-action?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're referring to copy-selected-hint* right? Actually I had this idea written down and I know I took it from you! It could very well be that I misunderstood you somehow. Note that right now it's not very useful since the URL might be relative (e.g. #potatoes), but that's an issue orthogonal to this PR...

A crazy idea: make both selection-actions and return-actions accessible in the return-marks-action and set-selection-action?

I think I understand what you mean and I agree. The only obstacle is that return-actions run over marks whereas selection-actions run over a single element (the suggestion).

Actions should be defined in such a way that it could be used in both cases. If we look at the particular of hint-mode, then we could use for instance focus* in whatever context.

"Copy hint URL to clipboard."
(highlight-selected-hint :element suggestion :scroll t)
(copy-to-clipboard (plump:attribute suggestion "href")))))
(prompter:marks-actions
(lambda (marks)
(let ((%marks (mapcar (lambda (mark) (str:concat "#nyxt-hint-" (identifier mark)))
Expand Down