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: RE: recenter-top-bottom Date: Mon, 12 Nov 2007 00:50:45 -0800 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1194857480 32633 80.91.229.12 (12 Nov 2007 08:51:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 Nov 2007 08:51:20 +0000 (UTC) To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 12 09:51:24 2007 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 1IrV0u-00049i-AI for ged-emacs-devel@m.gmane.org; Mon, 12 Nov 2007 09:51:24 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IrV0i-0007vY-8q for ged-emacs-devel@m.gmane.org; Mon, 12 Nov 2007 03:51:12 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IrV0e-0007uB-Vw for emacs-devel@gnu.org; Mon, 12 Nov 2007 03:51:09 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IrV0c-0007ty-LK for emacs-devel@gnu.org; Mon, 12 Nov 2007 03:51:07 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IrV0c-0007tv-Ch for emacs-devel@gnu.org; Mon, 12 Nov 2007 03:51:06 -0500 Original-Received: from mx20.gnu.org ([199.232.41.8]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IrV0c-00081t-3Z for emacs-devel@gnu.org; Mon, 12 Nov 2007 03:51:06 -0500 Original-Received: from agminet01.oracle.com ([141.146.126.228]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IrV0U-0000M1-9G for emacs-devel@gnu.org; Mon, 12 Nov 2007 03:50:58 -0500 Original-Received: from agmgw2.us.oracle.com (agmgw2.us.oracle.com [152.68.180.213]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id lAC8onN7017080 for ; Mon, 12 Nov 2007 02:50:49 -0600 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by agmgw2.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id lAC7hgVk023546 for ; Mon, 12 Nov 2007 01:50:48 -0700 Original-Received: from dhcp-amer-whq-csvpn-gw3-141-144-80-223.vpn.oracle.com by acsmt350.oracle.com with ESMTP id 3359205451194857432; Mon, 12 Nov 2007 00:50:32 -0800 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by mx20.gnu.org: Linux 2.4-2.6 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:83033 Archived-At: > So I think your first suggestion is better, and I am still thinking > of maybe installing it. If people are very enthusiastic about > your second suggestion, I will say yes to it. Just to make it easier for people who might want to try both and compare, here again are the two definitions. Each is a possible alternative binding for `C-l'. (I've added the `scroll-conservatively' feature to #1, as well as #2.) (defun recenter-top-bottom-1 (&optional arg) "Move current line to window center, top, and bottom, successively. With prefix ARG, move current line to window-line ARG. Top and bottom destinations are actually `scroll-conservatively' lines from true top and bottom." (interactive "P") (cond ((and (eq this-command last-command) (not arg)) (setq this-command 'recenter-top-bottom-top) (recenter scroll-conservatively)) ((and (eq 'recenter-top-bottom-top last-command) (not arg)) (setq this-command 'recenter-top-bottom-bottom) (recenter (1- (- scroll-conservatively)))) (t (recenter arg)))) (defun recenter-top-bottom-2 (&optional arg) "Move current line to line ARG, window center, top, or bottom. With a prefix argument, this is the same as `recenter': With numeric prefix ARG, move current line to window-line ARG. With plain `C-u', move current line to window center. Otherwise, the window starting position determines the next position: If in the top third, move to bottom. If in middle third, move to top. If in bottom third, move tocenter. Top and bottom destinations are actually `scroll-conservatively' lines from true top and bottom." (interactive "P") (cond (arg (recenter arg)) (t (let* ((top (1+ (count-lines 1 (window-start)))) (bottom (1+ (count-lines 1 (window-end)))) (current (1+ (count-lines 1 (point)))) (total (window-height))) (cond ((< (- current top) (/ total 3)) (recenter (1- (- scroll-conservatively)))) ((< (- bottom current) (/ total 3)) (recenter '(4))) (t (recenter scroll-conservatively)))))))