[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scroll behaviour during query-replace etc
From: |
Greg Hill |
Subject: |
Re: scroll behaviour during query-replace etc |
Date: |
Fri, 8 Oct 2004 12:24:32 -0700 |
At 11:28 AM +0200 10/8/04, Gordon Beaton wrote:
When I use query-replace (also
query-replace-regexp or even isearch
for that matter) and matches are relatively frequent, i.e. less than
a
windowfull of lines apart, a match will often be found at or near
the
last window line where I can't see enough context to decide whether
to
replace or not (or whether I've reached the thing I was searching
for).
I use scroll-margin to force the point to stay away from the top
and
bottom edges while scrolling, unfortunately that doesn't seem to
affect these functions.
Is there a way to keep the point (relatively!) centered during
query-replace, or (alternatively) force it to stay on the same
window
line?
Gordon,
Something like the following might do the trick for you, or at
least provide a place to start.
(defadvice search-forward (after
view-context compile disable activate)
(if (< (count-lines (point)
(window-end)) 5)
(recenter)))
(defadvice query-replace (around view-context compile activate)
(ad-enable-advice 'search-forward 'after 'view-context)
(ad-activate 'search-forward)
ad-do-it
(ad-disable-advice 'search-forward 'after 'view-context)
(ad-activate 'search-forward))
Good luck.
--Greg