From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Suggestion to change the behavior of M-r Date: Tue, 06 Oct 2009 00:33:07 +0300 Organization: JURTA Message-ID: <871vlhplv0.fsf@mail.jurta.org> References: <7b501d5c0904190940x24e9412fvb26dc531b096a62d@mail.gmail.com> <7b501d5c0908121151h59753720iaf34c60f06a074af@mail.gmail.com> <87y6poivkn.fsf@mail.jurta.org> <7b501d5c0908121620q720b33b4mb690d69c1365f36c@mail.gmail.com> <87my63v0dq.fsf@mail.jurta.org> <7b501d5c0910040951i9855c08iadd859644d6db118@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1254779747 10381 80.91.229.12 (5 Oct 2009 21:55:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Oct 2009 21:55:47 +0000 (UTC) Cc: emacs-devel@gnu.org To: Deniz Dogan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 05 23:55:37 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 1MuvWr-0005LJ-9t for ged-emacs-devel@m.gmane.org; Mon, 05 Oct 2009 23:55:37 +0200 Original-Received: from localhost ([127.0.0.1]:39177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MuvWq-00064D-9d for ged-emacs-devel@m.gmane.org; Mon, 05 Oct 2009 17:55:36 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MuvWP-0005kO-SU for emacs-devel@gnu.org; Mon, 05 Oct 2009 17:55:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MuvWK-0005g7-Vb for emacs-devel@gnu.org; Mon, 05 Oct 2009 17:55:09 -0400 Original-Received: from [199.232.76.173] (port=39785 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MuvWK-0005g0-Oy for emacs-devel@gnu.org; Mon, 05 Oct 2009 17:55:04 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:54957 helo=mx1.starman.ee) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MuvWK-0008Va-1A for emacs-devel@gnu.org; Mon, 05 Oct 2009 17:55:04 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.99.248.cable.starman.ee [82.131.99.248]) by mx1.starman.ee (Postfix) with ESMTP id 66ED33F4111; Tue, 6 Oct 2009 00:54:55 +0300 (EEST) In-Reply-To: <7b501d5c0910040951i9855c08iadd859644d6db118@mail.gmail.com> (Deniz Dogan's message of "Sun, 4 Oct 2009 18:51:42 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/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:115915 Archived-At: >> Yes, this is a separate question. =A0As for move-to-window-line-top-bo= ttom, >> I agree it should follow recenter-top-bottom. > > Can we conclude that this change is a reasonable one which should be > put into Emacs? The original message was posted about half a year ago > and since then no one has objected to this change. While I agree that adding move-to-window-line-top-bottom for consistency with recenter-top-bottom is reasonable, I don't think recenter-top-bottom itself has a reasonable implementation now. The problem is that currently the cycling order `middle -> top -> bottom' is hard-coded in `recenter-top-bottom'. I see no reason to impose this order on users. Below is a patch that adds a new customizable variable `recenter-destinations' with the default value '(middle top bottom) corresponding to the current hard-coded cycling order. In addition to possible values `top', `middle', `bottom', it's possible also to specify integers to move to the absolute window-line. And float numbers define the percentage between 0.0 and 1.0 from the top. As for `move-to-window', we could also do the same for it and rename it accordingly to something like move-to-window-line-top-bottom-or-anywhere-in-the-middle ;-) Index: lisp/window.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/window.el,v retrieving revision 1.183 diff -c -r1.183 window.el *** lisp/window.el 4 Oct 2009 00:41:23 -0000 1.183 --- lisp/window.el 5 Oct 2009 21:30:46 -0000 *************** *** 1609,1646 **** =20 (defvar recenter-last-op nil "Indicates the last recenter operation performed. ! Possible values: `top', `middle', `bottom'.") =20 (defun recenter-top-bottom (&optional arg) ! "Move current line to window center, top, and bottom, successively. ! With no prefix argument, the first call redraws the frame and ! centers point vertically within the window. Successive calls ! scroll the window, placing point on the top, bottom, and middle ! consecutively. The cycling order is middle -> top -> bottom. =20 A prefix argument is handled like `recenter': With numeric prefix ARG, move current line to window-line ARG. ! With plain `C-u', move current line to window center. !=20 ! Top and bottom destinations are actually `scroll-margin' lines ! the from true window top and bottom." (interactive "P") (cond ! (arg (recenter arg)) ; Always respect ARG. ! ((or (not (eq this-command last-command)) ! (eq recenter-last-op 'bottom)) ! (setq recenter-last-op 'middle) ! (recenter)) (t (let ((this-scroll-margin (min (max 0 scroll-margin) (truncate (/ (window-body-height) 4.0))))) (cond ((eq recenter-last-op 'middle) ! (setq recenter-last-op 'top) ! (recenter this-scroll-margin)) ((eq recenter-last-op 'top) ! (setq recenter-last-op 'bottom) ! (recenter (- -1 this-scroll-margin)))))))) =20 (define-key global-map [?\C-l] 'recenter-top-bottom) =0C --- 1609,1667 ---- =20 (defvar recenter-last-op nil "Indicates the last recenter operation performed. ! Possible values: `top', `middle', `bottom', integer or float numbers.") !=20 ! (defcustom recenter-destinations '(middle top bottom) ! "Cycling order for `recenter-top-bottom'. ! A list of elements with possible values `top', `middle', `bottom', ! integer or float numbers that define the cycling order for ! the command `recenter-top-bottom'. !=20 ! Top and bottom destinations are `scroll-margin' lines the from true ! window top and bottom. Middle redraws the frame and centers point ! vertically within the window. Integer number moves current line to ! the specified absolute window-line. Float number between 0.0 and 1.0 ! means the percentage of the screen space from the top. The default ! cycling order is middle -> top -> bottom." ! :type '(repeat (choice ! (const :tag "Top" top) ! (const :tag "Middle" middle) ! (const :tag "Bottom" bottom) ! (integer :tag "Line number") ! (float :tag "Percentage"))) ! :version "23.2" ! :group 'windows) =20 (defun recenter-top-bottom (&optional arg) ! "Move current buffer line to the specified window line. ! With no prefix argument, successive calls place point according ! to the cycling order defined by `recenter-destinations'. =20 A prefix argument is handled like `recenter': With numeric prefix ARG, move current line to window-line ARG. ! With plain `C-u', move current line to window center." (interactive "P") (cond ! (arg (recenter arg)) ; Always respect ARG. (t + (setq recenter-last-op + (if (eq this-command last-command) + (car (or (cdr (member recenter-last-op recenter-destinations)) + recenter-destinations)) + (car recenter-destinations))) (let ((this-scroll-margin (min (max 0 scroll-margin) (truncate (/ (window-body-height) 4.0))))) (cond ((eq recenter-last-op 'middle) ! (recenter)) ((eq recenter-last-op 'top) ! (recenter this-scroll-margin)) ! ((eq recenter-last-op 'bottom) ! (recenter (- -1 this-scroll-margin))) ! ((integerp recenter-last-op) ! (recenter recenter-last-op)) ! ((floatp recenter-last-op) ! (recenter (round (* recenter-last-op (window-height)))))))))) =20 (define-key global-map [?\C-l] 'recenter-top-bottom) =0C --=20 Juri Linkov http://www.jurta.org/emacs/