From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chat Newsgroups: gmane.emacs.help Subject: Re: Insert word at point in minibuffer Date: Fri, 15 Aug 2008 18:48:13 -0700 Organization: Noname Inc. Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1218860613 13767 80.91.229.12 (16 Aug 2008 04:23:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Aug 2008 04:23:33 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 16 06:24:25 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KUDKt-0006OZ-3T for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Aug 2008 06:24:19 +0200 Original-Received: from localhost ([127.0.0.1]:36394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KUDJw-0003rA-CO for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Aug 2008 00:23:20 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!flpi089.ffdc.sbc.com!prodigy.net!flpi088.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!flpi147.ffdc.sbc.com.POSTED!1c384869!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Emacs Gnus Cancel-Lock: sha1:rr9TQuM0RMVv6yqVzMK1DXd+z7w= Original-Lines: 37 Original-NNTP-Posting-Host: 75.37.20.251 Original-X-Complaints-To: abuse@prodigy.net Original-X-Trace: flpi147.ffdc.sbc.com 1218851182 ST000 75.37.20.251 (Fri, 15 Aug 2008 21:46:22 EDT) Original-NNTP-Posting-Date: Fri, 15 Aug 2008 21:46:22 EDT X-UserInfo1: SCSYASJE]JV[C\\Y\Z^DJFXBWR\HPCTL@XT^OBPLAH[\BTUCCNSKQFCY@TXDX_WHSVB]ZEJLSNY\^J[CUVSA_QLFC^RQHUPH[P[NRWCCMLSNPOD_ESALHUK@TDFUZHBLJ\XGKL^NXA\EVHSP[D_C^B_^JCX^W]CHBAX]POG@SSAZQ\LE[DCNMUPG_VSC@VJM Original-Xref: news.stanford.edu gnu.emacs.help:161350 X-Mailman-Approved-At: Sat, 16 Aug 2008 00:20:54 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:56699 Archived-At: The Badger writes: > 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) Isn't it simpler to copy the text you want while in the buffer and then invoke the command? Or even easier to use, write another function that calls query-replace (or whatever command you want to call)?