🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #188791

Line numbers in emacs?

#188791
From: Neil Mager
Date: Tue, 09 Jul 1991 15:10
45 lines
1835 bytes
Scott Barvian writes:
 > Is there a c-mode for emacs that will show line numbers (either along
 > side the file itself, or on the status line)?  I am too lazy to type
 > M-x what-line all the time.  There oughta be an easier way.


Put the following in your .emacs file. It redefines the function
line-move to put the present line number in the status line. 
One limitation is the line number only gets modified when the
function next-line (or previous-line) is called. It does not
change for C-v or esc-v.




(defun set-line ()
  (interactive)
  (setq mode-line-process
        (format " %4d" (1+ (count-lines 1 (point))))))

;;; redefine new-line-move to include
;;; output of line number

(defun new-line-move ()
  (fset 'old-line-move
	    (symbol-function 'line-move))
  (fset 'line-move
	    (function
	     (lambda (arg)
	       (old-line-move arg)
           (set-line)))))

(new-line-move)






        Neil Mager

==========================
Net                     <neilm@juliet.ll.mit.edu>
Voice                   (617) 981-4803
MIT Lincoln Labs        Lexington, MA
Technical Details
Message-ID: <9107091510.AA05945@horatio>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!juliet.ll.mit.edu!neilm
References: <BARVIAN.91Jul8161539@cocopah.sps.mot.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 102b9a,8784c3b1f0820646,start
X-Google-Attributes: gid102b9a,public
X-Google-Thread: 103b8b,8784c3b1f0820646,start
X-Google-Attributes: gid103b8b,public
X-Google-ArrivalTime: 1991-07-10 01:30:22 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!juliet.ll.mit.edu!neilm
From: neilm@juliet.ll.mit.edu (Neil Mager)
Newsgroups: gnu.emacs.help,comp.emacs
Subject: Line numbers in emacs?
Message-ID: <9107091510.AA05945@horatio>
Date: 9 Jul 91 15:10:15 GMT
References: <BARVIAN.91Jul8161539@cocopah.sps.mot.com>
Sender: gnulists@ai.mit.edu
Organization: Gatewayed from the GNU Project mailing list help-gnu-emacs@prep.ai.mit.edu
Lines: 45