* is it easy to make line numbering start at 0 too? @ 2003-01-08 1:57 Christian Seberino 2003-01-09 12:02 ` John Paul Wallington ` (3 more replies) 0 siblings, 4 replies; 6+ messages in thread From: Christian Seberino @ 2003-01-08 1:57 UTC (permalink / raw) is it easy to make line numbering start at 0 too? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: is it easy to make line numbering start at 0 too? 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 [not found] ` <20030109131745.A31056@spawar.navy.mil> 2003-01-10 23:19 ` Rikard Bosnjakovic ` (2 subsequent siblings) 3 siblings, 1 reply; 6+ messages in thread From: John Paul Wallington @ 2003-01-09 12:02 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20030109131745.A31056@spawar.navy.mil>]
* Re: is it easy to make line numbering start at 0 too? [not found] ` <20030109131745.A31056@spawar.navy.mil> @ 2003-01-12 16:53 ` John Paul Wallington 0 siblings, 0 replies; 6+ messages in thread From: John Paul Wallington @ 2003-01-12 16:53 UTC (permalink / raw) seberino@spawar.navy.mil wrote: > Thanks for the reply! This is a very cool way to do > the modeline modification.... I originally made column numbering > on modeline start at 1 this way.... [...] > (setq default-mode-line-format [...] > '(:eval (format "%d" (1+ (current-column)))))) > (add-hook 'post-command-hook (lambda () (force-mode-line-update))) > This has side effects... it messed up scroll-step behavior... this is > why I need a new way. > A problem with hacking Emacs source code is that I can't > make these changes happen on remote machines that I don't have root > privileges on. > > Plus, it sounds like new Emacs versions may not be compatible > with changes. Hacking decode_mode_spec in xdisp.c as mentioned earlier is much more straightforward than trying to replicate the same effect in emacs lisp. XEmacs has a `column-number-start-at-one' builtin and heeds it. If there is a genuine demand for the functionality you should propose it to the Emacs maintainers; as demonstrated it is a simple addition. It is controversial because presently the column and line number displays on the modeline reflect `point' which is on a line and between characters. The question arises as to why a user wants Emacs to tell fibs about column/line numbers; what is wrong with column numbers starting at zero, and line numbers at one? -- John Paul Wallington ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: is it easy to make line numbering start at 0 too? 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 @ 2003-01-10 23:19 ` Rikard Bosnjakovic 2003-01-10 23:50 ` Benjamin Lewis 2003-01-11 0:10 ` Henrik Enberg 3 siblings, 0 replies; 6+ messages in thread From: Rikard Bosnjakovic @ 2003-01-10 23:19 UTC (permalink / raw) > is it easy to make line numbering start at 0 too? ? -- Friendly, Rikard ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: is it easy to make line numbering start at 0 too? 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 2003-01-10 23:19 ` Rikard Bosnjakovic @ 2003-01-10 23:50 ` Benjamin Lewis 2003-01-11 0:10 ` Henrik Enberg 3 siblings, 0 replies; 6+ messages in thread From: Benjamin Lewis @ 2003-01-10 23:50 UTC (permalink / raw) Christian Seberino wrote: > is it easy to make line numbering start at 0 too? Not sure exactly what your asking, but keep in mind that column-numbering and line-numbering have a fundamental difference: when the cursor is on the top-left position in the buffer, point is *on* the first line but *before* the first character. Think of point as a line that has zero width, but the height of a line of text. -- Benjamin Lewis Don't take life so serious, son, it ain't nohow permanent. -- Walt Kelly ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: is it easy to make line numbering start at 0 too? 2003-01-08 1:57 is it easy to make line numbering start at 0 too? Christian Seberino ` (2 preceding siblings ...) 2003-01-10 23:50 ` Benjamin Lewis @ 2003-01-11 0:10 ` Henrik Enberg 3 siblings, 0 replies; 6+ messages in thread From: Henrik Enberg @ 2003-01-11 0:10 UTC (permalink / raw) seberino@spawar.navy.mil (Christian Seberino) writes: > is it easy to make line numbering start at 0 too? No. It is hardcoded on the C level. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-01-12 16:53 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 [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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).