[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: looking for: query-replace with a "yank-word" binding ala isearch
From: |
Kevin Rodgers |
Subject: |
Re: looking for: query-replace with a "yank-word" binding ala isearch |
Date: |
Tue, 12 Nov 2002 10:46:37 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2 |
bigfaceworm wrote:
Kevin's help worked wonderfully,
*except* now I have some odd behavior in my elisp.
When I debug the routine (via edebug) it works just
fine, but when it's loaded outside of edebug, it
grabs the wrong characters:
(defun bfw-insert-word ()
"insert word the cursor is on into minibuffer"
(interactive)
(let ((oldtxt (buffer-substring (save-excursion (beginning-of-line)
(point)) (point))))
(insert
(save-excursion
(set-buffer (window-buffer minibuffer-scroll-window))
(buffer-substring (progn (forward-char (length oldtxt))
(point)) (progn (forward-word 1) (point)))))))
Why should the contents of the minibuffer affect what text is inserted?
(defun bfw-insert-word ()
"Insert the word after point from the selected buffer into the minibuffer.
This advances point in the selected buffer."
(interactive)
(insert (save-excursion
(set-buffer (window-buffer minibuffer-scroll-window))
(buffer-substring (point)
(progn (forward-word 1) (point))))))
M-x global-set-key f9 bfw-insert-word
Create a new buffer, with contents:
1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z
move the point to the left of the `1', and query-replace
M-% f9 f9 f9 f9 f9 f9
gives you "12 4 7 b g"
but if you debug the routine (M-x edebug-defun)
and do the same test (hitting 'c' to continue)
you get "1 2 3 4 5 6"
Any idea why a defun would act differently when debugged versus
normal?
Perhaps the debugger is restoring point or some other aspect of the window/
buffer configuration.
--
<a href="mailto:<kevin.rodgers@ihs.com>">Kevin Rodgers</a>