--- /usr/src/emacs/lisp/simple.el 2004-06-30 14:03:13.000000000 -0400 +++ /home/tzz/emacs/mine/simple.el 2004-06-30 14:49:04.000000000 -0400 @@ -92,33 +92,34 @@ next-error-function))) ;; Return a next-error capable buffer according to the following rules: -;; 1. If the current buffer is a next-error capable buffer, return it. -;; 2. If one window on the selected frame displays such buffer, return it. -;; 3. If next-error-last-buffer is set to a live buffer, use that. +;; 1. If one window on the selected frame displays such buffer, return it. +;; 2. If next-error-last-buffer is set to a live buffer, use that. +;; 3. If the current buffer is a next-error capable buffer, return it. ;; 4. Otherwise, look for a next-error capable buffer in a buffer list. ;; 5. Signal an error if there are none. (defun next-error-find-buffer (&optional other-buffer extra-test) - (if (and (not other-buffer) - (next-error-buffer-p (current-buffer) extra-test)) - ;; The current buffer is a next-error capable buffer. - (current-buffer) - (or - (let ((window-buffers - (delete-dups - (delq nil - (mapcar (lambda (w) - (and (next-error-buffer-p (window-buffer w) extra-test) - (window-buffer w))) - (window-list)))))) - (if other-buffer - (setq window-buffers (delq (current-buffer) window-buffers))) - (if (eq (length window-buffers) 1) - (car window-buffers))) - (if (and next-error-last-buffer (buffer-name next-error-last-buffer) - (next-error-buffer-p next-error-last-buffer extra-test) - (or (not other-buffer) (not (eq next-error-last-buffer - (current-buffer))))) - next-error-last-buffer + (or + (let ((window-buffers + (delete-dups + (delq nil + (mapcar (lambda (w) + (and (next-error-buffer-p (window-buffer w) extra-test) + (window-buffer w))) + (window-list)))))) + (if other-buffer + (setq window-buffers (delq (current-buffer) window-buffers))) + (if (eq (length window-buffers) 1) + (car window-buffers))) + (if (and next-error-last-buffer + (buffer-name next-error-last-buffer) + (next-error-buffer-p next-error-last-buffer extra-test) + (or (not other-buffer) + (not (eq next-error-last-buffer (current-buffer))))) + next-error-last-buffer + (if (and (not other-buffer) + (next-error-buffer-p (current-buffer) extra-test)) + ;; The current buffer is a next-error capable buffer. + (current-buffer)))) (let ((buffers (buffer-list))) (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test)) (and other-buffer @@ -133,9 +134,9 @@ (if other-buffer (message "This is the only next-error capable buffer.")) (current-buffer))) - (error "No next-error capable buffer found")))))))) + (error "No next-error capable buffer found!"))))) -(defun next-error (arg &optional reset) +(defun next-error (&optional arg reset) "Visit next next-error message and corresponding source code. If all the error messages parsed so far have been processed already, @@ -153,9 +154,10 @@ buffer with output from the \\[compile], \\[grep] commands, or, more generally, on any buffer in Compilation mode or with Compilation Minor mode enabled, or any buffer in which -`next-error-function' is bound to an appropriate -function. To specify use of a particular buffer for error -messages, type \\[next-error] in that buffer. +`next-error-function' is bound to an appropriate function. To +specify use of a particular buffer for error messages, type +\\[next-error] in that buffer when it is the only one displayed +in the current frame. Once \\[next-error] has chosen the buffer for error messages, it stays with that buffer until you use it in some other buffer which @@ -164,7 +166,9 @@ See variables `compilation-parse-errors-function' and \`compilation-error-regexp-alist' for customization ideas." (interactive "P") - (if (consp arg) (setq reset t arg nil)) + (if (consp arg) + (setq reset t + arg nil)) (when (setq next-error-last-buffer (next-error-find-buffer)) ;; we know here that next-error-function is a valid symbol we can funcall (with-current-buffer next-error-last-buffer @@ -175,7 +179,7 @@ (define-key ctl-x-map "`" 'next-error) -(defun previous-error (n) +(defun previous-error (&optional n) "Visit previous next-error message and corresponding source code. Prefix arg N says how many error messages to move backwards (or @@ -183,9 +187,11 @@ This operates on the output from the \\[compile] and \\[grep] commands." (interactive "p") - (next-error (- n))) + (if n + (next-error (- n)) + (next-error))) -(defun first-error (n) +(defun first-error (&optional n) "Restart at the first error. Visit corresponding source code. With prefix arg N, visit the source code of the Nth error. @@ -193,7 +199,7 @@ (interactive "p") (next-error n t)) -(defun next-error-no-select (n) +(defun next-error-no-select (&optional n) "Move point to the next error in the next-error buffer and highlight match. Prefix arg N says how many error messages to move forwards (or backwards, if negative). @@ -203,14 +209,16 @@ (next-error n) (pop-to-buffer next-error-last-buffer)) -(defun previous-error-no-select (n) +(defun previous-error-no-select (&optional n) "Move point to the previous error in the next-error buffer and highlight match. Prefix arg N says how many error messages to move backwards (or forwards, if negative). Finds and highlights the source line like \\[previous-error], but does not select the source buffer." (interactive "p") - (next-error-no-select (- n))) + (if n + (next-error-no-select (- n)) + (next-error-no-select))) ;;; --- /usr/src/emacs/man/search.texi 2004-06-30 14:16:13.000000000 -0400 +++ /home/tzz/emacs/mine/search.texi 2004-06-30 14:34:40.000000000 -0400 @@ -1268,6 +1268,9 @@ @kbd{o} and @kbd{C-o} display the match in another window; @kbd{C-o} does not select it. +Occur mode supports the @code{next-error} functionality, described in +the section on Compilation. + @item M-x list-matching-lines Synonym for @kbd{M-x occur}. --- /usr/src/emacs/man/building.texi 2004-06-30 14:03:29.000000000 -0400 +++ /home/tzz/emacs/mine/building.texi 2004-06-30 14:52:02.000000000 -0400 @@ -204,6 +204,14 @@ buffer and finds no more error messages to visit, it fails and signals an Emacs error. + You don't have to be in the compilation buffer in order to use address@hidden If one window on the selected frame can be the +target of the @code{next-error} call, it is used. Else, if a buffer +previously had @code{next-error} called on it, it is used. Else, +if the current buffer can be the target of @code{next-error}, it is +used. Else, all the buffers Emacs manages are tried for address@hidden support. + @kbd{C-u C-x `} starts scanning from the beginning of the compilation buffer. This is one way to process the same set of errors again.