diff options
| -rw-r--r-- | doc/lispref/modes.texi | 18 | ||||
| -rw-r--r-- | etc/NEWS | 10 | ||||
| -rw-r--r-- | lisp/bindings.el | 32 | ||||
| -rw-r--r-- | src/xdisp.c | 48 |
4 files changed, 101 insertions, 7 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index eb72fcfd369..0e476b47a31 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi | |||
| @@ -1972,6 +1972,14 @@ displays the buffer percentage and, optionally, the buffer size, the | |||
| 1972 | line number and the column number. | 1972 | line number and the column number. |
| 1973 | @end defvar | 1973 | @end defvar |
| 1974 | 1974 | ||
| 1975 | @defopt mode-line-percent-position | ||
| 1976 | This option is used in @code{mode-line-position}. Its value specifies | ||
| 1977 | both the buffer percentage to display (one of @code{nil}, @code{"%o"}, | ||
| 1978 | @code{"%p"}, @code{"%P"} or @code{"%q"}, @pxref{%-Constructs}) and a | ||
| 1979 | width to space-fill or truncate to. You are recommended to set this | ||
| 1980 | option with the @code{customize-variable} facility. | ||
| 1981 | @end defopt | ||
| 1982 | |||
| 1975 | @defvar vc-mode | 1983 | @defvar vc-mode |
| 1976 | The variable @code{vc-mode}, buffer-local in each buffer, records | 1984 | The variable @code{vc-mode}, buffer-local in each buffer, records |
| 1977 | whether the buffer's visited file is maintained with version control, | 1985 | whether the buffer's visited file is maintained with version control, |
| @@ -2147,6 +2155,12 @@ of the buffer. | |||
| 2147 | @samp{Narrow} when narrowing is in effect; nothing otherwise (see | 2155 | @samp{Narrow} when narrowing is in effect; nothing otherwise (see |
| 2148 | @code{narrow-to-region} in @ref{Narrowing}). | 2156 | @code{narrow-to-region} in @ref{Narrowing}). |
| 2149 | 2157 | ||
| 2158 | @item %o | ||
| 2159 | The degree of @dfn{travel} of the window through (the visible portion | ||
| 2160 | of) the buffer, i.e. the size of the text above the top of the window | ||
| 2161 | expressed as a percentage of all the text outside the window, or | ||
| 2162 | @samp{Top}, @samp{Bottom} or @samp{All}. | ||
| 2163 | |||
| 2150 | @item %p | 2164 | @item %p |
| 2151 | The percentage of the buffer text above the @strong{top} of window, or | 2165 | The percentage of the buffer text above the @strong{top} of window, or |
| 2152 | @samp{Top}, @samp{Bottom} or @samp{All}. Note that the default mode | 2166 | @samp{Top}, @samp{Bottom} or @samp{All}. Note that the default mode |
| @@ -2158,6 +2172,10 @@ the window (which includes the text visible in the window, as well as | |||
| 2158 | the text above the top), plus @samp{Top} if the top of the buffer is | 2172 | the text above the top), plus @samp{Top} if the top of the buffer is |
| 2159 | visible on screen; or @samp{Bottom} or @samp{All}. | 2173 | visible on screen; or @samp{Bottom} or @samp{All}. |
| 2160 | 2174 | ||
| 2175 | @item %q | ||
| 2176 | The percentages of text above both the @strong{top} and the | ||
| 2177 | @strong{bottom} of the window, separated by @samp{-}, or @samp{All}. | ||
| 2178 | |||
| 2161 | @item %s | 2179 | @item %s |
| 2162 | The status of the subprocess belonging to the current buffer, obtained with | 2180 | The status of the subprocess belonging to the current buffer, obtained with |
| 2163 | @code{process-status}. @xref{Process Information}. | 2181 | @code{process-status}. @xref{Process Information}. |
| @@ -379,6 +379,16 @@ displayed to be horizontally scrolled when lines are truncated on | |||
| 379 | display and point moves outside the left or right window margin. | 379 | display and point moves outside the left or right window margin. |
| 380 | 380 | ||
| 381 | +++ | 381 | +++ |
| 382 | ** New mode line constructs '%o' and '%q', and user option | ||
| 383 | 'mode-line-percent-position'. '%o' displays the "degree of travel" of | ||
| 384 | the window through the buffer. Unlike the default '%p', this | ||
| 385 | percentage approaches 100% as the window approaches the end of the | ||
| 386 | buffer. '%q' displays the percentage offsets of both the start and | ||
| 387 | the end of the window, e.g. "5-17%". The new option | ||
| 388 | 'mode-line-percent-position' makes it easier to switch between '%p', | ||
| 389 | '%P', and these new constructs. | ||
| 390 | |||
| 391 | +++ | ||
| 382 | ** Two new user options 'list-matching-lines-jump-to-current-line' and | 392 | ** Two new user options 'list-matching-lines-jump-to-current-line' and |
| 383 | 'list-matching-lines-current-line-face' to show highlighted the current | 393 | 'list-matching-lines-current-line-face' to show highlighted the current |
| 384 | line in *Occur* buffer. | 394 | line in *Occur* buffer. |
diff --git a/lisp/bindings.el b/lisp/bindings.el index 85a54087178..0b4c3bda80f 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -365,14 +365,32 @@ zero, otherwise they start from one." | |||
| 365 | :group 'mode-line | 365 | :group 'mode-line |
| 366 | :version "26.1") | 366 | :version "26.1") |
| 367 | 367 | ||
| 368 | (defcustom mode-line-percent-position '(-3 "%p") | ||
| 369 | "Specification of \"percentage offset\" of window through buffer | ||
| 370 | This option specifies both the field width and the type of offset | ||
| 371 | displayed in `mode-line-position', a component of the default | ||
| 372 | `mode-line-format'." | ||
| 373 | :type `(radio | ||
| 374 | (const :tag "nil: No offset is displayed" nil) | ||
| 375 | (const :tag "\"%o\": Proportion of \"travel\" of the window through the buffer" | ||
| 376 | (-3 "%o")) | ||
| 377 | (const :tag "\"%p\": Percentage offset of top of window" | ||
| 378 | (-3 "%p")) | ||
| 379 | (const :tag "\"%P\": Precentage offset of bottom of window" | ||
| 380 | (-3 "%P")) | ||
| 381 | (const :tag "\"%q\": Offsets of both top and bottom of window" | ||
| 382 | (6 "%q"))) | ||
| 383 | :version "26.1" | ||
| 384 | :group 'mode-line) | ||
| 385 | |||
| 368 | (defvar mode-line-position | 386 | (defvar mode-line-position |
| 369 | `((-3 ,(propertize | 387 | `((:propertize |
| 370 | "%p" | 388 | mode-line-percent-position |
| 371 | 'local-map mode-line-column-line-number-mode-map | 389 | 'local-map mode-line-column-line-number-mode-map |
| 372 | 'mouse-face 'mode-line-highlight | 390 | 'mouse-face 'mode-line-highlight |
| 373 | ;; XXX needs better description | 391 | ;; XXX needs better description |
| 374 | 'help-echo "Size indication mode\n\ | 392 | 'help-echo "Size indication mode\n\ |
| 375 | mouse-1: Display Line and Column Mode Menu")) | 393 | mouse-1: Display Line and Column Mode Menu") |
| 376 | (size-indication-mode | 394 | (size-indication-mode |
| 377 | (8 ,(propertize | 395 | (8 ,(propertize |
| 378 | " of %I" | 396 | " of %I" |
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 ()); |