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: Wed, 14 Nov 2007 13:57:58 -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 1195077559 12144 80.91.229.12 (14 Nov 2007 21:59:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 Nov 2007 21:59:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 14 22:59:23 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 1IsQGQ-0004hM-68 for ged-emacs-devel@m.gmane.org; Wed, 14 Nov 2007 22:59:14 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IsQGD-0000I3-HZ for ged-emacs-devel@m.gmane.org; Wed, 14 Nov 2007 16:59:01 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IsQG7-0000EJ-Dh for emacs-devel@gnu.org; Wed, 14 Nov 2007 16:58:55 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IsQG4-000091-Po for emacs-devel@gnu.org; Wed, 14 Nov 2007 16:58:53 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IsQG3-00008A-KN for emacs-devel@gnu.org; Wed, 14 Nov 2007 16:58:52 -0500 Original-Received: from rgminet01.oracle.com ([148.87.113.118]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IsQFy-0000Q8-85; Wed, 14 Nov 2007 16:58:46 -0500 Original-Received: from rgmgw2.us.oracle.com (rgmgw2.us.oracle.com [138.1.186.111]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id lAELwQHN016933; Wed, 14 Nov 2007 14:58:26 -0700 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by rgmgw2.us.oracle.com (Switch-3.2.4/Switch-3.2.4) with ESMTP id lAELwOsA010222; Wed, 14 Nov 2007 14:58:25 -0700 Original-Received: from dhcp-4op11-4op12-west-130-35-178-158.us.oracle.com by acsmt350.oracle.com with ESMTP id 3366328991195077475; Wed, 14 Nov 2007 13:57:55 -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 monty-python.gnu.org: Linux 2.4-2.6 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:83206 Archived-At: > I am still interested in your original design, which I think is good. I think the version below combines the best of each and should satisfy most people. It is the same as the original design, except that the cycling order is appropriate for where you start out. 1. An explicit arg (plain `C-u' or numeric) is always respected, whenever it is used. 2. Otherwise, the first `C-l' always recenters. 3. Otherwise, successive `C-l' cycles among top, middle, and bottom (top and bottom are modulo `scroll-conservatively'). The initial position (top, middle, or bottom third of the window) determines the cycling order: middle -> bottom -> top versus middle -> top -> bottom. #1 and #2 mean that unless you repeat `C-l' you get the normal `recenter' behavior. #3 means that cycling never repeats the same destination twice in a row - the order fits the initial cursor position. (defun recenter-top-bottom (&optional arg) "Move current line to window center, top, and bottom, successively. 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 move current line to window center on first call, and to top, middle, or bottom on successive calls. The starting position of the window determines the cycling order: If initially in the top or middle third: top -> middle -> bottom. If initially in the bottom third: bottom -> middle -> top. Top and bottom destinations are actually `scroll-conservatively' lines from true window top and bottom." (interactive "P") (if arg ; Always respect ARG. (recenter arg) (case last-command (recenter-tb-top ; Top -> middle -> bottom (setq this-command 'recenter-tb-middle) (recenter)) (recenter-tb-middle (setq this-command 'recenter-tb-bottom) (recenter (1- (- scroll-conservatively)))) (recenter-tb-bottom (setq this-command 'recenter-tb-top) (recenter scroll-conservatively)) (recenter-tb-bottom-1 ; Bottom -> middle -> top (setq this-command 'recenter-tb-middle-1) (recenter)) (recenter-tb-middle-1 (setq this-command 'recenter-tb-top-1) (recenter scroll-conservatively)) (recenter-tb-top-1 (setq this-command 'recenter-tb-bottom-1) (recenter (1- (- scroll-conservatively)))) (otherwise ; First time - save mode and recenter. (let ((bottom (1+ (count-lines 1 (window-end)))) (current (1+ (count-lines 1 (point)))) (total (window-height))) (if (< (- bottom current) (/ total 3)) (setq this-command 'recenter-tb-middle-1) (setq this-command 'recenter-tb-middle))) (recenter)))))