aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPerry E. Metzger2017-05-10 20:57:21 +0300
committerEli Zaretskii2017-05-10 20:57:21 +0300
commit7df0777945efbab390cad0e87b92dd92e0d1853f (patch)
tree419c316a5f793159b1c78bd7f7923af75161fbf8 /src
parente124e07faede2f2d4c6f16af84d796f6305cb8d9 (diff)
downloademacs-7df0777945efbab390cad0e87b92dd92e0d1853f.tar.gz
emacs-7df0777945efbab390cad0e87b92dd92e0d1853f.zip
Implement 1-based column numbering in mode line
* src/xdisp.c (decode_mode_spec): Implement the %C construct. * lisp/bindings.el (column-number-indicator-zero-based): New defcustom. (mode-line-position): Use %C when column-number-indicator-zero-based is nil. * src/xdisp.c (syms_of_xdisp) <frame-title-format>: * src/buffer.c (syms_of_buffer) <mode-line-format>: * doc/lispref/modes.texi (%-Constructs): * doc/lispref/frames.texi (Frame Titles): Document the %C construct. * doc/emacs/display.texi (Optional Mode Line): Document 'column-number-indicator-zero-based'. * etc/NEWS: Mention 'column-number-indicator-zero-based' and the %C construct.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c3
-rw-r--r--src/xdisp.c14
2 files changed, 11 insertions, 6 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 33ffdf8eb8e..80dbd3318dc 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5486,8 +5486,11 @@ A string is printed verbatim in the mode line except for %-constructs:
5486 For a modified read-only buffer, %* gives % and %+ gives *. 5486 For a modified read-only buffer, %* gives % and %+ gives *.
5487 %s -- print process status. %l -- print the current line number. 5487 %s -- print process status. %l -- print the current line number.
5488 %c -- print the current column number (this makes editing slower). 5488 %c -- print the current column number (this makes editing slower).
5489 Columns are numbered starting from the left margin, and the
5490 leftmost column is displayed as zero.
5489 To make the column number update correctly in all cases, 5491 To make the column number update correctly in all cases,
5490 `column-number-mode' must be non-nil. 5492 `column-number-mode' must be non-nil.
5493 %C -- Like %c, but the leftmost column is displayed as one.
5491 %i -- print the size of the buffer. 5494 %i -- print the size of the buffer.
5492 %I -- like %i, but use k, M, G, etc., to abbreviate. 5495 %I -- like %i, but use k, M, G, etc., to abbreviate.
5493 %p -- print percent of buffer above top of window, or Top, Bot or All. 5496 %p -- print percent of buffer above top of window, or Top, Bot or All.
diff --git a/src/xdisp.c b/src/xdisp.c
index c730cdae054..cdea20993c7 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -476,7 +476,7 @@ int windows_or_buffers_changed;
476 used to track down the cause for this full-redisplay). 476 used to track down the cause for this full-redisplay).
477 477
478 Since the frame title uses the same %-constructs as the mode line 478 Since the frame title uses the same %-constructs as the mode line
479 (except %c and %l), if this variable is non-zero, we also consider 479 (except %c, %C, and %l), if this variable is non-zero, we also consider
480 redisplaying the title of each frame, see x_consider_frame_title. 480 redisplaying the title of each frame, see x_consider_frame_title.
481 481
482 The `redisplay' bits are the same as those used for 482 The `redisplay' bits are the same as those used for
@@ -11530,7 +11530,7 @@ window_buffer_changed (struct window *w)
11530 return (BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) != w->last_had_star; 11530 return (BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) != w->last_had_star;
11531} 11531}
11532 11532
11533/* True if W has %c in its mode line and mode line should be updated. */ 11533/* True if W has %c or %C in its mode line and mode line should be updated. */
11534 11534
11535static bool 11535static bool
11536mode_line_update_needed (struct window *w) 11536mode_line_update_needed (struct window *w)
@@ -23690,7 +23690,8 @@ decode_mode_spec (struct window *w, register int c, int field_width,
23690 break; 23690 break;
23691 23691
23692 case 'c': 23692 case 'c':
23693 /* %c and %l are ignored in `frame-title-format'. 23693 case 'C':
23694 /* %c, %C, and %l are ignored in `frame-title-format'.
23694 (In redisplay_internal, the frame title is drawn _before_ the 23695 (In redisplay_internal, the frame title is drawn _before_ the
23695 windows are updated, so the stuff which depends on actual 23696 windows are updated, so the stuff which depends on actual
23696 window contents (such as %l) may fail to render properly, or 23697 window contents (such as %l) may fail to render properly, or
@@ -23700,8 +23701,9 @@ decode_mode_spec (struct window *w, register int c, int field_width,
23700 else 23701 else
23701 { 23702 {
23702 ptrdiff_t col = current_column (); 23703 ptrdiff_t col = current_column ();
23704 int disp_col = (c == 'C') ? col + 1 : col;
23703 w->column_number_displayed = col; 23705 w->column_number_displayed = col;
23704 pint2str (decode_mode_spec_buf, width, col); 23706 pint2str (decode_mode_spec_buf, width, disp_col);
23705 return decode_mode_spec_buf; 23707 return decode_mode_spec_buf;
23706 } 23708 }
23707 23709
@@ -23749,7 +23751,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
23749 ptrdiff_t topline, nlines, height; 23751 ptrdiff_t topline, nlines, height;
23750 ptrdiff_t junk; 23752 ptrdiff_t junk;
23751 23753
23752 /* %c and %l are ignored in `frame-title-format'. */ 23754 /* %c, %C, and %l are ignored in `frame-title-format'. */
23753 if (mode_line_target == MODE_LINE_TITLE) 23755 if (mode_line_target == MODE_LINE_TITLE)
23754 return ""; 23756 return "";
23755 23757
@@ -31725,7 +31727,7 @@ This variable is not guaranteed to be accurate except while processing
31725\(Assuming the window manager supports this feature.) 31727\(Assuming the window manager supports this feature.)
31726 31728
31727This variable has the same structure as `mode-line-format', except that 31729This variable has the same structure as `mode-line-format', except that
31728the %c and %l constructs are ignored. It is used only on frames for 31730the %c, %C, and %l constructs are ignored. It is used only on frames for
31729which no explicit name has been set (see `modify-frame-parameters'). */); 31731which no explicit name has been set (see `modify-frame-parameters'). */);
31730 31732
31731 DEFVAR_LISP ("icon-title-format", Vicon_title_format, 31733 DEFVAR_LISP ("icon-title-format", Vicon_title_format,