From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: how to have line numbers start at 0? Date: Thu, 27 Aug 2009 05:14:20 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2d85bb02-fc70-4410-a09f-e05057f2d18a@v23g2000pro.googlegroups.com> References: <3c63743b-f8d2-416f-a254-c1e2a02f49e3@p36g2000prn.googlegroups.com> <87ws4p4my4.fsf@iki.fi> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1251431762 2268 80.91.229.12 (28 Aug 2009 03:56:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Aug 2009 03:56:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 28 05:55:55 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MgsZ9-0002kM-1w for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Aug 2009 05:55:55 +0200 Original-Received: from localhost ([127.0.0.1]:59301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgsZ8-0007kj-I0 for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Aug 2009 23:55:54 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!v23g2000pro.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 27 Original-NNTP-Posting-Host: 76.102.12.87 Original-X-Trace: posting.google.com 1251375261 3603 127.0.0.1 (27 Aug 2009 12:14:21 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 27 Aug 2009 12:14:21 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v23g2000pro.googlegroups.com; posting-host=76.102.12.87; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.39 Safari/530.5, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:172447 X-Mailman-Approved-At: Thu, 27 Aug 2009 23:54:34 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:67599 Archived-At: On Aug 27, 2:37=A0am, Teemu Likonen wrote: > On 2009-08-27 02:25 (-0700), Xah Lee wrote: > > > with emacs 23, is it possible to have line numbers on the margin start > > at 0? > > Do you mean like this: > > =A0 =A0 (setq linum-format #'(lambda (number) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(format "%3d" (1- = number)))) > > Or with dynamic width: > > =A0 =A0 (setq linum-format #'my-linum-format) > > =A0 =A0 (defun my-linum-format (number) > =A0 =A0 =A0 (format > =A0 =A0 =A0 =A0(let ((w (length (number-to-string > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(count-lines (point-mi= n) (point-max)))))) > =A0 =A0 =A0 =A0 =A0(concat "%" (number-to-string w) "d")) > =A0 =A0 =A0 =A0(1- number))) Thanks. :) Xah