From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: scroll-margin - does it work as advertized? Date: Sun, 15 Feb 2009 12:29:23 -0800 Message-ID: <001301c98fac$1758eb20$0200a8c0@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1234729774 11283 80.91.229.12 (15 Feb 2009 20:29:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 15 Feb 2009 20:29:34 +0000 (UTC) Cc: andre.riemann@web.de To: "'Emacs-Devel devel'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 15 21:30:48 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LYndV-0006MN-8e for ged-emacs-devel@m.gmane.org; Sun, 15 Feb 2009 21:30:45 +0100 Original-Received: from localhost ([127.0.0.1]:32775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LYncB-0003nB-AQ for ged-emacs-devel@m.gmane.org; Sun, 15 Feb 2009 15:29:23 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LYnc6-0003n6-Fb for emacs-devel@gnu.org; Sun, 15 Feb 2009 15:29:18 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LYnc4-0003mu-Vb for emacs-devel@gnu.org; Sun, 15 Feb 2009 15:29:17 -0500 Original-Received: from [199.232.76.173] (port=47833 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LYnc4-0003mr-Nw for emacs-devel@gnu.org; Sun, 15 Feb 2009 15:29:16 -0500 Original-Received: from rcsinet13.oracle.com ([148.87.113.125]:62141 helo=rgminet13.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LYnc4-00063u-BG for emacs-devel@gnu.org; Sun, 15 Feb 2009 15:29:16 -0500 Original-Received: from acsinet13.oracle.com (acsinet13.oracle.com [141.146.126.235]) by rgminet13.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n1FKUBOx021796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 15 Feb 2009 20:30:12 GMT Original-Received: from acsmt701.oracle.com (acsmt701.oracle.com [141.146.40.71]) by acsinet13.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n1FKTExd024669; Sun, 15 Feb 2009 20:29:15 GMT Original-Received: from dradamslap1 (/24.5.128.33) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 15 Feb 2009 12:29:07 -0800 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcmPrBamIqLMl+CRRBya8faKH19wsw== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 X-Source-IP: acsmt701.oracle.com [141.146.40.71] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090203.49987B15.012D:SCFSTAT928724,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:109090 Archived-At: I've read the doc (Emacs and Elisp manuals, and doc string) for `scroll-margin', and what I understand from that doc doesn't seem to correspond to the behavior I see. If others don't think there is a bug, then perhaps someone can help me understand better how this option works. My understanding from the doc is that you cannot move the window point to within `scroll-margin' lines of the top or bottom of the window - as soon as you try to do so, the window is scrolled to move the window point `scroll-margin' lines from the top or bottom. What I see, however, is that the effective margin as I (mis?)understand it is sometimes much smaller than the value of `scroll-margin'. And any `scroll-margin' value greater than about 1/3 of the window height seems to give the same effective margin. I see this in both Emacs 22 and 23 (which supports my guess that I'm misunderstanding the doc). If I set `scroll-margin' to 5 or 10, then, with a window-height of 39 (window-text-height of 38), I can move the window point to within 6 or 10 lines of the top or bottom, but not to within 5 or 9 lines. That's about what I would expect (I'd expect 10 instead of 9). But if I set `scroll-margin' to 20 or 15 (same window height), then I can move the window point to within 10 lines of the top or bottom, but not to within 8 (bottom) or 9 lines (top). Similarly, with a window-height of 27 and a `scroll-margin' of 20, 15, or 10, I can move the window point to within 7 lines of the top or bottom, but not to within 6 lines. With a `scroll-margin' of 5, I get the behavior I'd expect: can't get within 5 lines of the top/bottom. That the window-height affects the behavior of `scroll-margin' doesn't surprise me (though that fact and just how it affects it do not seem to be documented). It's how it seems to affect it that puzzles me. I would expect that if the value `scroll-margin' is >= half of the window height, then the cursor would just stay in the middle of the window, since Emacs would try to keep the window point at least `scroll-margin' from both top and bottom. In one particular context, keeping the window point in the middle of the window is the behavior I was looking for: keep the window point fixed relative to the window, while scrolling the text relative to the window, when I move point. That is somewhat like what `scroll-preserve-screen-position' does, but for point-movement commands, not scroll commands. I wanted the window point's line to remain fixed wrt the window, regardless of how I move point relative to the buffer. IOW, in this particular context, I want the window to follow the cursor as I move point, and I want the window point's line to remain constant. What is a good way to get that behavior using vanilla Emacs? I've since found a couple of things on Emacs Wiki that offer this behavior, in particular this library: http://www.emacswiki.org/cgi-bin/emacs/centered-cursor-mode.el, by Andre Riemann. It keeps the cursor centered in the window, as you move point. That library does what I was looking for. But beyond meeting that particular use case, I wonder what I'm missing wrt how `scroll-margin' works, or should work.