Prefill search query from Clipboard #123

Closed
sepich opened this Issue Sep 21, 2016 · 11 comments

Comments

Projects
None yet
3 participants
@sepich

sepich commented Sep 21, 2016

It would be nice (at least for me ;) to have some simple logic on_open of LaunchBox:

  • check if Clipboard holds one word only, and use it as query then
  • possibly also trim this "word" from spaces on both ends

Reading API docs, it looks like there is no possibility to create such as a plugin. What are the chances to have it implemented as core feature then?

@ueffel

This comment has been minimized.

Show comment
Hide comment
@ueffel

ueffel Sep 21, 2016

there is the on_activated method that gets called when the KP launchbox is opened.
but i dont think it is possible for a plugin to set the content of the launchbox, to prefill

ueffel commented Sep 21, 2016

there is the on_activated method that gets called when the KP launchbox is opened.
but i dont think it is possible for a plugin to set the content of the launchbox, to prefill

@sepich

This comment has been minimized.

Show comment
Hide comment
@sepich

sepich Sep 21, 2016

Thanks, what i actually was unable to find - is some keypirinha.set_query() method to change current LaunchBox query from inside the plugin. Could you please point me to it?

sepich commented Sep 21, 2016

Thanks, what i actually was unable to find - is some keypirinha.set_query() method to change current LaunchBox query from inside the plugin. Could you please point me to it?

@ueffel

This comment has been minimized.

Show comment
Hide comment
@ueffel

ueffel Sep 21, 2016

i dont think that is possible for a plugin. for one it collides with the retain_last_search setting of the core application.
maybe there is a possibility to add that functionally to the kp core. but thats up to @polyvertex

ueffel commented Sep 21, 2016

i dont think that is possible for a plugin. for one it collides with the retain_last_search setting of the core application.
maybe there is a possibility to add that functionally to the kp core. but thats up to @polyvertex

@sepich

This comment has been minimized.

Show comment
Hide comment
@sepich

sepich Sep 21, 2016

Actually if it is possible for plugin to push results on_activated, when there were no query yet - that's also ok. Haven't thought about that.

sepich commented Sep 21, 2016

Actually if it is possible for plugin to push results on_activated, when there were no query yet - that's also ok. Haven't thought about that.

@ueffel

This comment has been minimized.

Show comment
Hide comment
@ueffel

ueffel Sep 21, 2016

i'm pretty sure that on_suggest isn't called for the empty launchbox, but check that out first. if it doesn't work, you could try to call set_suggestions in the on_activated method. Maybe that works for you.
As a side note there is the chat room for keypirinha @ https://gitter.im/Keypirinha/Keypirinha thats a better place for this discussion i think.

ueffel commented Sep 21, 2016

i'm pretty sure that on_suggest isn't called for the empty launchbox, but check that out first. if it doesn't work, you could try to call set_suggestions in the on_activated method. Maybe that works for you.
As a side note there is the chat room for keypirinha @ https://gitter.im/Keypirinha/Keypirinha thats a better place for this discussion i think.

@polyvertex

This comment has been minimized.

Show comment
Hide comment
@polyvertex

polyvertex Sep 22, 2016

Member

It is not possible for a plugin to change the state of the search as it would give too much power to them. For example, what would happen if two plugins try to change the content of the edit box?

Perhaps a solution lies somewhere else but for that I would need more info about the reason(s) of your request.

Member

polyvertex commented Sep 22, 2016

It is not possible for a plugin to change the state of the search as it would give too much power to them. For example, what would happen if two plugins try to change the content of the edit box?

Perhaps a solution lies somewhere else but for that I would need more info about the reason(s) of your request.

@polyvertex

This comment has been minimized.

Show comment
Hide comment
@polyvertex

polyvertex Sep 22, 2016

Member

Ah I realized I only partly answered to this regarding the following of the discussion.

I confirm that on_suggest isn't called for empty searches, but I suspect you might be successful by calling set_suggestions from the on_activated method. IIRC the code allows that so you should give it a shot :)

Member

polyvertex commented Sep 22, 2016

Ah I realized I only partly answered to this regarding the following of the discussion.

I confirm that on_suggest isn't called for empty searches, but I suspect you might be successful by calling set_suggestions from the on_activated method. IIRC the code allows that so you should give it a shot :)

@polyvertex

This comment has been minimized.

Show comment
Hide comment
@polyvertex

polyvertex Sep 25, 2016

Member

@sepich Have you managed to achieve what you wanted?

Member

polyvertex commented Sep 25, 2016

@sepich Have you managed to achieve what you wanted?

@sepich

This comment has been minimized.

Show comment
Hide comment
@sepich

sepich Sep 25, 2016

I've managed to install KP and write a simple plugin using your SDK. Thanks for detailed docs.
But calling set_suggestions from the on_activated does not lead to actually showing them. Result is the same blank string of query entry, without results.
If i push the same array to set_catalog - they are appended to Catalog successfully.

I would need more info about the reason(s) of your request

Mostly workflow is to copy hostname from Monitoring, and then connect to it. But monitoring has only hostname, and to connect i need fqdn. So i've just wanted to reduce one step in workflow (Ctrl-V). I understand that it could be useful for me only, that's why i intrested to get it as plugin on first hand, and not as core feature. Because i also want to do some custom logic on clipboard content to decide - use it as query or not.

P.S

It is not possible for a plugin to change the state of the search as it would give too much power to them.

I do see a lot of comments like that from you in different issues. I believe that's wrong point.

As a side note, may the plugin developer absolutely wishes to crash the application anyway,
Python and Keypirinha both offer numerous ways to do that too.

That one from here is much better. It is up to user to decide which plugins to use, and which ones are buggy. And devs should have as much possibilities to write some workflow as possible. If they want to write buggy plugin - they would be able to do it even with most restricted API. Ability to shoot in the foot - is not a show stopper for internal API 😉

sepich commented Sep 25, 2016

I've managed to install KP and write a simple plugin using your SDK. Thanks for detailed docs.
But calling set_suggestions from the on_activated does not lead to actually showing them. Result is the same blank string of query entry, without results.
If i push the same array to set_catalog - they are appended to Catalog successfully.

I would need more info about the reason(s) of your request

Mostly workflow is to copy hostname from Monitoring, and then connect to it. But monitoring has only hostname, and to connect i need fqdn. So i've just wanted to reduce one step in workflow (Ctrl-V). I understand that it could be useful for me only, that's why i intrested to get it as plugin on first hand, and not as core feature. Because i also want to do some custom logic on clipboard content to decide - use it as query or not.

P.S

It is not possible for a plugin to change the state of the search as it would give too much power to them.

I do see a lot of comments like that from you in different issues. I believe that's wrong point.

As a side note, may the plugin developer absolutely wishes to crash the application anyway,
Python and Keypirinha both offer numerous ways to do that too.

That one from here is much better. It is up to user to decide which plugins to use, and which ones are buggy. And devs should have as much possibilities to write some workflow as possible. If they want to write buggy plugin - they would be able to do it even with most restricted API. Ability to shoot in the foot - is not a show stopper for internal API 😉

@polyvertex

This comment has been minimized.

Show comment
Hide comment
@polyvertex

polyvertex Sep 25, 2016

Member

A while ago I considered adding an extra hotkey to do exactly that: pop up the LaunchBox then immediately paste the content of the clipboard into it if it happens to be some text so a search is started automagically from it. It seems that it would perfectly address your problem.

Regarding your P.S. part, again, by design, plugins won't be able to change the state of the application directly. They can only make suggestions (in its general sense) about what to do and it will be up to the application to handle them or not. That, by extension, allows to give full power to the end-user, not the developer, even if they happen to be the same person. That does not make the API less flexible, that just allows the application to offer a better user experience. In that regard, the key question was: For example, what would happen if two plugins try to change the content of the edit box?

Member

polyvertex commented Sep 25, 2016

A while ago I considered adding an extra hotkey to do exactly that: pop up the LaunchBox then immediately paste the content of the clipboard into it if it happens to be some text so a search is started automagically from it. It seems that it would perfectly address your problem.

Regarding your P.S. part, again, by design, plugins won't be able to change the state of the application directly. They can only make suggestions (in its general sense) about what to do and it will be up to the application to handle them or not. That, by extension, allows to give full power to the end-user, not the developer, even if they happen to be the same person. That does not make the API less flexible, that just allows the application to offer a better user experience. In that regard, the key question was: For example, what would happen if two plugins try to change the content of the edit box?

@polyvertex

This comment has been minimized.

Show comment
Hide comment
@polyvertex

polyvertex Oct 10, 2016

Member

hotkey_paste setting added in v2.9.7

Member

polyvertex commented Oct 10, 2016

hotkey_paste setting added in v2.9.7

@polyvertex polyvertex closed this Oct 10, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment