Re: Insert word at point in minibuffer
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
Re: Insert word at point in minibuffer         


Author: Nick Sandow
Date: Aug 16, 2008 11:31

Hello again,

Actually, the code below is broken. Allow me to try posting that
again. As mentioned before, this allows you to yank into the minibuffer
the word at point.

Really, what I want to know is, can this be done "out of the box" in Emacs?

Here's the code:

(defun badger-minibuffer-yank-word ()
"Insert into the minibuffer the word at point in the selected
window. If invoked outside of the minibuffer, throw an error.

A good way to use this function is to bind it to a key in
mini-buffer-local-map, like so:

(define-key
minibuffer-local-map (kbd \"C-w\") 'badger-minibuffer-yank-word)

If point is not at a word, throw an error."
(interactive)
(insert (save-excursion
(set-buffer (window-buffer (minibuffer-selected-window)))
(thing-at-point 'word))))
(define-key minibuffer-local-map (kbd "M-w") 'badger-minibuffer-yank-word)

The Badger wrote:
> Hi,
>
> I wanted to be able to insert the word at point into the minibuffer.
> This is useful when doing, for example, M-x query-replace on the word
> at point. You run the query...
Show full article (2.22Kb)
no comments