From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Ehud Karni" Newsgroups: gmane.emacs.help Subject: Re: looking for: query-replace with a yank-word binding ala isearch Date: Mon, 11 Nov 2002 18:36:14 +0200 Organization: Mivtach-Simon Insurance agencies Sender: help-gnu-emacs-admin@gnu.org Message-ID: <200211111636.gABGaEue005606@beta.mvs.co.il> References: <2bd747c7.0211072024.1619ac84@posting.google.com> <3DCBEFFE.2030202@ihs.com> Reply-To: ehud@unix.mvs.co.il NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-8 Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1037034340 12038 80.91.224.249 (11 Nov 2002 17:05:40 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 11 Nov 2002 17:05:40 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18BI0I-000381-00 for ; Mon, 11 Nov 2002 18:05:38 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18BHzo-0008Us-00; Mon, 11 Nov 2002 12:05:08 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18BHkV-00034g-00 for help-gnu-emacs@gnu.org; Mon, 11 Nov 2002 11:49:19 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18BHYH-0007cQ-00 for help-gnu-emacs@gnu.org; Mon, 11 Nov 2002 11:36:46 -0500 Original-Received: from unix.simonwiesel.co.il ([192.114.178.12] helo=unix.mvs.co.il) by monty-python.gnu.org with esmtp (Exim 4.10) id 18BHYF-0007bN-00 for help-gnu-emacs@gnu.org; Mon, 11 Nov 2002 11:36:40 -0500 Original-Received: from beta.mvs.co.il (beta [10.253.0.3]) by unix.mvs.co.il (8.11.6/8.11.6) with ESMTP id gABGaIh24833; Mon, 11 Nov 2002 18:36:19 +0200 Original-Received: from beta.mvs.co.il (localhost [127.0.0.1]) by beta.mvs.co.il (8.12.5/8.12.5) with ESMTP id gABGaGed005612; Mon, 11 Nov 2002 18:36:17 +0200 Original-Received: (from ehud@localhost) by beta.mvs.co.il (8.12.5/8.12.5/Submit) id gABGaEue005606; Mon, 11 Nov 2002 18:36:14 +0200 X-Authentication-Warning: beta.mvs.co.il: ehud set sender to ehud@unix.mvs.co.il using -f Original-To: bigfaceworm@hotmail.com, " Kevin Rodgers" In-reply-to: <3DCBEFFE.2030202@ihs.com> (message from Kevin Rodgers on Fri, 08 Nov 2002 10:10:22 -0700) X-Mailer: Emacs 21.2.91.3 rmail (send-msg 1.106) Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:3485 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:3485 On Thr, 7 Nov 2002 20:24:37 -0800, bigfaceworm wrote: > > I tried defining my own, but because the control switches to the > minibuffer, I'm not sure how to find the buffer in which to do: I use the following to insert the current word (defined as ANY non white space string) into the mini buffer: (defun insert-word-or-file-name () "copy word cursor is on or file name to minibuff input" (interactive) (let* ((bfl (current-buffer)) (str "")) (set-buffer (buffer-name-not-mini)) (cond ((eq major-mode 'dired-mode) (setq str (dired-get-filename t t))) ;; audit-mode is a privetly defined mode for MVS ;; ((eq major-mode 'audit-mode) ;; (setq str (audit-get-filename t t))) (t (let (bch ech) (forward-char 1) (backward-to-non-blank) (setq bch (point)) (re-search-forward "[^ \t\n][ \t\n]" (point-max) t) (setq ech (1- (point))) (setq str (buffer-substring-no-properties bch ech))))) (set-buffer bfl) (insert str))) (defun backward-to-non-blank () "go to 1st non blank (after blank) to left" (interactive) (if (re-search-backward "[ \t\n][^ \t\n]" (point-min) t) (forward-char 1) (if (string-match "[^ \t\n]" (buffer-substring 1 2)) (goto-char (point-min))))) (defun buffer-name-not-mini () "Return the name of current buffer, as a string. If current buffer is the *mini-buffer* return name of previous-window." (buffer-name (if (window-minibuffer-p) (if (eq (get-lru-window) (next-window)) (window-buffer (previous-window)) (window-buffer (next-window))) nil))) ;; to add it to mini buffer key maps: (defun keymap-test (var) ; internal function for keymap checking (and (boundp var) (keymapp (symbol-value var)))) (let ((minimaps (apropos-internal "mini" 'keymap-test)) map op) (while minimaps (setq map (symbol-value (car minimaps))) (setq minimaps (cdr minimaps)) (define-key map "\C-w" 'insert-word-or-file-name))) You don't need to change the `query-replace-map' because when you edit the replacement string you are using the minibuffer maps. Ehud. -- Ehud Karni Tel: +972-3-7966-561 /"\ Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign Insurance agencies (USA) voice mail and X Against HTML Mail http://www.mvs.co.il FAX: 1-815-5509341 / \ mailto:ehud@unix.mvs.co.il Better Safe Than Sorry