* scroll behaviour during query-replace etc
@ 2004-10-08 9:28 Gordon Beaton
2004-10-08 19:24 ` Greg Hill
[not found] ` <mailman.2196.1097282004.2017.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 3+ messages in thread
From: Gordon Beaton @ 2004-10-08 9:28 UTC (permalink / raw)
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?
It might be worth mentioning that I normally have
scroll-conservatively set to 100 or so, since I'm not a big fan of
recentering while scrolling, however even the default setting doesn't
do what I want here, since there is no scroll until the point actually
tries to leave the window.
/gordon
--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: scroll behaviour during query-replace etc
2004-10-08 9:28 scroll behaviour during query-replace etc Gordon Beaton
@ 2004-10-08 19:24 ` Greg Hill
[not found] ` <mailman.2196.1097282004.2017.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: Greg Hill @ 2004-10-08 19:24 UTC (permalink / raw)
[-- Attachment #1.1: Type: text/plain, Size: 1242 bytes --]
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
[-- Attachment #1.2: Type: text/html, Size: 1924 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: scroll behaviour during query-replace etc
[not found] ` <mailman.2196.1097282004.2017.help-gnu-emacs@gnu.org>
@ 2004-10-11 6:39 ` Gordon Beaton
0 siblings, 0 replies; 3+ messages in thread
From: Gordon Beaton @ 2004-10-11 6:39 UTC (permalink / raw)
On Fri, 8 Oct 2004 12:24:32 -0700, Greg Hill wrote:
> Come to think of it, you might like this better.
>
> (defadvice search-forward (after view-context compile activate disable)
> (if (< (count-lines (point) (window-end)) scroll-margin)
> (recenter (- scroll-margin))))
Perfect, thanks!
/gordon
--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-10-11 6:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-08 9:28 scroll behaviour during query-replace etc Gordon Beaton
2004-10-08 19:24 ` Greg Hill
[not found] ` <mailman.2196.1097282004.2017.help-gnu-emacs@gnu.org>
2004-10-11 6:39 ` Gordon Beaton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).