"%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.
line number and the column number.
@end defvar
+@defopt mode-line-percent-position
+This option is used in @code{mode-line-position}. Its value specifies
+both the buffer percentage to display (one of @code{nil}, @code{"%o"},
+@code{"%p"}, @code{"%P"} or @code{"%q"}, @pxref{%-Constructs}) and a
+width to space-fill or truncate to. You are recommended to set this
+option with the @code{customize-variable} facility.
+@end defopt
+
@defvar vc-mode
The variable @code{vc-mode}, buffer-local in each buffer, records
whether the buffer's visited file is maintained with version control,
@samp{Narrow} when narrowing is in effect; nothing otherwise (see
@code{narrow-to-region} in @ref{Narrowing}).
+@item %o
+The degree of @dfn{travel} of the window through (the visible portion
+of) the buffer, i.e. the size of the text above the top of the window
+expressed as a percentage of all the text outside the window, or
+@samp{Top}, @samp{Bottom} or @samp{All}.
+
@item %p
The percentage of the buffer text above the @strong{top} of window, or
@samp{Top}, @samp{Bottom} or @samp{All}. Note that the default mode
the text above the top), plus @samp{Top} if the top of the buffer is
visible on screen; or @samp{Bottom} or @samp{All}.
+@item %q
+The percentages of text above both the @strong{top} and the
+@strong{bottom} of the window, separated by @samp{-}, or @samp{All}.
+
@item %s
The status of the subprocess belonging to the current buffer, obtained with
@code{process-status}. @xref{Process Information}.
displayed to be horizontally scrolled when lines are truncated on
display and point moves outside the left or right window margin.
++++
+** New mode line constructs '%o' and '%q', and user option
+'mode-line-percent-position'. '%o' displays the "degree of travel" of
+the window through the buffer. Unlike the default '%p', this
+percentage approaches 100% as the window approaches the end of the
+buffer. '%q' displays the percentage offsets of both the start and
+the end of the window, e.g. "5-17%". The new option
+'mode-line-percent-position' makes it easier to switch between '%p',
+'%P', and these new constructs.
+
+++
** Two new user options 'list-matching-lines-jump-to-current-line' and
'list-matching-lines-current-line-face' to show highlighted the current
:group 'mode-line
:version "26.1")
+(defcustom mode-line-percent-position '(-3 "%p")
+ "Specification of \"percentage offset\" of window through buffer
+This option specifies both the field width and the type of offset
+displayed in `mode-line-position', a component of the default
+`mode-line-format'."
+ :type `(radio
+ (const :tag "nil: No offset is displayed" nil)
+ (const :tag "\"%o\": Proportion of \"travel\" of the window through the buffer"
+ (-3 "%o"))
+ (const :tag "\"%p\": Percentage offset of top of window"
+ (-3 "%p"))
+ (const :tag "\"%P\": Precentage offset of bottom of window"
+ (-3 "%P"))
+ (const :tag "\"%q\": Offsets of both top and bottom of window"
+ (6 "%q")))
+ :version "26.1"
+ :group 'mode-line)
+
(defvar mode-line-position
- `((-3 ,(propertize
- "%p"
- 'local-map mode-line-column-line-number-mode-map
- 'mouse-face 'mode-line-highlight
- ;; XXX needs better description
- 'help-echo "Size indication mode\n\
-mouse-1: Display Line and Column Mode Menu"))
+ `((:propertize
+ mode-line-percent-position
+ 'local-map mode-line-column-line-number-mode-map
+ 'mouse-face 'mode-line-highlight
+ ;; XXX needs better description
+ 'help-echo "Size indication mode\n\
+mouse-1: Display Line and Column Mode Menu")
(size-indication-mode
(8 ,(propertize
" of %I"
return " Narrow";
break;
+ /* Display the "degree of travel" of the window through the buffer. */
+ case 'o':
+ {
+ ptrdiff_t toppos = marker_position (w->start);
+ ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
+ ptrdiff_t begv = BUF_BEGV (b);
+ ptrdiff_t zv = BUF_ZV (b);
+
+ if (zv <= botpos)
+ return toppos <= begv ? "All" : "Bottom";
+ else if (toppos <= begv)
+ return "Top";
+ else
+ {
+ sprintf (decode_mode_spec_buf, "%2d%%",
+ percent99 (toppos - begv, (toppos - begv) + (zv - botpos)));
+ return decode_mode_spec_buf;
+ }
+ }
+
+ /* Display percentage of buffer above the top of the screen. */
case 'p':
{
ptrdiff_t pos = marker_position (w->start);
}
}
+ /* Display percentage offsets of top and bottom of the window,
+ using "All" (but not "Top" or "Bottom") where appropriate. */
+ case 'q':
+ {
+ ptrdiff_t toppos = marker_position (w->start);
+ ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
+ ptrdiff_t begv = BUF_BEGV (b);
+ ptrdiff_t zv = BUF_ZV (b);
+
+ if ((toppos <= begv) && (zv <= botpos))
+ return "All ";
+
+ if (toppos <= begv)
+ strcpy (decode_mode_spec_buf, "0-");
+ else
+ sprintf (decode_mode_spec_buf, "%d-",
+ percent99 (toppos - begv, zv - begv));
+
+ if (zv <= botpos)
+ strcat (decode_mode_spec_buf, "100%");
+ else
+ sprintf (&decode_mode_spec_buf [strlen (decode_mode_spec_buf)],
+ "%d%%", percent99 (botpos - begv, zv - begv));
+
+ return decode_mode_spec_buf;
+ }
+
case 's':
/* status of process */
obj = Fget_buffer_process (Fcurrent_buffer ());