aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2004-04-21 21:37:18 +0000
committerKim F. Storm2004-04-21 21:37:18 +0000
commit5d9f0de2dedbc943e3aa26610508cd75828b1406 (patch)
tree04c7c561f70086d043e663996a9d082df0cc940b
parent423e4de7c1f0f29b60f744ce4bf29e3d65f9271f (diff)
downloademacs-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.el111
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.")
125Each function is called with two arguments: the compilation buffer, 125Each function is called with two arguments: the compilation buffer,
126and a string describing how the process finished.") 126and a string describing how the process finished.")
127 127
128(defvar compilation-last-buffer nil
129 "The most recent compilation buffer.
130A buffer becomes most recent when its compilation is started
131or 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.
1352Prefix arg N says how many error messages to move forwards (or
1353backwards, if negative).
1354Finds and highlights the source line like \\[next-error], but does not
1355select 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.
1362Prefix arg N says how many error messages to move backwards (or
1363forwards, if negative).
1364Finds and highlights the source line like \\[previous-error], but does not
1365select 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.
1371Prefix arg N says how many files to move forwards (or backwards, if negative)." 1357Prefix 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.
1438Prefix arg N says how many error messages to move forwards (or
1439backwards, if negative).
1440
1441\\[next-error] normally uses the most recently started compilation or
1442grep buffer. However, it can operate on any buffer with output from
1443the \\[compile] and \\[grep] commands, or, more generally, on any
1444buffer in Compilation mode or with Compilation Minor mode enabled. To
1445specify use of a particular buffer for error messages, type
1446\\[next-error] in that buffer.
1447
1448Once \\[next-error] has chosen the buffer for error messages,
1449it stays with that buffer until you use it in some other buffer which
1450uses Compilation mode or Compilation Minor mode.
1451
1452See 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.
1505Prefix arg N says how many error messages to move backwards (or
1506forwards, if negative).
1507
1508This 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.
1514Visit corresponding source code.
1515With prefix arg N, visit the source code of the Nth error.
1516This 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.
1524This is useful when you compile temporary files, but want 1451This is useful when you compile temporary files, but want