comparison lisp/simple.el @ 55755:969064cce54e

(next-error-find-buffer): Add a rule to return next-error capable buffer if one window on the selected frame displays such buffer.
author Juri Linkov <juri@jurta.org>
date Sun, 23 May 2004 21:01:15 +0000
parents 030ebc46c0c1
children 85609e1fa661 445e34bd8b61
comparison
equal deleted inserted replaced
55754:da7a694d2097 55755:969064cce54e
89 "Test if BUFFER is a next-error capable buffer." 89 "Test if BUFFER is a next-error capable buffer."
90 (with-current-buffer buffer 90 (with-current-buffer buffer
91 (or (and extra-test (funcall extra-test)) 91 (or (and extra-test (funcall extra-test))
92 next-error-function))) 92 next-error-function)))
93 93
94 ;; Return a next-error capable buffer. 94 ;; Return a next-error capable buffer according to the following rules:
95 ;; If the current buffer is such, return it. 95 ;; 1. If the current buffer is a next-error capable buffer, return it.
96 ;; If next-error-last-buffer is set to a live buffer, use that. 96 ;; 2. If one window on the selected frame displays such buffer, return it.
97 ;; Otherwise, look for a next-error capable buffer and signal an error 97 ;; 3. If next-error-last-buffer is set to a live buffer, use that.
98 ;; if there are none. 98 ;; 4. Otherwise, look for a next-error capable buffer in a buffer list.
99 ;; 5. Signal an error if there are none.
99 (defun next-error-find-buffer (&optional other-buffer extra-test) 100 (defun next-error-find-buffer (&optional other-buffer extra-test)
100 (if (and (not other-buffer) 101 (if (and (not other-buffer)
101 (next-error-buffer-p (current-buffer) extra-test)) 102 (next-error-buffer-p (current-buffer) extra-test))
102 ;; The current buffer is a next-error capable buffer. 103 ;; The current buffer is a next-error capable buffer.
103 (current-buffer) 104 (current-buffer)
104 (if (and next-error-last-buffer (buffer-name next-error-last-buffer) 105 (or
105 (next-error-buffer-p next-error-last-buffer extra-test) 106 (let ((window-buffers
106 (or (not other-buffer) (not (eq next-error-last-buffer 107 (delete-dups
107 (current-buffer))))) 108 (delq nil
108 next-error-last-buffer 109 (mapcar (lambda (w)
109 (let ((buffers (buffer-list))) 110 (and (next-error-buffer-p (window-buffer w) extra-test)
110 (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test)) 111 (window-buffer w)))
111 (and other-buffer 112 (window-list))))))
112 (eq (car buffers) (current-buffer))))) 113 (if other-buffer
113 (setq buffers (cdr buffers))) 114 (setq window-buffers (delq (current-buffer) window-buffers)))
114 (if buffers 115 (if (eq (length window-buffers) 1)
115 (car buffers) 116 (car window-buffers)))
116 (or (and other-buffer 117 (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
117 (next-error-buffer-p (current-buffer) extra-test) 118 (next-error-buffer-p next-error-last-buffer extra-test)
118 ;; The current buffer is a next-error capable buffer. 119 (or (not other-buffer) (not (eq next-error-last-buffer
119 (progn 120 (current-buffer)))))
120 (if other-buffer 121 next-error-last-buffer
121 (message "This is the only next-error capable buffer.")) 122 (let ((buffers (buffer-list)))
122 (current-buffer))) 123 (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
123 (error "No next-error capable buffer found!"))))))) 124 (and other-buffer
125 (eq (car buffers) (current-buffer)))))
126 (setq buffers (cdr buffers)))
127 (if buffers
128 (car buffers)
129 (or (and other-buffer
130 (next-error-buffer-p (current-buffer) extra-test)
131 ;; The current buffer is a next-error capable buffer.
132 (progn
133 (if other-buffer
134 (message "This is the only next-error capable buffer."))
135 (current-buffer)))
136 (error "No next-error capable buffer found!"))))))))
124 137
125 (defun next-error (arg &optional reset) 138 (defun next-error (arg &optional reset)
126 "Visit next next-error message and corresponding source code. 139 "Visit next next-error message and corresponding source code.
127 140
128 If all the error messages parsed so far have been processed already, 141 If all the error messages parsed so far have been processed already,