Mercurial > emacs
comparison lisp/progmodes/compile.el @ 54854:eb5c70ae728c
(compilation-setup): Localize overlay-arrow-position.
(compilation-sentinel): Restructure code equivalently.
(compilation-next-error): Find message on same line after point if
not found before point.
(compile-mouse-goto-error): Restore function so that compilation
buffer need not be current and use compile-goto-error.
(compile-goto-error): Restore function.
(next-error): Set overlay-arrow-position.
(compilation-forget-errors): Don't localize already local
compilation-locs and remove FIXME about refontifying.
author | Daniel Pfeiffer <occitan@esperanto.org> |
---|---|
date | Tue, 13 Apr 2004 22:42:43 +0000 |
parents | 7b278dbd537f |
children | 6a45f159f315 |
comparison
equal
deleted
inserted
replaced
54853:429f2746c125 | 54854:eb5c70ae728c |
---|---|
673 (let ((file (nth 1 item)) | 673 (let ((file (nth 1 item)) |
674 (line (nth 2 item)) | 674 (line (nth 2 item)) |
675 (col (nth 3 item)) | 675 (col (nth 3 item)) |
676 (type (nth 4 item)) | 676 (type (nth 4 item)) |
677 end-line end-col fmt) | 677 end-line end-col fmt) |
678 (if (consp file) (setq fmt (cdr file) file (car file))) | 678 (if (consp file) (setq fmt (cdr file) file (car file))) |
679 (if (consp line) (setq end-line (cdr line) line (car line))) | 679 (if (consp line) (setq end-line (cdr line) line (car line))) |
680 (if (consp col) (setq end-col (cdr col) col (car col))) | 680 (if (consp col) (setq end-col (cdr col) col (car col))) |
681 | 681 |
682 (if (functionp line) | 682 (if (functionp line) |
683 ;; The old compile.el had here an undocumented hook that | 683 ;; The old compile.el had here an undocumented hook that |
684 ;; allowed `line' to be a function that computed the actual | 684 ;; allowed `line' to be a function that computed the actual |
685 ;; error location. Let's do our best. | 685 ;; error location. Let's do our best. |
686 `(,(car item) | 686 `(,(car item) |
688 (funcall ',line (list* (match-string ,file) | 688 (funcall ',line (list* (match-string ,file) |
689 default-directory | 689 default-directory |
690 ',(nthcdr 4 item)) | 690 ',(nthcdr 4 item)) |
691 ,(if col `(match-string ,col))))) | 691 ,(if col `(match-string ,col))))) |
692 (,file compilation-error-face t)) | 692 (,file compilation-error-face t)) |
693 | 693 |
694 `(,(nth 0 item) | 694 `(,(nth 0 item) |
695 | 695 |
696 ,@(when (integerp file) | 696 ,@(when (integerp file) |
697 `((,file ,(if (consp type) | 697 `((,file ,(if (consp type) |
698 `(compilation-face ',type) | 698 `(compilation-face ',type) |
980 '("Next Error" . next-error)) | 980 '("Next Error" . next-error)) |
981 map)) | 981 map)) |
982 | 982 |
983 (defvar compilation-minor-mode-map | 983 (defvar compilation-minor-mode-map |
984 (let ((map (make-sparse-keymap))) | 984 (let ((map (make-sparse-keymap))) |
985 (define-key map [mouse-2] 'compile-goto-error) | 985 (define-key map [mouse-2] 'compile-mouse-goto-error) |
986 (define-key map "\C-c\C-c" 'compile-goto-error) | 986 (define-key map "\C-c\C-c" 'compile-goto-error) |
987 (define-key map "\C-m" 'compile-goto-error) | 987 (define-key map "\C-m" 'compile-goto-error) |
988 (define-key map "\C-c\C-k" 'kill-compilation) | 988 (define-key map "\C-c\C-k" 'kill-compilation) |
989 (define-key map "\M-n" 'compilation-next-error) | 989 (define-key map "\M-n" 'compilation-next-error) |
990 (define-key map "\M-p" 'compilation-previous-error) | 990 (define-key map "\M-p" 'compilation-previous-error) |
996 map) | 996 map) |
997 "Keymap for `compilation-minor-mode'.") | 997 "Keymap for `compilation-minor-mode'.") |
998 | 998 |
999 (defvar compilation-shell-minor-mode-map | 999 (defvar compilation-shell-minor-mode-map |
1000 (let ((map (make-sparse-keymap))) | 1000 (let ((map (make-sparse-keymap))) |
1001 (define-key map [mouse-2] 'compile-goto-error) | 1001 (define-key map [mouse-2] 'compile-mouse-goto-error) |
1002 (define-key map "\M-\C-m" 'compile-goto-error) | 1002 (define-key map "\M-\C-m" 'compile-goto-error) |
1003 (define-key map "\M-\C-n" 'compilation-next-error) | 1003 (define-key map "\M-\C-n" 'compilation-next-error) |
1004 (define-key map "\M-\C-p" 'compilation-previous-error) | 1004 (define-key map "\M-\C-p" 'compilation-previous-error) |
1005 (define-key map "\M-{" 'compilation-previous-file) | 1005 (define-key map "\M-{" 'compilation-previous-file) |
1006 (define-key map "\M-}" 'compilation-next-file) | 1006 (define-key map "\M-}" 'compilation-next-file) |
1129 | 1129 |
1130 (defun compilation-setup (&optional minor) | 1130 (defun compilation-setup (&optional minor) |
1131 "Prepare the buffer for the compilation parsing commands to work." | 1131 "Prepare the buffer for the compilation parsing commands to work." |
1132 (make-local-variable 'compilation-current-error) | 1132 (make-local-variable 'compilation-current-error) |
1133 (make-local-variable 'compilation-error-screen-columns) | 1133 (make-local-variable 'compilation-error-screen-columns) |
1134 (make-local-variable 'overlay-arrow-position) | |
1134 (setq compilation-last-buffer (current-buffer)) | 1135 (setq compilation-last-buffer (current-buffer)) |
1135 (set (make-local-variable 'font-lock-extra-managed-props) | 1136 (set (make-local-variable 'font-lock-extra-managed-props) |
1136 '(directory message help-echo mouse-face debug)) | 1137 '(directory message help-echo mouse-face debug)) |
1137 (set (make-local-variable 'compilation-locs) | 1138 (set (make-local-variable 'compilation-locs) |
1138 (make-hash-table :test 'equal :weakness 'value)) | 1139 (make-hash-table :test 'equal :weakness 'value)) |
1190 (funcall compilation-exit-message-function | 1191 (funcall compilation-exit-message-function |
1191 process-status exit-status msg) | 1192 process-status exit-status msg) |
1192 (cons msg exit-status))) | 1193 (cons msg exit-status))) |
1193 (omax (point-max)) | 1194 (omax (point-max)) |
1194 (opoint (point))) | 1195 (opoint (point))) |
1195 ;; Record where we put the message, so we can ignore it | 1196 ;; Record where we put the message, so we can ignore it later on. |
1196 ;; later on. | |
1197 (goto-char omax) | 1197 (goto-char omax) |
1198 (insert ?\n mode-name " " (car status)) | 1198 (insert ?\n mode-name " " (car status)) |
1199 (if (and (numberp compilation-window-height) | 1199 (if (and (numberp compilation-window-height) |
1200 (zerop compilation-window-height)) | 1200 (zerop compilation-window-height)) |
1201 (message "%s" (cdr status))) | 1201 (message "%s" (cdr status))) |
1219 (setq functions (cdr functions)))))) | 1219 (setq functions (cdr functions)))))) |
1220 | 1220 |
1221 ;; Called when compilation process changes state. | 1221 ;; Called when compilation process changes state. |
1222 (defun compilation-sentinel (proc msg) | 1222 (defun compilation-sentinel (proc msg) |
1223 "Sentinel for compilation buffers." | 1223 "Sentinel for compilation buffers." |
1224 (let ((buffer (process-buffer proc))) | 1224 (if (memq (process-status proc) '(exit signal)) |
1225 (if (memq (process-status proc) '(signal exit)) | 1225 (let ((buffer (process-buffer proc))) |
1226 (progn | 1226 (if (null (buffer-name buffer)) |
1227 (if (null (buffer-name buffer)) | 1227 ;; buffer killed |
1228 ;; buffer killed | 1228 (set-process-buffer proc nil) |
1229 (set-process-buffer proc nil) | 1229 (with-current-buffer buffer |
1230 (with-current-buffer buffer | 1230 ;; Write something in the compilation buffer |
1231 ;; Write something in the compilation buffer | 1231 ;; and hack its mode line. |
1232 ;; and hack its mode line. | 1232 (compilation-handle-exit (process-status proc) |
1233 (compilation-handle-exit (process-status proc) | 1233 (process-exit-status proc) |
1234 (process-exit-status proc) | 1234 msg) |
1235 msg) | 1235 ;; Since the buffer and mode line will show that the |
1236 ;; Since the buffer and mode line will show that the | 1236 ;; process is dead, we can delete it now. Otherwise it |
1237 ;; process is dead, we can delete it now. Otherwise it | 1237 ;; will stay around until M-x list-processes. |
1238 ;; will stay around until M-x list-processes. | 1238 (delete-process proc))) |
1239 (delete-process proc))) | 1239 (setq compilation-in-progress (delq proc compilation-in-progress))))) |
1240 (setq compilation-in-progress (delq proc compilation-in-progress)) | |
1241 )))) | |
1242 | 1240 |
1243 (defun compilation-filter (proc string) | 1241 (defun compilation-filter (proc string) |
1244 "Process filter for compilation buffers. | 1242 "Process filter for compilation buffers. |
1245 Just inserts the text, but uses `insert-before-markers'." | 1243 Just inserts the text, but uses `insert-before-markers'." |
1246 (if (buffer-name (process-buffer proc)) | 1244 (if (buffer-name (process-buffer proc)) |
1291 (unless (or msg ; find message near here | 1289 (unless (or msg ; find message near here |
1292 (setq msg (get-text-property (max (1- pt) (point-min)) | 1290 (setq msg (get-text-property (max (1- pt) (point-min)) |
1293 'message))) | 1291 'message))) |
1294 (setq pt (previous-single-property-change pt 'message nil | 1292 (setq pt (previous-single-property-change pt 'message nil |
1295 (line-beginning-position))) | 1293 (line-beginning-position))) |
1296 (if pt ; FIXME: `pt' can never be nil here anyway. --stef | 1294 (unless (setq msg (get-text-property (max (1- pt) (point-min)) 'message)) |
1297 (setq msg (get-text-property (max (1- pt) (point-min)) 'message)) | |
1298 (setq pt (next-single-property-change pt 'message nil | 1295 (setq pt (next-single-property-change pt 'message nil |
1299 (line-end-position))) | 1296 (line-end-position))) |
1300 (if pt ; FIXME: `pt' can never be nil here anyway. --stef | 1297 (or (setq msg (get-text-property pt 'message)) |
1301 (setq msg (get-text-property pt 'message)) | 1298 (setq pt (point))))) |
1302 (setq pt (point))))) | |
1303 (setq last (nth 2 (car msg))) | 1299 (setq last (nth 2 (car msg))) |
1304 (if (>= n 0) | 1300 (if (>= n 0) |
1305 (compilation-loop > next-single-property-change 1- | 1301 (compilation-loop > next-single-property-change 1- |
1306 (if (get-buffer-process (current-buffer)) | 1302 (if (get-buffer-process (current-buffer)) |
1307 "No more %ss yet" | 1303 "No more %ss yet" |
1360 (let ((buffer (compilation-find-buffer))) | 1356 (let ((buffer (compilation-find-buffer))) |
1361 (if (get-buffer-process buffer) | 1357 (if (get-buffer-process buffer) |
1362 (interrupt-process (get-buffer-process buffer)) | 1358 (interrupt-process (get-buffer-process buffer)) |
1363 (error "The compilation process is not running")))) | 1359 (error "The compilation process is not running")))) |
1364 | 1360 |
1365 (defalias 'compile-mouse-goto-error 'compile-goto-error) | 1361 (defun compile-mouse-goto-error (event) |
1366 | 1362 "Visit the source for the error message the mouse is pointing at." |
1367 (defun compile-goto-error (&optional event) | 1363 (interactive "e") |
1368 "Visit the source for the error message at point. | 1364 (mouse-set-point event) |
1365 (compile-goto-error)) | |
1366 | |
1367 (defun compile-goto-error () | |
1368 "Visit the source for the error message point is on. | |
1369 Use this command in a compilation log buffer. Sets the mark at point there." | 1369 Use this command in a compilation log buffer. Sets the mark at point there." |
1370 (interactive (list last-input-event)) | 1370 (interactive) |
1371 (or (compilation-buffer-p (current-buffer)) | 1371 (or (compilation-buffer-p (current-buffer)) |
1372 (error "Not in a compilation buffer")) | 1372 (error "Not in a compilation buffer")) |
1373 (let* ((loc (event-end event)) | 1373 (if (get-text-property (point) 'directory) |
1374 (pos (posn-point loc))) | 1374 (dired-other-window (car (get-text-property (point) 'directory))) |
1375 (with-selected-window (posn-window loc) | 1375 (push-mark) |
1376 (if (get-text-property pos 'directory) | 1376 (setq compilation-current-error (point)) |
1377 (dired-other-window (car (get-text-property pos 'directory))) | 1377 (next-error 0))) |
1378 (push-mark) | |
1379 (setq compilation-current-error pos) | |
1380 (next-error 0))))) | |
1381 | 1378 |
1382 ;; Return a compilation buffer. | 1379 ;; Return a compilation buffer. |
1383 ;; If the current buffer is a compilation buffer, return it. | 1380 ;; If the current buffer is a compilation buffer, return it. |
1384 ;; If compilation-last-buffer is set to a live buffer, use that. | 1381 ;; If compilation-last-buffer is set to a live buffer, use that. |
1385 ;; Otherwise, look for a compilation buffer and signal an error | 1382 ;; Otherwise, look for a compilation buffer and signal an error |
1435 (loc (compilation-next-error (or n 1) nil | 1432 (loc (compilation-next-error (or n 1) nil |
1436 (or compilation-current-error (point-min)))) | 1433 (or compilation-current-error (point-min)))) |
1437 (end-loc (nth 2 loc)) | 1434 (end-loc (nth 2 loc)) |
1438 (marker (point-marker))) | 1435 (marker (point-marker))) |
1439 (setq compilation-current-error (point-marker) | 1436 (setq compilation-current-error (point-marker) |
1437 overlay-arrow-position | |
1438 (if (bolp) | |
1439 compilation-current-error | |
1440 (save-excursion | |
1441 (beginning-of-line) | |
1442 (point-marker))) | |
1440 loc (car loc)) | 1443 loc (car loc)) |
1441 ;; If loc contains no marker, no error in that file has been visited. If | 1444 ;; If loc contains no marker, no error in that file has been visited. If |
1442 ;; the marker is invalid the buffer has been killed. So, recalculate all | 1445 ;; the marker is invalid the buffer has been killed. So, recalculate all |
1443 ;; markers for that file. | 1446 ;; markers for that file. |
1444 (unless (and (nthcdr 3 loc) (marker-buffer (nth 3 loc))) | 1447 (unless (and (nthcdr 3 loc) (marker-buffer (nth 3 loc))) |
1732 nil) | 1735 nil) |
1733 | 1736 |
1734 (defun compilation-forget-errors () | 1737 (defun compilation-forget-errors () |
1735 ;; In case we hit the same file/line specs, we want to recompute a new | 1738 ;; In case we hit the same file/line specs, we want to recompute a new |
1736 ;; marker for them, so flush our cache. | 1739 ;; marker for them, so flush our cache. |
1737 (set (make-local-variable 'compilation-locs) | 1740 (setq compilation-locs (make-hash-table :test 'equal :weakness 'value)) |
1738 (make-hash-table :test 'equal :weakness 'value)) | |
1739 ;; FIXME: the old code reset the directory-stack, so maybe we should | 1741 ;; FIXME: the old code reset the directory-stack, so maybe we should |
1740 ;; put a `directory change' marker of some sort, but where? -stef | 1742 ;; put a `directory change' marker of some sort, but where? -stef |
1741 ;; | 1743 ;; |
1742 ;; FIXME: The old code moved compilation-current-error (which was | 1744 ;; FIXME: The old code moved compilation-current-error (which was |
1743 ;; virtually represented by a mix of compilation-parsing-end and | 1745 ;; virtually represented by a mix of compilation-parsing-end and |
1744 ;; compilation-error-list) to point-min, but that was only meaningful for | 1746 ;; compilation-error-list) to point-min, but that was only meaningful for |
1745 ;; the internal uses of compilation-forget-errors: all calls from external | 1747 ;; the internal uses of compilation-forget-errors: all calls from external |
1746 ;; packages seem to be followed by a move of compilation-parsing-end to | 1748 ;; packages seem to be followed by a move of compilation-parsing-end to |
1747 ;; something equivalent to point-max. So we speculatively move | 1749 ;; something equivalent to point-max. So we speculatively move |
1748 ;; compilation-current-error to point-max (since the external package | 1750 ;; compilation-current-error to point-max (since the external package |
1749 ;; won't know that it should do it). --stef | 1751 ;; won't know that it should do it). --stef |
1750 (setq compilation-current-error (point-max)) | 1752 (setq compilation-current-error (point-max))) |
1751 ;; FIXME the old code removed the mouse-face and help-echo properties. | |
1752 ;; Should we font-lock-fontify-buffer? --stef | |
1753 ) | |
1754 | 1753 |
1755 (provide 'compile) | 1754 (provide 'compile) |
1756 | 1755 |
1757 ;;; arch-tag: 12465727-7382-4f72-b234-79855a00dd8c | 1756 ;;; arch-tag: 12465727-7382-4f72-b234-79855a00dd8c |
1758 ;;; compile.el ends here | 1757 ;;; compile.el ends here |