home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / emacs / help / 3952 < prev    next >
Encoding:
Text File  |  1992-09-02  |  2.2 KB  |  76 lines

  1. Path: sparky!uunet!dtix!darwin.sura.net!wupost!gumby!destroyer!ncar!sunny!southern
  2. From: southern@sunny.NoSubdomain.NoDomain (Lawrence Buja)
  3. Newsgroups: gnu.emacs.help
  4. Subject: Re: line numbers
  5. Message-ID: <1992Sep2.143710.28466@ncar.ucar.edu>
  6. Date: 2 Sep 92 14:37:10 GMT
  7. References: <9209020320.AA07133@midget.towson.edu>
  8. Sender: news@ncar.ucar.edu (USENET Maintenance)
  9. Reply-To: southern@ncar.ucar.edu
  10. Distribution: usa
  11. Organization: National Center for Atmospheric Research
  12. Lines: 62
  13.  
  14. In article <9209020320.AA07133@midget.towson.edu>, tree@midget.towson.edu (Denise Tree) writes:
  15. >I know that Emacs is not a line type editor but I've been doing
  16. >a lot of patching lately and it would be helpful....
  17.  
  18. I grabbed this off the net awhile ago and it works for me...
  19.  
  20. ;;;
  21. ;;; newline.el
  22. ;;;
  23. ;;; This will set the line number in the mode line automatically when
  24. ;;; next-line,prev-line,scroll-up, and scroll down are called. It does
  25. ;;; not work to well with vm.
  26. ;;;  Use the following commented out code for displaying the current column.
  27. ;;;  Substitute it in the set-line function.
  28. ;;;
  29. ;;;  (setq mode-line-process
  30. ;;;        (format " %4d %4d" (1+ (count-lines 1 (point))) (current-column))))
  31.  
  32.  
  33. (defvar new-line-move-flag nil
  34. "*Nil if line numbering has not yet been defined.")
  35.  
  36. (defun set-line ()
  37.   (interactive)
  38.   (setq mode-line-process
  39. ;;;     (format " %4d" (1+ (count-lines 1 (point))))))
  40.         (format " %4d %3d" (1+ (count-lines 1 (point))) (current-column))))
  41.  
  42. ;;; Redefine new-line-move to include output of line number
  43.  
  44. ;;; Use this for version  18.57 and beyond
  45. (defun new-line-move ()
  46.   "*Enable line numbering."
  47.   (fset 'old-line-move
  48.         (symbol-function 'next-line-internal))
  49.  (fset 'next-line-internal
  50.         (function
  51.          (lambda (arg)
  52.            (old-line-move arg)
  53.         (set-line))))
  54. )
  55.  
  56. (if new-line-move-flag
  57.   ()
  58.   (setq new-line-move-flag t)
  59.  (new-line-move))
  60.  
  61.  
  62. (defun new-scroll-up (&optional arg)
  63.   (interactive "P")
  64.   (scroll-up arg)
  65.   (set-line))
  66.  
  67. (defun new-scroll-down (&optional arg)
  68.   (interactive "P")
  69.   (scroll-down arg)
  70.   (set-line))
  71.  
  72.  
  73. /\      Lawrence Buja           Climate and Global Dynamics Division
  74.   \_][  southern@ncar.ucar.edu  National Center for Atmospheric Research
  75.       \_________________________Boulder,_Colorado___80307-3000__________
  76.