* Possible to get line numbers?
@ 2005-03-29 21:47 JS
2005-03-29 22:25 ` Pascal Bourguignon
2005-03-29 23:23 ` Joe Corneli
0 siblings, 2 replies; 9+ messages in thread
From: JS @ 2005-03-29 21:47 UTC (permalink / raw)
Is it possible to get line numbers in the left margin of emacs??
JS
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Possible to get line numbers?
2005-03-29 21:47 JS
@ 2005-03-29 22:25 ` Pascal Bourguignon
2005-03-29 22:44 ` Drew Adams
2005-03-29 23:23 ` Joe Corneli
1 sibling, 1 reply; 9+ messages in thread
From: Pascal Bourguignon @ 2005-03-29 22:25 UTC (permalink / raw)
JS <d44sf@44ada.com> writes:
> Is it possible to get line numbers in the left margin of emacs??
ISTR that a mode passed on gnu.emacs.sources to do that. Otherwise,
there's the line-number-mode and column-number-mode that display the
line and column number in the mode line. The point is that it's
rather costly to maintain line numbers while editing a buffer: you
have to renumber all lines every time something's cut, pasted or C-o
or RETURN is typed, etc.
You could use this M-x insert-line-numbers command to insert line
numbers, M-x delete-line-numbers to remove them, M-x renumber-lines to
update them.
And M-x local-set-key RET RET lse-newline RET to get new line numbers
inserted automatically when you type return (actually, not _line_
numbers, but a statement number like in LSE or BASIC where you may
number lines 5 b 5 or 10 by 10.
I don't know if there's a way to maintain an area on the screen
distinct from the buffer contents, but scroll-synchronized with the
buffer, like the "fringe", were we could put the line numbers; it
doesn't seems so...
(defun insert-line-numbers ()
(interactive)
(save-excursion
(save-restriction
(widen)
(let ((fmt (format "%%0%dd "
(1+ (truncate
(log (count-lines (point-min) (point-max))
10)))))
(i 0))
(goto-char (point-min))
(while (< (point) (point-max))
(setq i (1+ i))
(insert (format fmt i))
(forward-line))))))
(defun delete-line-numbers ()
(interactive)
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(while (< (point) (point-max))
(if (looking-at "[0-9][0-9]* ")
(delete-region (match-beginning 0) (match-end 0)))
(forward-line)))))
(defun renumber-lines ()
(interactive)
(delete-line-numbers)
(insert-line-numbers))
(defun lse-newline ()
"Insert newline and line number incremented with the same step
as previously."
(interactive)
(newline)
(let ((nlpt (point))
(line (progn
(forward-line -1)
(beginning-of-line)
(if (looking-at "[0-9]+")
(let ((curr (string-to-number (match-string 0))))
(forward-line -1)
(beginning-of-line)
(if (looking-at "[0-9]+")
(let ((prev (string-to-number (match-string 0))))
(+ curr (abs (- curr prev))))
(+ 10 curr)))
10))))
(goto-char nlpt)
(beginning-of-line)
(insert (format "%d " line))
(when (looking-at " +")
(delete-region (match-beginning 0) (match-end 0)))));;lse-newline
--
__Pascal Bourguignon__ http://www.informatimago.com/
Nobody can fix the economy. Nobody can be trusted with their finger
on the button. Nobody's perfect. VOTE FOR NOBODY.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Possible to get line numbers?
2005-03-29 22:25 ` Pascal Bourguignon
@ 2005-03-29 22:44 ` Drew Adams
0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2005-03-29 22:44 UTC (permalink / raw)
> Is it possible to get line numbers in the left margin of emacs??
http://www.emacswiki.org/cgi-bin/wiki/LineNumbers
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Possible to get line numbers?
2005-03-29 21:47 JS
2005-03-29 22:25 ` Pascal Bourguignon
@ 2005-03-29 23:23 ` Joe Corneli
1 sibling, 0 replies; 9+ messages in thread
From: Joe Corneli @ 2005-03-29 23:23 UTC (permalink / raw)
Look in the list archives (someone just asked last week about the same
thing).
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Possible to get line numbers?
[not found] <mailman.580.1112137662.28103.help-gnu-emacs@gnu.org>
@ 2005-03-29 23:52 ` JS
2005-03-30 7:26 ` Mathias Dahl
0 siblings, 1 reply; 9+ messages in thread
From: JS @ 2005-03-29 23:52 UTC (permalink / raw)
"Drew Adams" <drew.adams@oracle.com> skrev i en meddelelse
news:mailman.580.1112137662.28103.help-gnu-emacs@gnu.org...
> > Is it possible to get line numbers in the left margin of emacs??
>
> http://www.emacswiki.org/cgi-bin/wiki/LineNumbers
>
>
Ok I downloaded:
setnu.el
But what am I supposed to do with it? I am just starting to use emacs.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Possible to get line numbers?
2005-03-29 23:52 ` JS
@ 2005-03-30 7:26 ` Mathias Dahl
2005-03-30 9:50 ` JS
0 siblings, 1 reply; 9+ messages in thread
From: Mathias Dahl @ 2005-03-30 7:26 UTC (permalink / raw)
"JS" <dsa.@asdf.com> writes:
> "Drew Adams" <drew.adams@oracle.com> skrev i en meddelelse
> news:mailman.580.1112137662.28103.help-gnu-emacs@gnu.org...
>> > Is it possible to get line numbers in the left margin of emacs??
>>
>> http://www.emacswiki.org/cgi-bin/wiki/LineNumbers
>>
>>
>
> Ok I downloaded:
>
> setnu.el
>
> But what am I supposed to do with it? I am just starting to use emacs.
Put the file in your somewhere in your load-path (to see which
directories are in the load-path, do C-h v load-path RET), then add
the following to your .emacs file:
(require 'setnu)
Now, when you want line numbers do M-x setnu-mode RET
/Mathias
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Possible to get line numbers?
2005-03-30 7:26 ` Mathias Dahl
@ 2005-03-30 9:50 ` JS
2005-03-30 11:38 ` Mathias Dahl
0 siblings, 1 reply; 9+ messages in thread
From: JS @ 2005-03-30 9:50 UTC (permalink / raw)
Mathias Dahl wrote:
> "JS" <dsa.@asdf.com> writes:
>
>> "Drew Adams" <drew.adams@oracle.com> skrev i en meddelelse
>> news:mailman.580.1112137662.28103.help-gnu-emacs@gnu.org...
>>> > Is it possible to get line numbers in the left margin of emacs??
>>>
>>> http://www.emacswiki.org/cgi-bin/wiki/LineNumbers
>>>
>>>
>>
>> Ok I downloaded:
>>
>> setnu.el
>>
>> But what am I supposed to do with it? I am just starting to use emacs.
>
> Put the file in your somewhere in your load-path (to see which
> directories are in the load-path, do C-h v load-path RET),
When I do that I get a list of maybe 15 diretories! Should I just put in one
of them?
> then add
> the following to your .emacs file:
>
> (require 'setnu)
>
> Now, when you want line numbers do M-x setnu-mode RET
I could be nice that the linenumbers are visible each time I start emacs, is
that possible?
JS
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Possible to get line numbers?
2005-03-30 9:50 ` JS
@ 2005-03-30 11:38 ` Mathias Dahl
0 siblings, 0 replies; 9+ messages in thread
From: Mathias Dahl @ 2005-03-30 11:38 UTC (permalink / raw)
JS <d44sf@44ada.com> writes:
>>> But what am I supposed to do with it? I am just starting to use emacs.
>>
>> Put the file in your somewhere in your load-path (to see which
>> directories are in the load-path, do C-h v load-path RET),
>
>
> When I do that I get a list of maybe 15 diretories! Should I just put in one
> of them?
Yes, basically, any will do.
>> then add
>> the following to your .emacs file:
>>
>> (require 'setnu)
>>
>> Now, when you want line numbers do M-x setnu-mode RET
>
> I could be nice that the linenumbers are visible each time I start emacs, is
> that possible?
Not with this mode because it has to be enabled in each buffer, when
you need it. I suggest you bind it to some key:
(global-set-key "\C-cl" 'setnu-mode)
And then you only need to press C-c l to toggle this mode.
/Mathias
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Possible to get line numbers?
@ 2005-03-30 19:03 Ryan Bowman
0 siblings, 0 replies; 9+ messages in thread
From: Ryan Bowman @ 2005-03-30 19:03 UTC (permalink / raw)
> > I could be nice that the linenumbers are visible
> each time I start emacs, is that possible?
>
> Not with this mode because it has to be enabled in
> each buffer, when you need it. I suggest you bind it
to some key:
>
> (global-set-key "\C-cl" 'setnu-mode)
>
Or you can add to to a hook for whichever modes you
want it enabled, i.e. placing in your .emacs file
(add-hook 'java-mode-hook
'(lambda ()
(setnu-mode t))
will turn on line numbers for any buffer that uses java-mode.
----
Ryan Bowman
That stupid bird stole my quarter. I hate birds. - Eddie
----
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-03-30 19:03 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-30 19:03 Possible to get line numbers? Ryan Bowman
[not found] <mailman.580.1112137662.28103.help-gnu-emacs@gnu.org>
2005-03-29 23:52 ` JS
2005-03-30 7:26 ` Mathias Dahl
2005-03-30 9:50 ` JS
2005-03-30 11:38 ` Mathias Dahl
-- strict thread matches above, loose matches on Subject: below --
2005-03-29 21:47 JS
2005-03-29 22:25 ` Pascal Bourguignon
2005-03-29 22:44 ` Drew Adams
2005-03-29 23:23 ` Joe Corneli
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).