all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: jpw@shootybangbang.com (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	[thread overview]
Message-ID: <m2u1gir0oy.fsf@coco.shootybangbang.com> (raw)
In-Reply-To: bf23f78f.0301071757.47a089d9@posting.google.com

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

  reply	other threads:[~2003-01-09 12:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-08  1:57 is it easy to make line numbering start at 0 too? Christian Seberino
2003-01-09 12:02 ` John Paul Wallington [this message]
     [not found]   ` <20030109131745.A31056@spawar.navy.mil>
2003-01-12 16:53     ` John Paul Wallington
2003-01-10 23:19 ` Rikard Bosnjakovic
2003-01-10 23:50 ` Benjamin Lewis
2003-01-11  0:10 ` Henrik Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2u1gir0oy.fsf@coco.shootybangbang.com \
    --to=jpw@shootybangbang.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.