From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Greg Hill Newsgroups: gmane.emacs.help Subject: Re: scroll behaviour during query-replace etc Date: Fri, 8 Oct 2004 12:24:32 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <41665dcb@news.wineasy.se> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0940829613==" X-Trace: sea.gmane.org 1097281785 3539 80.91.229.6 (9 Oct 2004 00:29:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 9 Oct 2004 00:29:45 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 09 02:29:39 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CG57D-0006Zg-00 for ; Sat, 09 Oct 2004 02:29:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CG5E1-0006cm-8x for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Oct 2004 20:36:41 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CG5Ap-0003ZY-5P for help-gnu-emacs@gnu.org; Fri, 08 Oct 2004 20:33:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CG5Ao-0003Yv-6E for help-gnu-emacs@gnu.org; Fri, 08 Oct 2004 20:33:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CG5An-0003Yo-Ue for help-gnu-emacs@gnu.org; Fri, 08 Oct 2004 20:33:21 -0400 Original-Received: from [199.232.41.8] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CG4y6-0003gR-AS for help-gnu-emacs@gnu.org; Fri, 08 Oct 2004 20:20:14 -0400 Original-Received: from [207.158.54.5] (helo=renfield.synergymicro.com) by mx20.gnu.org with esmtp (Exim 4.34) id 1CG0Nu-0003tH-UT for help-gnu-emacs@gnu.org; Fri, 08 Oct 2004 15:26:35 -0400 Original-Received: from synergy.san.synergymicro.com (synergy.san.synergymicro.com [10.1.2.12]) by renfield.synergymicro.com (8.12.10/8.12.10) with ESMTP id i98JSsmQ026183 for ; Fri, 8 Oct 2004 12:28:54 -0700 Original-Received: from [10.1.5.75] ([10.1.5.75]) by synergy.san.synergymicro.com (8.12.10/8.12.10) with ESMTP id i98JQGY9007936 for ; Fri, 8 Oct 2004 12:26:16 -0700 In-Reply-To: <41665dcb@news.wineasy.se> Original-To: help-gnu-emacs@gnu.org X-Virus-Scanned: clamd / ClamAV version 0.70, clamav-milter version 0.70j X-CanItPRO-Stream: default X-Canit-Stats-ID: 360268 - 6eb3ba3b180e X-Scanned-By: CanIt (www . canit . ca) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:21148 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21148 --===============0940829613== Content-Type: multipart/alternative; boundary="============_-1114859022==_ma============" --============_-1114859022==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" 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 --============_-1114859022==_ma============ Content-Type: text/html; charset="us-ascii" Re: scroll behaviour during query-replace etc
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
--============_-1114859022==_ma============-- --===============0940829613== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --===============0940829613==--