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

Option to push the values entered in the jq-interactive minibuffer into the kill-ring? #12

Open
blak3mill3r opened this issue Oct 12, 2018 · 5 comments

Comments

@blak3mill3r
Copy link

Great package, thanks!

I was searching for a way to get at the value of the jq expression I last typed in...

I ended up binding a key in json-mode to do this

(kill-new (car minibuffer-history))

and that more or less does what I want, but I have to press that key after finishing jq-interactively. Perhaps it would be useful to add an option to jq-mode that would cause the last interactive jq expression to be pushed to the kill-ring automatically.

@Fuco1
Copy link
Collaborator

Fuco1 commented Oct 12, 2018

That's very unusual in Emacs, I cannot think of any other minibuffer-reading routine doing that. Would you be OK with the content always being pushed to the kill ring?
I can imagine it being quite annoying.

@blak3mill3r
Copy link
Author

Yes, if the content were always pushed to the kill ring, that would help. I'm generally using jq-interactive in order to come up with a jq expression that I will use in a script, for example, not just to get the output of jq in a buffer.

@ljos
Copy link
Owner

ljos commented Oct 14, 2018

I have used C-x h C-w, i.e., mark-whole-buffer -> kill-region, but we could push it to a separate history variable that you can cycle through with a keybinding in a jq-mode buffer.

@ljos
Copy link
Owner

ljos commented Oct 14, 2018

If you execute the command it will go into the jq-interactive-history variable. We could use that, we could even do something if you C-g and cheat something into the variable.

@gvol
Copy link
Contributor

gvol commented Aug 18, 2023

What about something like

(defun jq-insert-last-interactive-query ()
  "Insert the last interactive query.
Useful when using `jq-interactively' to test out a query and then
insert it into a script."
  (interactive)
  (let ((query (car-safe jq-interactive-history)))
    (when query
      (insert query))))

This requires my fix at #35.

I feel like a prefix argument should insert an entire shell statement (with jq '...'), or maybe choose a different query from the history. I could probably put a PR together with either one if people know what they want. Otherwise, I might just leave the simple version like this.

@ljos ljos closed this as completed Aug 23, 2023
@ljos ljos reopened this Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants