home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / emacs / help / 4864 < prev    next >
Encoding:
Text File  |  1992-11-19  |  5.3 KB  |  136 lines

  1. Path: sparky!uunet!stanford.edu!rutgers!uwm.edu!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!centurion.ksu.ksu.edu!news
  2. From: kodiak@centurion.ksu.ksu.edu (Bryan D. Nehl)
  3. Newsgroups: gnu.emacs.help
  4. Subject: Re: Help With the status line
  5. Keywords: emacs status line
  6. Message-ID: <1egio5INN7ip@centurion.ksu.ksu.edu>
  7. Date: 19 Nov 92 17:26:29 GMT
  8. References: <1992Nov18.212235.23653@b8.b8.ingr.com>
  9. Organization: Feed the Bears Association
  10. Lines: 123
  11. NNTP-Posting-Host: centurion.ksu.ksu.edu
  12.  
  13. In <1992Nov18.212235.23653@b8.b8.ingr.com> paries@b8.b8.ingr.com (Randy Paries) writes:
  14.  
  15. >My question is how can I display ( or can I ) the current 
  16. >row or column. 
  17.  
  18. >randy@turq.b8.ingr.com
  19.  
  20. there seems to be enough interest that I will go ahead and post the
  21. code. Put the file row_col.el in a directory that is in your
  22. load-path.  M-x byte-compile the file and the put:
  23. (load "row_col")
  24. (display-curline)
  25. (display-curcol)
  26.  
  27. in your .emacs file.
  28.  
  29. /* === Bryan Nehl ========== kodiak@Kodiakpc.Manhattan.KS.US =========+
  30. [            USDA-ARS-NPA-WERU          ][ bdn@chepil.weru.ksu.edu    ]
  31. [     913.532.6233 or 913.532.6495      ][ kodiak@matt.ksu.ksu.edu    ]
  32. +_______________ ...!rutgers!matt.ksu.ksu.edu!kodiak _______________ */
  33.  
  34. ;;From: Haavard Rue <hrue@sima.sintef.no>
  35. ;;put this into your .emacs
  36.     ;;(load-file "the file below") ;; load the source
  37.     ;;(display-curline) ;; turn on current line
  38.     ;;(display-curcol) ;; turn on current column
  39. ;;
  40. ;; @(#)procs.el    1.1  12/23/91
  41. ;; 
  42.  
  43. ;;-----------------------------------------------------------------------------
  44. ;;                           display curcol and curline
  45. ;;-----------------------------------------------------------------------------
  46. ;;
  47. ;; the display-curcol and display-curline function
  48.  
  49. ;; show current column in mode line process
  50. ;;
  51. (defvar display-curcol-process nil)
  52. (defvar display-curcol-interval 2 "*Seconds between update current column")
  53. (defvar display-curcol-string nil)
  54. (defun display-curcol ()
  55. "Display current column in mode line of each buffer.
  56. Updates automatically every display-curcol-interval."
  57.   (interactive)
  58.   (let ((live (and display-curcol-process
  59.            (eq (process-status display-curcol-process) 'run))))
  60.     (if (not live)
  61.     (progn
  62.       (if display-curcol-process
  63.           (delete-process display-curcol-process))
  64.       (or global-mode-string (setq global-mode-string '("")))
  65.       (or (memq 'display-curcol-string global-mode-string)
  66.           (setq global-mode-string
  67.             (append global-mode-string '(display-curcol-string))))
  68.       (setq display-curcol-string "")
  69.       (setq display-curcol-process
  70.         (start-process "display-curcol" nil
  71.                    (concat exec-directory "wakeup")
  72.                    (int-to-string display-curcol-interval)))
  73.       (process-kill-without-query display-curcol-process)
  74.       (set-process-sentinel display-curcol-process 'display-curcol-sentinel)
  75.       (set-process-filter display-curcol-process 'display-curcol-filter)))))
  76. ;;
  77. (defun display-curcol-sentinel (proc reason)
  78.   (or (eq (process-status proc) 'run)
  79.       (setq display-curcol-string ""))
  80.   ;; Force mode-line updates
  81.   (save-excursion (set-buffer (other-buffer)))
  82.   (set-buffer-modified-p (buffer-modified-p))
  83.   (sit-for 0))
  84. ;;
  85. (defun display-curcol-filter (proc string)
  86.   (setq display-curcol-string (concat " C" (int-to-string (current-column)) " "))
  87.   (save-excursion (set-buffer (other-buffer)))
  88.   (set-buffer-modified-p (buffer-modified-p))
  89.   (sit-for 0))
  90. ;;
  91. ;; show current line-number in mode line process
  92. ;;
  93. (defvar display-curline-process nil)
  94. (defvar display-curline-interval 2 "*Seconds between update current line")
  95. (defvar display-curline-string nil)
  96. (defun display-curline ()
  97. "Display current linenumber in mode line of each buffer.
  98. Updates automatically every display-curline-interval."
  99.   (interactive)
  100.   (let ((live (and display-curline-process
  101.            (eq (process-status display-curline-process) 'run))))
  102.     (if (not live)
  103.     (progn
  104.       (if display-curline-process
  105.           (delete-process display-curline-process))
  106.       (or global-mode-string (setq global-mode-string '("")))
  107.       (or (memq 'display-curline-string global-mode-string)
  108.           (setq global-mode-string
  109.             (append global-mode-string '(display-curline-string))))
  110.       (setq display-curline-string "")
  111.       (setq display-curline-process
  112.         (start-process "display-curline" nil
  113.                    (concat exec-directory "wakeup")
  114.                    (int-to-string display-curline-interval)))
  115.       (process-kill-without-query display-curline-process)
  116.       (set-process-sentinel display-curline-process 'display-curline-sentinel)
  117.       (set-process-filter display-curline-process 'display-curline-filter)))))
  118. ;;
  119. (defun display-curline-sentinel (proc reason)
  120.   (or (eq (process-status proc) 'run)
  121.       (setq display-curline-string ""))
  122.   ;; Force mode-line updates
  123.   (save-excursion (set-buffer (other-buffer)))
  124.   (set-buffer-modified-p (buffer-modified-p))
  125.   (sit-for 0))
  126. ;;
  127. (defun display-curline-filter (proc string)
  128. ;; (setq display-curcol-string (concat " C" (int-to-string (current-column)) " "))
  129. ;; set lambda below to 0 so that the current line matches with current-line C-x l output
  130. ;; Bryan (kodiak@matt.ksu.ksu.edu)
  131.   (setq display-curline-string (concat " L" (int-to-string (+ 0 (count-lines 1 (point))))))
  132.   (save-excursion (set-buffer (other-buffer)))
  133.   (set-buffer-modified-p (buffer-modified-p))
  134.   (sit-for 0))
  135. ;; ------------------------------------------------------------------------------
  136.