diff options
| author | Kim F. Storm | 2004-04-21 21:37:18 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-04-21 21:37:18 +0000 |
| commit | 5d9f0de2dedbc943e3aa26610508cd75828b1406 (patch) | |
| tree | 04c7c561f70086d043e663996a9d082df0cc940b | |
| parent | 423e4de7c1f0f29b60f744ce4bf29e3d65f9271f (diff) | |
| download | emacs-5d9f0de2dedbc943e3aa26610508cd75828b1406.tar.gz emacs-5d9f0de2dedbc943e3aa26610508cd75828b1406.zip | |
From: Teodor Zlatanov <tzz@lifelogs.com>
(compilation-start): Set next-error-last-buffer so
next-error knows where to jump.
(compilation-setup): Set the buffer-local variable
next-error-function to 'compilation-next-error-function.
(compilation-buffer-p, compilation-buffer-internal-p): Use an
alternate way to find if a buffer is a compilation buffer, for
next-error convenience.
(next-error-no-select, previous-error-no-select, next-error)
(previous-error, first-error): Move to simple.el.
(compilation-find-buffer): Move to next-error-find-buffer in simple.el.
(compilation-last-buffer): Remove.
(compilation-start, compilation-next-error, compilation-setup)
(compilation-next-error-function, compilation-find-buffer):
Remove compilation-last-buffer use.
| -rw-r--r-- | lisp/progmodes/compile.el | 111 |
1 files changed, 19 insertions, 92 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 6bfdea2b8bf..00b9830516f 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el | |||
| @@ -125,11 +125,6 @@ describing how the process finished.") | |||
| 125 | Each function is called with two arguments: the compilation buffer, | 125 | Each function is called with two arguments: the compilation buffer, |
| 126 | and a string describing how the process finished.") | 126 | and a string describing how the process finished.") |
| 127 | 127 | ||
| 128 | (defvar compilation-last-buffer nil | ||
| 129 | "The most recent compilation buffer. | ||
| 130 | A buffer becomes most recent when its compilation is started | ||
| 131 | or when it is used with \\[next-error] or \\[compile-goto-error].") | ||
| 132 | |||
| 133 | (defvar compilation-in-progress nil | 128 | (defvar compilation-in-progress nil |
| 134 | "List of compilation processes now running.") | 129 | "List of compilation processes now running.") |
| 135 | (or (assq 'compilation-in-progress minor-mode-alist) | 130 | (or (assq 'compilation-in-progress minor-mode-alist) |
| @@ -968,7 +963,7 @@ exited abnormally with code %d\n" | |||
| 968 | (select-window outwin) | 963 | (select-window outwin) |
| 969 | (goto-char (point-max)))) | 964 | (goto-char (point-max)))) |
| 970 | ;; Make it so the next C-x ` will use this buffer. | 965 | ;; Make it so the next C-x ` will use this buffer. |
| 971 | (setq compilation-last-buffer outbuf))) | 966 | (setq next-error-last-buffer outbuf))) |
| 972 | 967 | ||
| 973 | (defun compilation-set-window-height (window) | 968 | (defun compilation-set-window-height (window) |
| 974 | "Set the height of WINDOW according to `compilation-window-height'." | 969 | "Set the height of WINDOW according to `compilation-window-height'." |
| @@ -1099,6 +1094,10 @@ Runs `compilation-mode-hook' with `run-hooks' (which see)." | |||
| 1099 | (set (make-local-variable 'page-delimiter) | 1094 | (set (make-local-variable 'page-delimiter) |
| 1100 | compilation-page-delimiter) | 1095 | compilation-page-delimiter) |
| 1101 | (compilation-setup) | 1096 | (compilation-setup) |
| 1097 | ;; note that compilation-next-error-function is for interfacing | ||
| 1098 | ;; with the next-error function in simple.el, and it's only | ||
| 1099 | ;; coincidentally named similarly to compilation-next-error | ||
| 1100 | (setq next-error-function 'compilation-next-error-function) | ||
| 1102 | (run-mode-hooks 'compilation-mode-hook)) | 1101 | (run-mode-hooks 'compilation-mode-hook)) |
| 1103 | 1102 | ||
| 1104 | (defmacro define-compilation-mode (mode name doc &rest body) | 1103 | (defmacro define-compilation-mode (mode name doc &rest body) |
| @@ -1160,7 +1159,6 @@ Optional argument MINOR indicates this is called from | |||
| 1160 | (make-local-variable 'compilation-current-error) | 1159 | (make-local-variable 'compilation-current-error) |
| 1161 | (make-local-variable 'compilation-error-screen-columns) | 1160 | (make-local-variable 'compilation-error-screen-columns) |
| 1162 | (make-local-variable 'overlay-arrow-position) | 1161 | (make-local-variable 'overlay-arrow-position) |
| 1163 | (setq compilation-last-buffer (current-buffer)) | ||
| 1164 | (set (make-local-variable 'font-lock-extra-managed-props) | 1162 | (set (make-local-variable 'font-lock-extra-managed-props) |
| 1165 | '(directory message help-echo mouse-face debug)) | 1163 | '(directory message help-echo mouse-face debug)) |
| 1166 | (set (make-local-variable 'compilation-locs) | 1164 | (set (make-local-variable 'compilation-locs) |
| @@ -1277,8 +1275,16 @@ Just inserts the text, but uses `insert-before-markers'." | |||
| 1277 | (insert-before-markers string) | 1275 | (insert-before-markers string) |
| 1278 | (run-hooks 'compilation-filter-hook)))))) | 1276 | (run-hooks 'compilation-filter-hook)))))) |
| 1279 | 1277 | ||
| 1278 | ;;; test if a buffer is a compilation buffer, assuming we're in the buffer | ||
| 1279 | (defsubst compilation-buffer-internal-p () | ||
| 1280 | "Test if inside a compilation buffer." | ||
| 1281 | (local-variable-p 'compilation-locs)) | ||
| 1282 | |||
| 1283 | ;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p | ||
| 1280 | (defsubst compilation-buffer-p (buffer) | 1284 | (defsubst compilation-buffer-p (buffer) |
| 1281 | (local-variable-p 'compilation-locs buffer)) | 1285 | "Test if BUFFER is a compilation buffer." |
| 1286 | (with-current-buffer buffer | ||
| 1287 | (compilation-buffer-internal-p))) | ||
| 1282 | 1288 | ||
| 1283 | (defmacro compilation-loop (< property-change 1+ error) | 1289 | (defmacro compilation-loop (< property-change 1+ error) |
| 1284 | `(while (,< n 0) | 1290 | `(while (,< n 0) |
| @@ -1309,7 +1315,6 @@ Does NOT find the source line like \\[next-error]." | |||
| 1309 | (or (compilation-buffer-p (current-buffer)) | 1315 | (or (compilation-buffer-p (current-buffer)) |
| 1310 | (error "Not in a compilation buffer")) | 1316 | (error "Not in a compilation buffer")) |
| 1311 | (or pt (setq pt (point))) | 1317 | (or pt (setq pt (point))) |
| 1312 | (setq compilation-last-buffer (current-buffer)) | ||
| 1313 | (let* ((msg (get-text-property pt 'message)) | 1318 | (let* ((msg (get-text-property pt 'message)) |
| 1314 | (loc (car msg)) | 1319 | (loc (car msg)) |
| 1315 | last) | 1320 | last) |
| @@ -1347,25 +1352,6 @@ Does NOT find the source line like \\[previous-error]." | |||
| 1347 | (interactive "p") | 1352 | (interactive "p") |
| 1348 | (compilation-next-error (- n))) | 1353 | (compilation-next-error (- n))) |
| 1349 | 1354 | ||
| 1350 | (defun next-error-no-select (n) | ||
| 1351 | "Move point to the next error in the compilation buffer and highlight match. | ||
| 1352 | Prefix arg N says how many error messages to move forwards (or | ||
| 1353 | backwards, if negative). | ||
| 1354 | Finds and highlights the source line like \\[next-error], but does not | ||
| 1355 | select the source buffer." | ||
| 1356 | (interactive "p") | ||
| 1357 | (next-error n) | ||
| 1358 | (pop-to-buffer compilation-last-buffer)) | ||
| 1359 | |||
| 1360 | (defun previous-error-no-select (n) | ||
| 1361 | "Move point to previous error in compilation buffer and highlight match. | ||
| 1362 | Prefix arg N says how many error messages to move backwards (or | ||
| 1363 | forwards, if negative). | ||
| 1364 | Finds and highlights the source line like \\[previous-error], but does not | ||
| 1365 | select the source buffer." | ||
| 1366 | (interactive "p") | ||
| 1367 | (next-error-no-select (- n))) | ||
| 1368 | |||
| 1369 | (defun compilation-next-file (n) | 1355 | (defun compilation-next-file (n) |
| 1370 | "Move point to the next error for a different file than the current one. | 1356 | "Move point to the next error for a different file than the current one. |
| 1371 | Prefix arg N says how many files to move forwards (or backwards, if negative)." | 1357 | Prefix arg N says how many files to move forwards (or backwards, if negative)." |
| @@ -1403,55 +1389,17 @@ Use this command in a compilation log buffer. Sets the mark at point there." | |||
| 1403 | 1389 | ||
| 1404 | ;; Return a compilation buffer. | 1390 | ;; Return a compilation buffer. |
| 1405 | ;; If the current buffer is a compilation buffer, return it. | 1391 | ;; If the current buffer is a compilation buffer, return it. |
| 1406 | ;; If compilation-last-buffer is set to a live buffer, use that. | ||
| 1407 | ;; Otherwise, look for a compilation buffer and signal an error | 1392 | ;; Otherwise, look for a compilation buffer and signal an error |
| 1408 | ;; if there are none. | 1393 | ;; if there are none. |
| 1409 | (defun compilation-find-buffer (&optional other-buffer) | 1394 | (defun compilation-find-buffer (&optional other-buffer) |
| 1410 | (if (and (not other-buffer) | 1395 | (next-error-find-buffer other-buffer 'compilation-buffer-internal-p)) |
| 1411 | (compilation-buffer-p (current-buffer))) | ||
| 1412 | ;; The current buffer is a compilation buffer. | ||
| 1413 | (current-buffer) | ||
| 1414 | (if (and compilation-last-buffer (buffer-name compilation-last-buffer) | ||
| 1415 | (compilation-buffer-p compilation-last-buffer) | ||
| 1416 | (or (not other-buffer) (not (eq compilation-last-buffer | ||
| 1417 | (current-buffer))))) | ||
| 1418 | compilation-last-buffer | ||
| 1419 | (let ((buffers (buffer-list))) | ||
| 1420 | (while (and buffers (or (not (compilation-buffer-p (car buffers))) | ||
| 1421 | (and other-buffer | ||
| 1422 | (eq (car buffers) (current-buffer))))) | ||
| 1423 | (setq buffers (cdr buffers))) | ||
| 1424 | (if buffers | ||
| 1425 | (car buffers) | ||
| 1426 | (or (and other-buffer | ||
| 1427 | (compilation-buffer-p (current-buffer)) | ||
| 1428 | ;; The current buffer is a compilation buffer. | ||
| 1429 | (progn | ||
| 1430 | (if other-buffer | ||
| 1431 | (message "This is the only compilation buffer.")) | ||
| 1432 | (current-buffer))) | ||
| 1433 | (error "No compilation started!"))))))) | ||
| 1434 | 1396 | ||
| 1435 | ;;;###autoload | 1397 | ;;;###autoload |
| 1436 | (defun next-error (&optional n) | 1398 | (defun compilation-next-error-function (n &optional reset) |
| 1437 | "Visit next compilation error message and corresponding source code. | ||
| 1438 | Prefix arg N says how many error messages to move forwards (or | ||
| 1439 | backwards, if negative). | ||
| 1440 | |||
| 1441 | \\[next-error] normally uses the most recently started compilation or | ||
| 1442 | grep buffer. However, it can operate on any buffer with output from | ||
| 1443 | the \\[compile] and \\[grep] commands, or, more generally, on any | ||
| 1444 | buffer in Compilation mode or with Compilation Minor mode enabled. To | ||
| 1445 | specify use of a particular buffer for error messages, type | ||
| 1446 | \\[next-error] in that buffer. | ||
| 1447 | |||
| 1448 | Once \\[next-error] has chosen the buffer for error messages, | ||
| 1449 | it stays with that buffer until you use it in some other buffer which | ||
| 1450 | uses Compilation mode or Compilation Minor mode. | ||
| 1451 | |||
| 1452 | See variable `compilation-error-regexp-alist' for customization ideas." | ||
| 1453 | (interactive "p") | 1399 | (interactive "p") |
| 1454 | (set-buffer (setq compilation-last-buffer (compilation-find-buffer))) | 1400 | (set-buffer (compilation-find-buffer)) |
| 1401 | (when reset | ||
| 1402 | (setq compilation-current-error nil)) | ||
| 1455 | (let* ((columns compilation-error-screen-columns) ; buffer's local value | 1403 | (let* ((columns compilation-error-screen-columns) ; buffer's local value |
| 1456 | (last 1) | 1404 | (last 1) |
| 1457 | (loc (compilation-next-error (or n 1) nil | 1405 | (loc (compilation-next-error (or n 1) nil |
| @@ -1498,27 +1446,6 @@ See variable `compilation-error-regexp-alist' for customization ideas." | |||
| 1498 | (compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc)) | 1446 | (compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc)) |
| 1499 | (setcdr (nthcdr 3 loc) t))) ; Set this one as visited. | 1447 | (setcdr (nthcdr 3 loc) t))) ; Set this one as visited. |
| 1500 | 1448 | ||
| 1501 | ;;;###autoload (define-key ctl-x-map "`" 'next-error) | ||
| 1502 | |||
| 1503 | (defun previous-error (n) | ||
| 1504 | "Visit previous compilation error message and corresponding source code. | ||
| 1505 | Prefix arg N says how many error messages to move backwards (or | ||
| 1506 | forwards, if negative). | ||
| 1507 | |||
| 1508 | This operates on the output from the \\[compile] and \\[grep] commands." | ||
| 1509 | (interactive "p") | ||
| 1510 | (next-error (- n))) | ||
| 1511 | |||
| 1512 | (defun first-error (n) | ||
| 1513 | "Restart at the first error. | ||
| 1514 | Visit corresponding source code. | ||
| 1515 | With prefix arg N, visit the source code of the Nth error. | ||
| 1516 | This operates on the output from the \\[compile] command." | ||
| 1517 | (interactive "p") | ||
| 1518 | (set-buffer (setq compilation-last-buffer (compilation-find-buffer))) | ||
| 1519 | (setq compilation-current-error nil) | ||
| 1520 | (next-error n)) | ||
| 1521 | |||
| 1522 | (defun compilation-fake-loc (marker file &optional line col) | 1449 | (defun compilation-fake-loc (marker file &optional line col) |
| 1523 | "Preassociate MARKER with FILE. | 1450 | "Preassociate MARKER with FILE. |
| 1524 | This is useful when you compile temporary files, but want | 1451 | This is useful when you compile temporary files, but want |