# HG changeset patch # User Juri Linkov # Date 1094058359 0 # Node ID adba247afe3f69c661d761b9f4af49890a74654c # Parent 2e59d91877629b1e41d3a288d0a0f49ee4cabe43 * simple.el (next-error-find-buffer): Move the rule "if current buffer is a next-error capable buffer" after the rule "if next-error-last-buffer is set to a live buffer". Simplify to test all rules in one `or'. (next-error): Doc fix. diff -r 2e59d9187762 -r adba247afe3f lisp/simple.el --- a/lisp/simple.el Wed Sep 01 16:19:04 2004 +0000 +++ b/lisp/simple.el Wed Sep 01 17:05:59 2004 +0000 @@ -91,49 +91,48 @@ (or (and extra-test (funcall extra-test)) 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. -;; 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 - (let ((buffers (buffer-list))) - (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test)) - (and other-buffer - (eq (car buffers) (current-buffer))))) - (setq buffers (cdr buffers))) - (if buffers - (car buffers) - (or (and other-buffer - (next-error-buffer-p (current-buffer) extra-test) - ;; The current buffer is a next-error capable buffer. - (progn - (if other-buffer - (message "This is the only next-error capable buffer.")) - (current-buffer))) - (error "No next-error capable buffer found")))))))) + "Return a next-error capable buffer." + (or + ;; 1. If one window on the selected frame displays such buffer, return it. + (let ((window-buffers + (delete-dups + (delq nil (mapcar (lambda (w) + (if (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))) + ;; 2. If next-error-last-buffer is set to a live buffer, use that. + (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) + ;; 3. If the current buffer is a next-error capable buffer, return it. + (if (and (not other-buffer) + (next-error-buffer-p (current-buffer) extra-test)) + (current-buffer)) + ;; 4. Look for a next-error capable buffer in a buffer list. + (let ((buffers (buffer-list))) + (while (and buffers + (or (not (next-error-buffer-p (car buffers) extra-test)) + (and other-buffer (eq (car buffers) (current-buffer))))) + (setq buffers (cdr buffers))) + (if buffers + (car buffers) + (or (and other-buffer + (next-error-buffer-p (current-buffer) extra-test) + ;; The current buffer is a next-error capable buffer. + (progn + (if other-buffer + (message "This is the only next-error capable buffer")) + (current-buffer))) + (error "No next-error capable buffer found")))))) (defun next-error (&optional arg reset) "Visit next next-error message and corresponding source code. @@ -153,9 +152,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