From: Alan Mackenzie <acm@muc.de>
To: rms@gnu.org, 1355@emacsbugs.donarmstrong.com
Cc: xah lee <xah@xahlee.org>,
bug-gnu-emacs@gnu.org, bug-submit-list@donarmstrong.com
Subject: bug#1355: suggestion on the modeline
Date: Mon, 17 Nov 2008 23:26:48 +0000 [thread overview]
Message-ID: <20081117232648.GA9335@muc.de> (raw)
In-Reply-To: <E1L1uIj-0003nH-1c@fencepost.gnu.org>
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).
next prev parent reply other threads:[~2008-11-17 23:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-16 1:09 bug#1355: suggestion on the modeline xah lee
2008-11-17 2:57 ` Richard M. Stallman
2008-11-17 23:26 ` Alan Mackenzie [this message]
2008-11-18 3:47 ` Stefan Monnier
2008-11-18 9:42 ` Juanma Barranquero
2008-11-18 10:37 ` Alan Mackenzie
2008-11-18 10:37 ` Juanma Barranquero
2008-11-18 16:30 ` Stefan Monnier
2008-11-18 18:17 ` James Cloos
2020-09-19 21:59 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081117232648.GA9335@muc.de \
--to=acm@muc.de \
--cc=1355@emacsbugs.donarmstrong.com \
--cc=bug-gnu-emacs@gnu.org \
--cc=bug-submit-list@donarmstrong.com \
--cc=rms@gnu.org \
--cc=xah@xahlee.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.