home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / functions / simp-lnum.el < prev    next >
Encoding:
Text File  |  1992-09-20  |  1.5 KB  |  60 lines

  1. ;;; This will set the line number in the mode line automatically when
  2. ;;; next-line,prev-line,scroll-up, and scroll down are called. It does
  3. ;;; not work to well with vm.
  4.  
  5. ;;; LCD Archive Entry:
  6. ;;; simple-line-numbers|?|?|
  7. ;;; Simple line number in the mode line.|
  8. ;;; 92-09-17||~/functions/simp-lnum.el.Z|
  9.  
  10. ;;;  Use the following commented out code for displaying the current column.
  11. ;;;  Substitute it in the set-line function.
  12. ;;;
  13. ;;;  (setq mode-line-process
  14. ;;;        (format " %4d %4d" (1+ (count-lines 1 (point))) (current-column))))
  15.  
  16. (defun set-line ()
  17.   (interactive)
  18.   (setq mode-line-process
  19.         (format " %4d" (1+ (count-lines 1 (point))))))
  20.  
  21. ;;; redefine new-line-move to include output of line number
  22.  
  23. ;;; Use this for version  18.57 and beyond
  24.  
  25. (defun new-line-move ()
  26.   (fset 'old-line-move
  27.         (symbol-function 'next-line-internal))
  28.   (fset 'next-line-internal
  29.         (function
  30.          (lambda (arg)
  31.            (old-line-move arg)
  32.         (set-line)))))
  33.  
  34. ;;; Use this for version before 18.57
  35.  
  36. ;;;(defun new-line-move ()
  37. ;;;  (fset 'old-line-move
  38. ;;;        (symbol-function 'line-move))
  39. ;;;  (fset 'line-move
  40. ;;;        (function
  41. ;;;         (lambda (arg)
  42. ;;;           (old-line-move arg)
  43. ;;;           (set-line)))))
  44.  
  45. (new-line-move)
  46.  
  47. (defun new-scroll-up (&optional arg)
  48.   (interactive "P")
  49.   (scroll-up arg)
  50.   (set-line))
  51.  
  52.  
  53. (defun new-scroll-down (&optional arg)
  54.   (interactive "P")
  55.   (scroll-down arg)
  56.   (set-line))
  57.  
  58. (global-set-key "v" 'new-scroll-down)
  59. (global-set-key "\C-v" 'new-scroll-up)
  60.