[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3beb8bc 3/3: Allow controlling the look of the line/column indica
From: |
Lars Ingebrigtsen |
Subject: |
master 3beb8bc 3/3: Allow controlling the look of the line/column indicators |
Date: |
Tue, 15 Sep 2020 11:16:25 -0400 (EDT) |
branch: master
commit 3beb8bc9940b1de7ecee3d58b32c888898bb3ee0
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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.
---
doc/lispref/modes.texi | 16 ++++++++++++++++
etc/NEWS | 8 ++++++++
lisp/bindings.el | 34 +++++++++++++++++++++++++++++-----
lisp/simple.el | 10 ++++++++--
4 files changed, 61 insertions(+), 7 deletions(-)
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index fa5f18e..6180cb2 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index c9221a2..90273dd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -999,6 +999,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
towards sending a patch to the Emacs issue tracker.
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 20342bc..bc9cccd 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -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\
diff --git a/lisp/simple.el b/lisp/simple.el
index 6ef327b..7dc6958 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -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