5

The first line of a text file is line number 1 in probably every application I have ever come across, including Emacs.

Every application I have at hand also uses column number 1 for the first column of each line. Except for Emacs, which says it is column number 0.

My questions:

  • Is column number 1 the near-universal convention (as it would seem)?
  • What is the history/rationale for Emacs using column number 0 by default? (It's used both in the return value of current-column and on the mode line when column-number-mode is enabled.) Is this a historical convention on some old operating system or community, or did it debut in Emacs?

I just found out that Emacs 26.1 introduced a new customizable variable column-number-indicator-zero-based to control this. From the release notes:

Traditionally, in Column Number mode, the displayed column number counts from zero starting at the left margin of the window. This behavior is now controlled by 'column-number-indicator-zero-based'. If you would prefer for the displayed column number to count from one, you may set this variable to nil. (Behind the scenes, there is now a new mode line construct, '%C', which operates exactly as '%c' does except that it counts from one.)

This is neat, but still doesn't shed light on the history or rationale.

2
  • 2
    It may behoove you to submit a link on reddit/Emacs reddit.com/r/emacs to this particular thread as it will attract one or more of the lead developers on the Emacs development team. Only a few of the core developers read (or at least actively participate) emacs.stackexchange.com.
    – lawlist
    Commented Mar 27, 2019 at 1:06
  • 1
    Since arrays are zero-based in many languages, most(?) lisp dialects included, counting columns from zero may just have seemed the natural choice at the time. But not entirely consistent, since lines are counted starting at 1. My guess, though, is that only Richard Stallman can give an authoritative answer to this question. (Amusing aside: JavaScript counts months starting at zero. This catches many a JavaScript newbie unawares.) Commented Mar 27, 2019 at 8:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.