* how to have line numbers start at 0?
@ 2009-08-27 9:25 Xah Lee
2009-08-27 9:37 ` Teemu Likonen
0 siblings, 1 reply; 3+ messages in thread
From: Xah Lee @ 2009-08-27 9:25 UTC (permalink / raw)
To: help-gnu-emacs
with emacs 23, is it possible to have line numbers on the margin start
at 0?
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: how to have line numbers start at 0?
2009-08-27 9:25 how to have line numbers start at 0? Xah Lee
@ 2009-08-27 9:37 ` Teemu Likonen
2009-08-27 12:14 ` Xah Lee
0 siblings, 1 reply; 3+ messages in thread
From: Teemu Likonen @ 2009-08-27 9:37 UTC (permalink / raw)
To: help-gnu-emacs
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:
(setq linum-format #'(lambda (number)
(format "%3d" (1- number))))
Or with dynamic width:
(setq linum-format #'my-linum-format)
(defun my-linum-format (number)
(format
(let ((w (length (number-to-string
(count-lines (point-min) (point-max))))))
(concat "%" (number-to-string w) "d"))
(1- number)))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: how to have line numbers start at 0?
2009-08-27 9:37 ` Teemu Likonen
@ 2009-08-27 12:14 ` Xah Lee
0 siblings, 0 replies; 3+ messages in thread
From: Xah Lee @ 2009-08-27 12:14 UTC (permalink / raw)
To: help-gnu-emacs
On Aug 27, 2:37 am, Teemu Likonen <tliko...@iki.fi> 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:
>
> (setq linum-format #'(lambda (number)
> (format "%3d" (1- number))))
>
> Or with dynamic width:
>
> (setq linum-format #'my-linum-format)
>
> (defun my-linum-format (number)
> (format
> (let ((w (length (number-to-string
> (count-lines (point-min) (point-max))))))
> (concat "%" (number-to-string w) "d"))
> (1- number)))
Thanks. :)
Xah
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-27 12:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-27 9:25 how to have line numbers start at 0? Xah Lee
2009-08-27 9:37 ` Teemu Likonen
2009-08-27 12:14 ` Xah Lee
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).