1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-03 02:31:03 -08:00

Allow controlling the look of the line/column indicators

* doc/lispref/modes.texi (Mode Line Variables): Document them.

* lisp/bindings.el (mode-line-position-line-format): New variable
(bug#28648).
(mode-line-position-column-format): Ditto.
(mode-line-position): Use them.

* lisp/simple.el (column-number-mode): Mention them.
(line-number-mode): Ditto.
This commit is contained in:
Lars Ingebrigtsen 2020-09-15 17:07:31 +02:00
parent caf64ae08b
commit 3beb8bc994
4 changed files with 61 additions and 7 deletions

View file

@ -2166,6 +2166,22 @@ Mode line construct for miscellaneous information. By default, this
shows the information specified by @code{global-mode-string}.
@end defvar
@defvar mode-line-position-line-format
The format used for display line numbers when @code{line-number-mode}
(@pxref{Optional Mode Line,,, emacs, The GNU Emacs Manual}) is
switched on. @samp{%l} in the format will be replaced with the line
number.
@end defvar
@defvar mode-line-position-column-format
The format used for display column numbers when
@code{column-number-mode} (@pxref{Optional Mode Line,,, emacs, The GNU
Emacs Manual}) is switched on. @samp{%c} in the format will be
replaced with the line number, and this is zero-based if
@code{column-number-indicator-zero-based} is non-@code{nil}, and
one-based if @code{column-number-indicator-zero-based} is @code{nil}.
@end defvar
@defvar minor-mode-alist
@anchor{Definition of minor-mode-alist}
This variable holds an association list whose elements specify how the

View file

@ -998,6 +998,14 @@ window after starting). This variable defaults to nil.
** Miscellaneous
+++
*** New variables to control the look of line/column numbers in the mode line.
'mode-line-position-line-format' is the line number format (when
'line-number-mode') is on, and 'mode-line-position-column-format' is
the column number format (when 'column-number-mode') is on. These are
also used if both modes are on, which leads to the default in that
case going from "(5,9)" to "(L5,C9)".
+++
*** New command 'submit-emacs-patch'.
This works along the lines of 'report-emacs-bug', but is more geared

View file

@ -431,6 +431,24 @@ displayed in `mode-line-position', a component of the default
:group 'mode-line)
(put 'mode-line-percent-position 'risky-local-variable t)
(defcustom mode-line-position-line-format "L%l"
"Format used to display line numbers in the mode line.
This is used when `line-number-mode' is switched on. The \"%l\"
format spec will be replaced by the line number."
:type 'string
:version "28.1"
:group 'mode-line)
(defcustom mode-line-position-column-format "C%c"
"Format used to display column numbers in the mode line.
This is used when `column-number-mode' is switched on. The
\"%c\" format spec will be replaced by the column number, which
is zero-based if `column-number-indicator-zero-based' is non-nil,
and one-based if `column-number-indicator-zero-based' is nil."
:type 'string
:version "28.1"
:group 'mode-line)
(defvar mode-line-position
`((:propertize
mode-line-percent-position
@ -451,19 +469,24 @@ mouse-1: Display Line and Column Mode Menu")))
((column-number-mode
(column-number-indicator-zero-based
(10 ,(propertize
" (%l,%c)"
(format " (%s,%s)"
mode-line-position-line-format
mode-line-position-column-format)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line number and Column number\n\
mouse-1: Display Line and Column Mode Menu"))
(10 ,(propertize
" (%l,%C)"
(format " (%s,%s)"
mode-line-position-line-format
(replace-in-string "%c" "%C"
mode-line-position-column-format))
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line number and Column number\n\
mouse-1: Display Line and Column Mode Menu")))
(6 ,(propertize
" L%l"
(format " %s" mode-line-position-line-format)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line Number\n\
@ -471,13 +494,14 @@ mouse-1: Display Line and Column Mode Menu"))))
((column-number-mode
(column-number-indicator-zero-based
(5 ,(propertize
" C%c"
(format " %s" mode-line-position-column-format)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Column number\n\
mouse-1: Display Line and Column Mode Menu"))
(5 ,(propertize
" C%C"
(format " %s" (replace-in-string "%c" "%C"
mode-line-position-column-format))
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Column number\n\

View file

@ -7805,11 +7805,17 @@ a specialization of overwrite mode, entered by setting the
Line numbers do not appear for very large buffers and buffers
with very long lines; see variables `line-number-display-limit'
and `line-number-display-limit-width'."
and `line-number-display-limit-width'.
See `mode-line-position-line-format' for how this number is
presented."
:init-value t :global t :group 'mode-line)
(define-minor-mode column-number-mode
"Toggle column number display in the mode line (Column Number mode)."
"Toggle column number display in the mode line (Column Number mode).
See `mode-line-position-column-format' for how this number is
presented."
:global t :group 'mode-line)
(define-minor-mode size-indication-mode