Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!strath-cs!ex-dcs!admin From: admin@dcs.exeter.ac.uk (System Administrator) Newsgroups: comp.emacs Subject: Re: Message-ID: <3813@izar.dcs.exeter.ac.uk> Date: 3 Jun 91 12:48:17 GMT References: <1991May30.142750.9342@bronze.ucs.indiana.edu> Sender: news@dcs.exeter.ac.uk Organization: Computer Science Dept. - University of Exeter. UK Lines: 159 Nntp-Posting-Host: merope In-reply-to: ury@cosmos.huji.ac.il's message of 30 May 91 14:27:50 GMT >>>>> In article <1991May30.142750.9342@bronze.ucs.indiana.edu> ury segal writes: ury> I'm a programmer. I need the line numbers 'cause the compiler give ury> them to me to tell me where the errors are. If it is standard C compiler error message then like other people have said that you can use other environments that will get you the line you want provided you compiled from emacs - typically M-x compile and then using C-x ` to get emacs to place you on the line where the error is (if you are compiling with many sourec files, this 'parse-error command will also load the files if needed.) Try also M-x grep The above features combined with M-x goto-line I get by all my requirements for getting to a specific line but I can understand that in some cases it would be nice if emacs did infact display line numbers. So here is a article I dug up that appeared looong ago. It is not perfect but it might help fist put a small shell script called "peep" in your path somewhere, peep contains while [ 1 ] do echo -n x sleep $1 done Then load this... ;; display-line-numbers: Show line-numbers for an Emacs buffer. ;; Copyright (C) 1989 Wayne Mesard ;; ;; This file is not officially part of GNU EMACS. But it is being ;; distributed under the terms of the GNU Emacs General Public License. ;; The copyright notice and this notice must be preserved in all copies. ;; Call M-x display-line-nums to show 'em. ;; M-x hide-line-nums to make 'em go away. ;; Or bind these guys to keys in your .emacs file. ;; [N.B. I haven't tested this rigorously. It may be buggy.] ;; I will get around to these things eventually. Other suggestions ;; are welcome. Mail to Mesard@BBN.COM. -wsm ;; To do: [wsm060289] ;; o Support for line numbers in multiple windows is not adequate. ;; Things like this should be possible and fool proof: ;; ;; +---------------------+ ;; | 1| GNU, which stands| ;; | 2|for Gnu's not Unix| ;; | 3|is the name for | ;; | 4|the complete ... | ;; +---------------------+ ;; |20|I canna change the| ;; |21|laws o physics | ;; |22|Cap'n! | ;; +---------------------+ ;; ;; o Ctrl-X 1 hides the line number window, but doesn't kill ;; The line-num process. It should. (Have the filter function ;; check for the case when the line num window isn't on screen.) ;; o Ctrl-X o should not go to the num buf. ;; o Similarly, The *Help* buffer should NOT be allowed to come ;; up in the line number window! ;; o Some function documentation would be nice. (defvar *win-min-width* 6) (defvar *line-num-update* 1) (defvar line-num-process nil) (defvar *line-num-buf* nil) (defun display-line-nums () (interactive) (if (> window-min-width *win-min-width*) (setq window-min-width *win-min-width*)) (split-window-horizontally *win-min-width*) (switch-to-buffer " Line-Numbers" t) (setq *line-num-buf* (current-buffer)) (other-window 1) (if (not (and line-num-process (eq (process-status line-num-process) 'run))) (progn (setq line-num-process (start-process "line-nums" nil "peep" (int-to-string *line-num-update*))) (set-process-sentinel line-num-process 'line-num-sentinel) (set-process-filter line-num-process 'update-when-scrolled))) (process-kill-without-query line-num-process) ) (defun line-num-sentinel (ignore reason) (hide-line-nums) (message "The line number process died unexpectedly: %s." reason)) (defun hide-line-nums () (interactive) (if (and line-num-process (eq (process-status line-num-process) 'run)) (progn (set-process-sentinel line-num-process nil) (delete-process line-num-process))) (let ((first-window (current-buffer)) (first-time t)) (while (or (not (eq first-window (current-buffer))) first-time) (setq first-time nil) (if (eq *line-num-buf* (current-buffer)) (delete-window) (other-window 1))) )) (defvar prev-top -99) (defun update-when-scrolled (ignore ignore) "When window has been scrolled, do something." (save-excursion (move-to-window-line 0) (if (and (not (eq (current-buffer) *line-num-buf*)) (/= (point) prev-top)) (let* ((cur-line-num (count-lines (point-min) (point))) (i (+ cur-line-num (window-height)))) (setq prev-top (point)) (other-window -1) (if (eq (current-buffer) *line-num-buf*) (progn (newline (goto-line i)) (while (> i cur-line-num) (setq i (1- i)) (forward-line -1) (if (looking-at "$") (progn (if (< i 10) (insert " ") (if (< i 100) (insert ?\040))) (insert (int-to-string i)))) ) (move-to-window-line 0) (scroll-up (- i (count-lines (point-min) (point)))) (move-to-window-line 0) )) (other-window 1)) ))) -- Khalid Sattar JANET : admin@uk.ac.ex.dcs Computer Science Dept. UUCP : admin@ex-dcs.uucp University of Exeter INTERNET: admin%dcs.ex.ac.uk Exeter, UK. Tel : +44 392 264062