From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: Re: Absolutely =?utf-8?q?na=C3=AFve_question_about_line_numbering?= =?utf-8?q?_and_lisp_code?= Date: Tue, 03 Mar 2009 09:16:59 -0600 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1236094902 2113 80.91.229.12 (3 Mar 2009 15:41:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 Mar 2009 15:41:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 03 16:42:59 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 1LeWli-0003C0-Tw for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Mar 2009 16:42:55 +0100 Original-Received: from localhost ([127.0.0.1]:33394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LeWkN-0000A6-Qz for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Mar 2009 10:41:31 -0500 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.posted.cpinternet!news.posted.cpinternet.POSTED!not-for-mail Original-NNTP-Posting-Date: Tue, 03 Mar 2009 09:16:50 -0600 User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) Original-Newsgroups: gnu.emacs.help In-Reply-To: Original-Lines: 42 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 64.61.220.234 Original-X-Trace: sv3-GwtISfBa4XRJUxDoquK302ztFUG4womj6tFJFlNrC4fCtnfkZaJOlV2+WiwmJyxTPI/iRLDm7oQp++v!fRSQIuawaSXxbcV9B1C6gsa//ZmHw1W2/LDC6UL/Khkrr5vsU71a/TvSa+pol3aNlBsXVg29H48S!tSrna5fPBL39q/yP1qk= Original-X-Complaints-To: abuse@cpinternet.com X-DMCA-Complaints-To: abuse@cpinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.39 Original-Xref: news.stanford.edu gnu.emacs.help:167254 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:62552 Archived-At: Armando Martins wrote: > Hello! > > I am trying to numer the lines of a text (not the buffer, although > this solution could work around). I google and I find files in lisp > code, say: num.el, setnu.el, line.el... > How can I make it work on a text file I have. Do I download (wherever) > and open it and click "evaluate lisp" and then it will work for all > the session? > I am using Windows Vista. > Thanks for your help > Yes. Just copy that file (say, setnu.el) into say, site-lisp directory and then M-x load-library setnu. Now M-x setnu-mode should toggle line numbers on and off. If you just want to add line numbers permanently you could run this, of unknown provenance: (defun insert-line-numbers () "Insert a line number on all lines of the current buffer." (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))))) );;insert-line-numbers Of course if you add or delete a line then you would have to delete the rectangle in the the line number "region" and re-run M-x insert-line-numbers. Not very flexible. Ed