12

To post this question and this question, I had to copy the contents of minibuffer.

I tried to copy from minibuffer but it didn't worked.

I came across this discussion and checked *Messages* buffer also. But minibuffer contents won't be there always.

Is it possible to copy mini buffer contents? How?

Update:

I am in a python process buffer and run kill-this-buffer, emacs will show this message in minibuffer

Buffer "Python" has a running process; kill it (y or n)?

I want to copy that text.

Update:

In above example that message will be available in *Messages* buffer, but if am creating a new branch using magit b c, it will prompt with message

Create branch starting at (default master):

which will NOT be available in *Messages*. I need to copy this text also.

3
  • 4
    Sounds like you're mixing up the minibuffer (reads in events) with the echo area (displays things).
    – wasamasa
    Commented Aug 31, 2015 at 7:28
  • 2
    It would help if you included a specific example of something you would like to do, what you have tried for this and what you would like to improve. Make it as detailed as possible, for example mention the exact command of which you want to copy the output.
    – T. Verron
    Commented Aug 31, 2015 at 7:37
  • 1
    If you just back up with C-b over the right boundary of the message of the prompt, then you will be able to use other navigation and text editing commands on the prompt message (except for modifying it, since it's read-only).
    – wvxvw
    Commented Aug 31, 2015 at 13:14

2 Answers 2

5

You can select and copy the text of the prompt in the minibuffer (normally), if you move the point using any moving commands just one position after the prompt, and then C-b to move the point over the right boundary of the prompt. After you do it, you can use other navigation and selection commands on the prompt text. This can be achieved normally by using Fields BTW, it works the same way with the prompt of most shells run by Emacs.

You can also query for the contents of minibuffer programmatically (however it returns the entire history of the minibuffer, not just the visible text) by using minibuffer-contents-no-properties.

14
  1. As others have indicated, and as was explained in the page you link to, output messages to the echo area are logged in buffer *Messages*. Clicking in the echo area brings up *Messages*, where you can copy text normally.

  2. In the minibuffer, which is for input (as opposed to the echo area, which is in the same place, and which is for output), if you use normal, vanilla Emacs then you can just copy (and yank) there normally. IOW, you can edit text in the minibuffer.

  3. #2 is not true, however, if you use something like Ido mode. That co-opts the normal editing behavior of the minibuffer for its own purposes. Keys that would normally edit text in the minibuffer do not, when you are in Ido mode.

    (FWIW, Icicles does not do this. It lets you edit minibuffer text normally, Even more so than vanilla Emacs, in fact, in that SPC, ?, and newline (C-j) characters self-insert normally. Of course, TAB and RET are not normal editing keys in the minibuffer.)

  4. As @wvxwv mentioned in a comment to your question, the prompt area of the minibuffer is generally read-only text. But you can certainly copy it. Just back into it (e.g. using C-b or the left-arrow key) and copy text from the prompt normally (e.g., C-SPC move cursor with C-f, M-f, etc., followed by M-w).

    And then you can yank it anywhere, including in the minibuffer input area (after the prompt).

    (The prompt area is read-only, and some cursor movement keys will not move into it, simply for convenience. For example, C-a takes you to the beginning of your input area, not to the beginning of the line, which would be within the prompt area. This is the reason for mentioning C-b, as it is one way that you can move the cursor into the prompt area.)

3
  • Apparently, what the OP wants to copy is the prompt in the minibuffer, which is not the input area per se, but not output pushed to *Messages* either. As far as I can remember, the prompt is not edittable by default (or is it? that would make a terrible default imo), so this answer could be expanded to include this usage.
    – T. Verron
    Commented Aug 31, 2015 at 14:08
  • @T.Verron. Right; done. Thx.
    – Drew
    Commented Aug 31, 2015 at 14:39
  • 1
    *Messages* buffer is a good solution. When I switch focus to the minibuffer, the text dissapears, so this might be the only solution as far as I understand. The accepted answer does not work for me.
    – mcp
    Commented Jan 7, 2022 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.