How can I insert some text (thing) at point from the buffer into the minibuffer at a text prompt or during an incremental search? Is there a convenient way to insert, e.g., the sexp around point?
-
2Can you elaborate your use case? In the case you are trying to search for the thing at point (guessed from the isearch tag that you added), you can do `M-s . C-s` in emacs 24.4. – Kaushal Modi Dec 14 '14 at 05:13
-
For example with `el-get-install`. Surely I can install from package-menu buffer, but it not so quick. Or for grep commands. – Netsu Dec 14 '14 at 08:48
-
@Netsu: Please clarify whether the question is about Isearch or is about the minibuffer. You included tag `isearch`. And @Pradhan edited the title such that it made no sense (both minibuffer and Isearch were present), and that edit was approved (I voted to reject it). I've rolled back that edit, temporarily. It is ***up to you*** to clarify what question you really want to ask. The Q&A wrt minibuffer is quite different from the Q&A wrt Isearch. **Isearch does not use the minibuffer.** – Drew Dec 14 '14 at 17:49
-
@Drew Sorry about that - I thought the input to `isearch` when invoked interactively is through the minibuffer. How does it get the input then? – Pradhan Dec 14 '14 at 18:29
-
2No reason to be sorry. **Many, maybe most, users have the same mistaken impression.** What Isearch does is complicated. It sets `overriding-terminal-local-map` temporarily, so it interprets each input char/event its own way. It binds `cursor-in-echo-area`, to show the cursor in the echo area. And it uses `message` to show the "prompt" and the current search string in the echo area. In short, **it uses the echo area** (an output area) instead of the minibuffer (an input area). – Drew Dec 14 '14 at 21:23
-
But you still have not made clear whether you are asking about Isearch. We've had two edits from others so far, based on assuming this is the case. If it is, OK, but it still would have been better if you had edited your own question to make this clear. – Drew Dec 14 '14 at 21:26
-
@Drew, actually question was about minibuffer, but information about isearch was helpful as well. – Netsu Dec 15 '14 at 14:22
-
1OK, I've edited the question to make it clear that this is about inserting buffer text into the minibuffer, not yanking buffer text onto the Isearch search string. – Drew Dec 15 '14 at 15:14
-
@Drew thank you. And sorry, I missed that currently use *helm-mode* which let me use `C-w` like *isearch*. So actually there's few different questions about same thing (inserting things at point): for helm-mode, for isearch, for minibuffer. Could you suggest, should I edit question to add all this themes or it will be better to create different questions (and for inserting active region from buffer as well, for example)? – Netsu Dec 15 '14 at 15:41
-
1Create different questions. Each question post should pose a *single*, clear question. Thx. – Drew Dec 15 '14 at 15:43
1 Answers
If you use library Icicles then you can use M-.
at any time from the minibuffer to insert a thing-at-point from the buffer.
You can repeat M-.
to either (a) append subsequent such things from the buffer or (b) change the kind of thing, inserting a different kind instead (cycling through thing types).
This is explained at Icicles - Inserting Text from Cursor.
If you use library ThingAtPoint+ (thingatpt+.el
) then you can grab additional kinds of thing, and you can grab them near point as well as at point.
Keep in mind that none of this has to do with Isearch, which does not in fact use the minibuffer (except when you use M-e
, to edit the search string).
If you want to grab (yank) a thing at point and append it to your Isearch search string, you can use library Isearch+ (isearch+.el
) to yank these kinds of thing:
C-y C-_
isearchp-yank-symbol-or-char
C-y C-(
isearchp-yank-sexp-symbol-or-char
C-y C-c
isearchp-yank-char
C-y C-e
isearchp-yank-line
C-y C-w
isearchp-yank-word-or-char
And you can define your own yank command that yanks whatever you want from the buffer. For example, you can have it move point around temporarily and grab, for example, the full word (or sexp or whatever) that point is in. See the definitions of other Isearch yank commands for how this is done. It is quite simple, but since you do not specify what behavior you are after there is little sense in showing code here that tries to guess what that is.

- 75,699
- 9
- 109
- 225