From: kodiak@centurion.ksu.ksu.edu (Bryan D. Nehl)
Newsgroups: gnu.emacs.help
Subject: Re: Help With the status line
Keywords: emacs status line
Date: 19 Nov 92 17:26:29 GMT
Organization: Feed the Bears Association
NNTP-Posting-Host: centurion.ksu.ksu.edu

In <1992Nov18.212235.23653@b8.b8.ingr.com> paries@b8.b8.ingr.com (Randy Paries) writes:

>My question is how can I display ( or can I ) the current 
>row or column. 

>randy@turq.b8.ingr.com

there seems to be enough interest that I will go ahead and post the
code. Put the file row_col.el in a directory that is in your
load-path.  M-x byte-compile the file and the put:
(load "row_col")
(display-curline)
(display-curcol)

in your .emacs file.

/* === Bryan Nehl ========== kodiak@Kodiakpc.Manhattan.KS.US =========+
[            USDA-ARS-NPA-WERU          ][ bdn@chepil.weru.ksu.edu    ]
[     913.532.6233 or 913.532.6495      ][ kodiak@matt.ksu.ksu.edu    ]
+_______________ ...!rutgers!matt.ksu.ksu.edu!kodiak _______________ */

;;From: Haavard Rue <hrue@sima.sintef.no>
;;put this into your .emacs
	;;(load-file "the file below") ;; load the source
	;;(display-curline) ;; turn on current line
	;;(display-curcol) ;; turn on current column
;;
;; @(#)procs.el	1.1  12/23/91
;; 

;;-----------------------------------------------------------------------------
;;                           display curcol and curline
;;-----------------------------------------------------------------------------
;;
;; the display-curcol and display-curline function

;; show current column in mode line process
;;
(defvar display-curcol-process nil)
(defvar display-curcol-interval 2 "*Seconds between update current column")
(defvar display-curcol-string nil)
(defun display-curcol ()
"Display current column in mode line of each buffer.
Updates automatically every display-curcol-interval."
  (interactive)
  (let ((live (and display-curcol-process
		   (eq (process-status display-curcol-process) 'run))))
    (if (not live)
	(progn
	  (if display-curcol-process
	      (delete-process display-curcol-process))
	  (or global-mode-string (setq global-mode-string '("")))
	  (or (memq 'display-curcol-string global-mode-string)
	      (setq global-mode-string
		    (append global-mode-string '(display-curcol-string))))
	  (setq display-curcol-string "")
	  (setq display-curcol-process
		(start-process "display-curcol" nil
			       (concat exec-directory "wakeup")
			       (int-to-string display-curcol-interval)))
	  (process-kill-without-query display-curcol-process)
	  (set-process-sentinel display-curcol-process 'display-curcol-sentinel)
	  (set-process-filter display-curcol-process 'display-curcol-filter)))))
;;
(defun display-curcol-sentinel (proc reason)
  (or (eq (process-status proc) 'run)
      (setq display-curcol-string ""))
  ;; Force mode-line updates
  (save-excursion (set-buffer (other-buffer)))
  (set-buffer-modified-p (buffer-modified-p))
  (sit-for 0))
;;
(defun display-curcol-filter (proc string)
  (setq display-curcol-string (concat " C" (int-to-string (current-column)) " "))
  (save-excursion (set-buffer (other-buffer)))
  (set-buffer-modified-p (buffer-modified-p))
  (sit-for 0))
;;
;; show current line-number in mode line process
;;
(defvar display-curline-process nil)
(defvar display-curline-interval 2 "*Seconds between update current line")
(defvar display-curline-string nil)
(defun display-curline ()
"Display current linenumber in mode line of each buffer.
Updates automatically every display-curline-interval."
  (interactive)
  (let ((live (and display-curline-process
		   (eq (process-status display-curline-process) 'run))))
    (if (not live)
	(progn
	  (if display-curline-process
	      (delete-process display-curline-process))
	  (or global-mode-string (setq global-mode-string '("")))
	  (or (memq 'display-curline-string global-mode-string)
	      (setq global-mode-string
		    (append global-mode-string '(display-curline-string))))
	  (setq display-curline-string "")
	  (setq display-curline-process
		(start-process "display-curline" nil
			       (concat exec-directory "wakeup")
			       (int-to-string display-curline-interval)))
	  (process-kill-without-query display-curline-process)
	  (set-process-sentinel display-curline-process 'display-curline-sentinel)
	  (set-process-filter display-curline-process 'display-curline-filter)))))
;;
(defun display-curline-sentinel (proc reason)
  (or (eq (process-status proc) 'run)
      (setq display-curline-string ""))
  ;; Force mode-line updates
  (save-excursion (set-buffer (other-buffer)))
  (set-buffer-modified-p (buffer-modified-p))
  (sit-for 0))
;;
(defun display-curline-filter (proc string)
;; (setq display-curcol-string (concat " C" (int-to-string (current-column)) " "))
;; set lambda below to 0 so that the current line matches with current-line C-x l output
;; Bryan (kodiak@matt.ksu.ksu.edu)
  (setq display-curline-string (concat " L" (int-to-string (+ 0 (count-lines 1 (point))))))
  (save-excursion (set-buffer (other-buffer)))
  (set-buffer-modified-p (buffer-modified-p))
  (sit-for 0))
;; ------------------------------------------------------------------------------
Newsgroups: gnu.emacs.help