help-gnu-emacs
[Top][All Lists]
Advanced

[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: bigfaceworm
Subject: Re: looking for: query-replace with a "yank-word" binding ala isearch
Date: 11 Nov 2002 14:21:32 -0800

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)))))))

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?


TJ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]