[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: is it easy to make line numbering start at 0 too?
From: |
John Paul Wallington |
Subject: |
Re: is it easy to make line numbering start at 0 too? |
Date: |
Thu, 09 Jan 2003 12:02:05 +0000 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (powerpc-apple-darwin5.5) |
seberino@spawar.navy.mil (Christian Seberino) wrote:
> is it easy to make line numbering start at 0 too?
If you mean in the modeline, the best bet is probably to hack the
decode_mode_spec in xdisp.c:
[caveats: I don't grok C, and the doc-string format is different for
released versions of Emacs.]
Index: xdisp.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xdisp.c,v
retrieving revision 1.798
diff -u -r1.798 xdisp.c
--- xdisp.c 6 Jan 2003 00:58:45 -0000 1.798
+++ xdisp.c 9 Jan 2003 11:31:41 -0000
@@ -464,6 +464,14 @@
int cursor_type_changed;
+/* Nonzero means column number display starts at one */
+
+int column_number_start_at_one;
+
+/* Nonzero means line number display starts at one */
+
+int line_number_start_at_one;
+
/* Nonzero after display_mode_line if %l was used and it displayed a
line number. */
@@ -14625,6 +14633,8 @@
{
int col = (int) current_column (); /* iftc */
w->column_number_displayed = make_number (col);
+ if (column_number_start_at_one)
+ ++col;
pint2str (decode_mode_spec_buf, field_width, col);
return decode_mode_spec_buf;
}
@@ -14732,6 +14742,8 @@
/* Now count lines from the start pos to point. */
nlines = display_count_lines (startpos, startpos_byte,
PT_BYTE, PT, &junk);
+ if (!line_number_start_at_one)
+ --nlines;
/* Record that we did display the line number. */
line_number_displayed = 1;
@@ -15663,6 +15675,14 @@
Any other value means to use the appropriate face, `mode-line',
`header-line', or `menu' respectively. */);
mode_line_inverse_video = 1;
+
+ DEFVAR_BOOL ("column-number-start-at-one", &column_number_start_at_one,
+ doc: /* *Non-nil means column number display starts at one. */);
+ column_number_start_at_one = 0;
+
+ DEFVAR_BOOL ("line-number-start-at-one", &line_number_start_at_one,
+ doc: /* *Non-nil means line number display starts at one. */);
+ line_number_start_at_one = 1;
DEFVAR_LISP ("line-number-display-limit", &Vline_number_display_limit,
doc: /* *Maximum buffer size for which line number should be displayed.
--
John Paul Wallington