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

How to make candidates clickable? #113

Closed
okamsn opened this issue Jun 20, 2020 · 4 comments
Closed

How to make candidates clickable? #113

okamsn opened this issue Jun 20, 2020 · 4 comments

Comments

@okamsn
Copy link
Contributor

okamsn commented Jun 20, 2020

At which point should the clickable text be added to the candidates? It must be added to selectrum--refined-candidates, yes?

@raxod502
Copy link
Member

Well, text properties are never stripped, so I think adding at any point would be fine. Why not in the collection passed to completing-read?

(let ((button "Hello world")
      (keymap (make-sparse-keymap)))
  (define-key keymap
    [mouse-1]
    (lambda
      ()
      (interactive)
      (message "Hi there!")))
  (put-text-property
   0 (length button) 'keymap keymap button)
  (completing-read "Click me: " (list button)))

@raxod502 raxod502 added the waiting on response Needs more info or follow-up, will be closed after 90 days if no response label Jun 25, 2020
@okamsn
Copy link
Contributor Author

okamsn commented Jun 25, 2020

I wanted to add the ability to select candidates via the mouse for all selections, but I'm not sure at what point the final candidates are decided.

I wanted to do something like the following.

  (seq-map-indexed (lambda (cand index)
                   (propertize
                    cand
                    'keymap (let ((keymap (make-sparse-keymap)))
                              (define-key keymap [mouse-1]
                                (lambda ()
                                  (interactive)
                                  (selectrum-select-current-candidate (1+ index))))
                              (define-key keymap [mouse-3]
                                (lambda ()
                                  (interactive)
                                  (selectrum-insert-current-candidate (1+ index)))))))
                 cands)

@raxod502
Copy link
Member

I see. You were not talking about propertizing a particular candidate, rather you wanted to contribute a pull request that would allow mouse control of Selectrum. I think it would make the most sense to do this at the very end, around here where other text properties are handled:

https://github.com/raxod502/selectrum/blob/a6a2512e1970af1a8e4273a719160fc1d5cb7660/selectrum.el#L745-L756

@okamsn
Copy link
Contributor Author

okamsn commented Jun 27, 2020

Thank you for your help. I made a pull request.

@okamsn okamsn closed this as completed Jun 27, 2020
@raxod502 raxod502 removed the waiting on response Needs more info or follow-up, will be closed after 90 days if no response label Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants