aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mackenzie2017-05-21 10:16:09 +0000
committerAlan Mackenzie2017-05-21 10:16:09 +0000
commitb0b02ca7f3e06d0f092df6f81babd1277bf93b0f (patch)
tree8d5d40e2150d975bd4a4a67e3190fe65b0f9ed37 /src
parent9759b249e97d4b05644309fc70ae9277b347027e (diff)
downloademacs-b0b02ca7f3e06d0f092df6f81babd1277bf93b0f.tar.gz
emacs-b0b02ca7f3e06d0f092df6f81babd1277bf93b0f.zip
Enhance mode-line percentage offset facility, with "%o" and "%q"
"%o" will display the percentage "travel" of the window through the buffer. "%q" will display a combination of the percentage offsets of the top and bottom of the window. The new user option mode-line-percent-position will facilitate selecting a setting for this part of the mode line. * lisp/bindings.el (mode-line-percent-position): New customizable user option. (mode-line-position): Use mode-line-percent-position in place of "%p", etc. * src/xdisp.c (decode_mode_spec): Add handlers for "%o" and "%q". * doc/lispref/modes.texi (Mode Line Variables): Document mode-line-percent-position. (%-Constructs): Document %o and %q. * etc/NEWS: Add an entry for these new facilities.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index c0e821a934c..05880617385 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -23924,6 +23924,27 @@ decode_mode_spec (struct window *w, register int c, int field_width,
23924 return " Narrow"; 23924 return " Narrow";
23925 break; 23925 break;
23926 23926
23927 /* Display the "degree of travel" of the window through the buffer. */
23928 case 'o':
23929 {
23930 ptrdiff_t toppos = marker_position (w->start);
23931 ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
23932 ptrdiff_t begv = BUF_BEGV (b);
23933 ptrdiff_t zv = BUF_ZV (b);
23934
23935 if (zv <= botpos)
23936 return toppos <= begv ? "All" : "Bottom";
23937 else if (toppos <= begv)
23938 return "Top";
23939 else
23940 {
23941 sprintf (decode_mode_spec_buf, "%2d%%",
23942 percent99 (toppos - begv, (toppos - begv) + (zv - botpos)));
23943 return decode_mode_spec_buf;
23944 }
23945 }
23946
23947 /* Display percentage of buffer above the top of the screen. */
23927 case 'p': 23948 case 'p':
23928 { 23949 {
23929 ptrdiff_t pos = marker_position (w->start); 23950 ptrdiff_t pos = marker_position (w->start);
@@ -23961,6 +23982,33 @@ decode_mode_spec (struct window *w, register int c, int field_width,
23961 } 23982 }
23962 } 23983 }
23963 23984
23985 /* Display percentage offsets of top and bottom of the window,
23986 using "All" (but not "Top" or "Bottom") where appropriate. */
23987 case 'q':
23988 {
23989 ptrdiff_t toppos = marker_position (w->start);
23990 ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
23991 ptrdiff_t begv = BUF_BEGV (b);
23992 ptrdiff_t zv = BUF_ZV (b);
23993
23994 if ((toppos <= begv) && (zv <= botpos))
23995 return "All ";
23996
23997 if (toppos <= begv)
23998 strcpy (decode_mode_spec_buf, "0-");
23999 else
24000 sprintf (decode_mode_spec_buf, "%d-",
24001 percent99 (toppos - begv, zv - begv));
24002
24003 if (zv <= botpos)
24004 strcat (decode_mode_spec_buf, "100%");
24005 else
24006 sprintf (&decode_mode_spec_buf [strlen (decode_mode_spec_buf)],
24007 "%d%%", percent99 (botpos - begv, zv - begv));
24008
24009 return decode_mode_spec_buf;
24010 }
24011
23964 case 's': 24012 case 's':
23965 /* status of process */ 24013 /* status of process */
23966 obj = Fget_buffer_process (Fcurrent_buffer ()); 24014 obj = Fget_buffer_process (Fcurrent_buffer ());