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

Acquire target during already-active prompt #549

Closed
woolsweater opened this issue Oct 15, 2022 · 2 comments
Closed

Acquire target during already-active prompt #549

woolsweater opened this issue Oct 15, 2022 · 2 comments

Comments

@woolsweater
Copy link

woolsweater commented Oct 15, 2022

Can Embark be used to get a target into the minibuffer after a command has already been started? In effect, "yanking" into the minibuffer, but directly from a regular buffer, not from the kill ring.

As a concrete example, say I'm looking at the Magit status view for a repo, and I decide I want to check out a particular commit by its hash. So I hit b b, running magit-checkout, which wants to read the hash value in the minibuffer. Then I realize I have the hash already written out in another open buffer. I switch to that buffer and run embark-act on the hash. The magit-checkout prompt is still active and Embark has the value I want. But how can I put them together?

It looks like this might be possible in embark's design, if I could get embark--act to target the current, active minibuffer when running a non-interactive function. If I'm reading the code correctly. But I figured I'd ask; this doesn't seem to have come up in Issues before that I can see. Not so much a feature request as a usage help request. 🙂

@minad
Copy link
Contributor

minad commented Oct 15, 2022

You can write a custom embark-inject action and bind it in the embark-general-map. Then in the other buffer, press C-. I on the target you want to inject into the currently active minibuffer (assuming that C-. is bound to embark-act).

(defun embark-inject (str)
  (interactive "sString: ")
  (let ((win (active-minibuffer-window)))
    (unless win
      (user-error "No active minibuffer"))
    (select-window win)
    (delete-minibuffer-contents)
    (insert str)))

(define-key embark-general-map "I" #'embark-inject)

I think it isworth to add this functionality with the description of the use case to the wiki. I wouldn't add the action to Embark itself since it seems to be too rarely useful, since you can just use kill (w = embark-copy-as-kill) and yank in the minibuffer instead.

@woolsweater
Copy link
Author

Ah, that's great. I didn't think it would be so simple to get the previous command's minibuffer. Thanks!

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

2 participants