[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#1355: suggestion on the modeline
From: |
Alan Mackenzie |
Subject: |
bug#1355: suggestion on the modeline |
Date: |
Mon, 17 Nov 2008 23:26:48 +0000 |
User-agent: |
Mutt/1.5.9i |
Hi, R and X!
On Sun, Nov 16, 2008 at 09:57:21PM -0500, Richard M. Stallman wrote:
> The cursor location percentage should by default not shown if
> emacs is running in GUI with scroll bar.
> Maybe so.
> When emacs is running in a terminal, the special indicator
> Top and Bot should be shown as percentage as usual,
> "Top" is equivalent to 00%, and showing "00%" instead would
> be just as good. However, "Bot" gives you other information:
> that the bottom of the buffer is on the screen.
Incidentally, I think the wrong percentage is displayed. Assuming that
the window shows part of the buffer, there's stuff above, stuff below,
like this:
a ^
a |
a |
a |
W | ^
W | |
W | |
W buffer window
W | |
W | |
W | v
b |
b |
b |
b v
, the percentage currently displayed is a / (a + W + b). So, although in
the picture, the window is showing the middle of the buffer, the
percentage displayed is 22%, rather than 50%. This is particularly
jarring when scrolling through, perhaps, an info page. You see 47%, then
two lines later, Bot.
A better calculation would be a / (a + b), the degree of "travel" of the
windown through the buffer. This approaches 100% as the window reaches
the bottom of the buffer.
I've been using this for many years now. Here's how:
[ Emacs 22.3 ]
*** xdisp.orig.c 2008-08-26 15:45:44.000000000 +0000
--- xdisp.c 2008-09-12 13:59:17.000000000 +0000
***************
*** 18033,18041 ****
case 'p':
{
int pos = marker_position (w->start);
! int total = BUF_ZV (b) - BUF_BEGV (b);
! if (XFASTINT (w->window_end_pos) <= BUF_Z (b) - BUF_ZV (b))
{
if (pos <= BUF_BEGV (b))
return "All";
--- 18033,18043 ----
case 'p':
{
int pos = marker_position (w->start);
! int bottpos = BUF_Z (b) - XFASTINT (w->window_end_pos); /* ACM */
! int totnotdisp = BUF_ZV (b) - BUF_BEGV (b) - (bottpos - pos); /* ACM
*/
! int total ;
! if ((bottpos >= BUF_ZV (b)) || (totnotdisp <= 0)) /* ACM */
{
if (pos <= BUF_BEGV (b))
return "All";
***************
*** 18046,18056 ****
return "Top";
else
{
! if (total > 1000000)
/* Do it differently for a large value, to avoid overflow. */
! total = ((pos - BUF_BEGV (b)) + (total / 100) - 1) / (total /
100);
else
! total = ((pos - BUF_BEGV (b)) * 100 + total - 1) / total;
/* We can't normally display a 3-digit number,
so get us a 2-digit number that is close. */
if (total == 100)
--- 18048,18060 ----
return "Top";
else
{
! if (totnotdisp > 1000000)
/* Do it differently for a large value, to avoid overflow. */
! total = ((pos - BUF_BEGV (b)) + (totnotdisp / 100) - 1)
! / (totnotdisp / 100); /* ACM */
else
! total = ((pos - BUF_BEGV (b)) * 100 + totnotdisp - 1)
! / totnotdisp ; /* ACM */
/* We can't normally display a 3-digit number,
so get us a 2-digit number that is close. */
if (total == 100)
--
Alan Mackenzie (Nuremberg, Germany).
- bug#1355: suggestion on the modeline, xah lee, 2008/11/16
- bug#1355: suggestion on the modeline, Richard M. Stallman, 2008/11/16
- bug#1355: suggestion on the modeline,
Alan Mackenzie <=
- bug#1355: suggestion on the modeline, Stefan Monnier, 2008/11/17
- bug#1355: suggestion on the modeline, Juanma Barranquero, 2008/11/18
- bug#1355: suggestion on the modeline, Alan Mackenzie, 2008/11/18
- bug#1355: suggestion on the modeline, Juanma Barranquero, 2008/11/18
- bug#1355: suggestion on the modeline, Stefan Monnier, 2008/11/18
- bug#1355: suggestion on the modeline, James Cloos, 2008/11/18