From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: recenter-ratio (was: Re: Toolbars on MacOSX) Date: Thu, 13 May 2004 07:33:33 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87wu3h0wv6.fsf_-_@mail.jurta.org> References: <20040512.171251.91443934.mituharu@math.s.chiba-u.ac.jp> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1084423862 29459 80.91.224.253 (13 May 2004 04:51:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 13 May 2004 04:51:02 +0000 (UTC) Cc: steventamm@mac.com, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu May 13 06:50:55 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BO8BL-0001Cb-00 for ; Thu, 13 May 2004 06:50:55 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BO8BJ-0001Zg-00 for ; Thu, 13 May 2004 06:50:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BO89i-0005An-3u for emacs-devel@quimby.gnus.org; Thu, 13 May 2004 00:49:14 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BO84p-00044A-8s for emacs-devel@gnu.org; Thu, 13 May 2004 00:44:11 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BO83j-0002uW-MR for emacs-devel@gnu.org; Thu, 13 May 2004 00:43:36 -0400 Original-Received: from [66.33.219.4] (helo=spork.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BO7zp-0001WV-DN for emacs-devel@gnu.org; Thu, 13 May 2004 00:39:01 -0400 Original-Received: from mail.jurta.org (80-235-35-214-dsl.mus.estpak.ee [80.235.35.214]) by spork.dreamhost.com (Postfix) with ESMTP id 8F2DE11DC33; Wed, 12 May 2004 21:38:58 -0700 (PDT) Original-To: YAMAMOTO Mitsuharu In-Reply-To: <20040512.171251.91443934.mituharu@math.s.chiba-u.ac.jp> (YAMAMOTO Mitsuharu's message of "Wed, 12 May 2004 17:12:51 +0900 (JST)") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:23297 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:23297 YAMAMOTO Mitsuharu writes: > http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGWindows/chapter_16_section_3.html#//apple_ref/doc/uid/20000961/BABIFCFJ I must say that Apple human interface guidelines define very well-researched principles of implementing the good user interfaces. I will not discuss its usefulness for Emacs design now, but one chapter reminded me about an improvement I wanted to propose for addition to Emacs. The chapter at http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGWindows/chapter_16_section_4.html#//apple_ref/doc/uid/20000961-BACFHDHE defines a concept of "visually centered placement", where the distance from the bottom to the center should be approximately twice the distance as that from the center to the top. This applies to the window positioning, but the same principle makes sense also for the cursor positioning in Emacs. Currently by default the cursor is always placed exactly in the center of the window (i.e. on the window line equal to the window height divided by the constant 2). I use a special key to scroll the window to adjust the place with the cursor to more convenient vertical position (which is about 1/3 of the window height). Unfortunately, currently it is not possible to change the hard-coded default cursor position. The following patch introduces a new variable with the default value 2. Its value defines a ratio at which the cursor is placed by default from the top of the window relative to the window height. It even can be set to the Golden Ratio if one wishes so: (setq recenter-ratio (expt (/ (1+ (sqrt 5)) 2) 2)) Index: emacs/src/window.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/window.c,v retrieving revision 1.465 diff -u -r1.465 window.c --- emacs/src/window.c 7 May 2004 00:43:49 -0000 1.465 +++ emacs/src/window.c 13 May 2004 04:34:11 -0000 @@ -120,6 +120,10 @@ Lisp_Object Vother_window_scroll_buffer; +Lisp_Object Vrecenter_ratio; + /* Non-nil means it's function to call to display temp buffers. */ Lisp_Object Vtemp_buffer_show_function; @@ -5172,7 +5221,7 @@ int ht = window_internal_height (w); if (center_p) - arg = make_number (ht / 2); + arg = make_number (ht / XFLOATINT (Vrecenter_ratio)); else if (XINT (arg) < 0) arg = make_number (XINT (arg) + ht); @@ -5241,7 +5290,7 @@ lines = displayed_window_lines (w); if (NILP (arg)) - XSETFASTINT (arg, lines / 2); + XSETFASTINT (arg, lines / XFLOATINT (Vrecenter_ratio)); else { arg = Fprefix_numeric_value (arg); @@ -6474,6 +6523,10 @@ doc: /* If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window. */); Vother_window_scroll_buffer = Qnil; + DEFVAR_LISP ("recenter-ratio", &Vrecenter_ratio, + doc: /* Ratio to recenter cursor. */); + Vrecenter_ratio = 2; + DEFVAR_BOOL ("pop-up-frames", &pop_up_frames, doc: /* *Non-nil means `display-buffer' should make a separate frame. */); pop_up_frames = 0; Index: emacs/src/xdisp.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/xdisp.c,v retrieving revision 1.888 diff -u -r1.888 xdisp.c --- emacs/src/xdisp.c 10 May 2004 11:16:37 -0000 1.888 +++ emacs/src/xdisp.c 13 May 2004 03:34:29 -0000 @@ -229,6 +229,8 @@ extern Lisp_Object Qwhen; extern Lisp_Object Qhelp_echo; +extern Lisp_Object Vrecenter_ratio; + Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions; Lisp_Object Qredisplay_end_trigger_functions; @@ -11722,7 +11724,7 @@ /* If point does not appear, try to move point so it does appear. The desired matrix has been built above, so we can use it here. */ - new_vpos = window_box_height (w) / 2; + new_vpos = window_box_height (w) / XFLOATINT (Vrecenter_ratio); } if (!make_cursor_line_fully_visible (w, 0)) @@ -11922,7 +11924,7 @@ /* Finally, just choose place to start which centers point */ recenter: - centering_position = window_box_height (w) / 2; + centering_position = window_box_height (w) / XFLOATINT (Vrecenter_ratio); point_at_top: /* Jump here with centering_position already set to 0. */ -- Juri Linkov http://www.jurta.org/emacs/