all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Insert word at point in minibuffer
@ 2008-08-15 22:47 The Badger
  2008-08-16 18:31 ` Nick Sandow
  0 siblings, 1 reply; 7+ messages in thread
From: The Badger @ 2008-08-15 22:47 UTC (permalink / raw)
  To: help-gnu-emacs

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-replace, hit a key to put the current word 
into the minibuffer, and go from there.  Quite often I want to do this, 
so it saves time over typing the word in over and over.

My solution is presented below.  However, can this be done out of the 
box in Emacs?  The less custom code I have to write, the better.  God 
knows I have enough of that in Emacs already.


(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\") 'njs-buffer-yank)

If point is not at a word, throw an error."

  (interactive)
  (insert (njs-call-in-buffer (lambda () (thing-at-point 'word))
                              (window-buffer (minibuffer-selected-window))))
   (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)




^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <mailman.16858.1218833586.18990.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2008-08-19  0:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-15 22:47 Insert word at point in minibuffer The Badger
2008-08-16 18:31 ` Nick Sandow
2008-08-16  6:43   ` Drew Adams
2008-08-19  0:20     ` Nick Sandow
2008-08-18  8:02       ` Drew Adams
     [not found] <mailman.16858.1218833586.18990.help-gnu-emacs@gnu.org>
2008-08-16  1:48 ` Chat
2008-08-18 23:37   ` The Badger

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.