comparison lisp/progmodes/compile.el @ 26222:35c7eab893ab

Checkdoc-inspired fixes.
author Dave Love <fx@gnu.org>
date Wed, 27 Oct 1999 22:38:17 +0000
parents 0f4f299cebb2
children 11ac69b74132
comparison
equal deleted inserted replaced
26221:6e72ffb1b4c4 26222:35c7eab893ab
307 ;; cc-1070 cc: ERROR File = linkl.c, Line = 38 307 ;; cc-1070 cc: ERROR File = linkl.c, Line = 38
308 (".*: ERROR File = \\(.+\\), Line = \\([0-9]+\\)" 1 2) 308 (".*: ERROR File = \\(.+\\), Line = \\([0-9]+\\)" 1 2)
309 (".*: WARNING File = \\(.+\\), Line = \\([0-9]+\\)" 1 2) 309 (".*: WARNING File = \\(.+\\), Line = \\([0-9]+\\)" 1 2)
310 310
311 ;; Sun F90 error messages: 311 ;; Sun F90 error messages:
312 ;; cf90-113 f90comp: ERROR NSE, File = Hoved.f90, Line = 16, Column = 3 312 ;; cf90-113 f90comp: ERROR NSE, File = Hoved.f90, Line = 16, Column = 3
313 (".* ERROR [a-zA-Z0-9 ]+, File = \\(.+\\), Line = \\([0-9]+\\), Column = \\([0-9]+\\)" 313 (".* ERROR [a-zA-Z0-9 ]+, File = \\(.+\\), Line = \\([0-9]+\\), Column = \\([0-9]+\\)"
314 1 2 3) 314 1 2 3)
315 ) 315 )
316 "Alist that specifies how to match errors in compiler output. 316 "Alist that specifies how to match errors in compiler output.
317 Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...]) 317 Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...])
341 ) 341 )
342 "Alist specifying how to match lines that indicate restoring current directory. 342 "Alist specifying how to match lines that indicate restoring current directory.
343 Note that the match is done at the beginning of lines. 343 Note that the match is done at the beginning of lines.
344 Each elt has the form (REGEXP IDX). 344 Each elt has the form (REGEXP IDX).
345 If REGEXP matches, the IDX'th subexpression gives the name of the directory 345 If REGEXP matches, the IDX'th subexpression gives the name of the directory
346 being moved from. If IDX is nil, the last directory entered \(by a line 346 being moved from. If IDX is nil, the last directory entered \(by a line
347 matching `compilation-enter-directory-regexp-alist'\) is assumed. 347 matching `compilation-enter-directory-regexp-alist'\) is assumed.
348 348
349 The default value matches lines printed by the `-w' option of GNU Make.") 349 The default value matches lines printed by the `-w' option of GNU Make.")
350 350
351 (defvar compilation-file-regexp-alist 351 (defvar compilation-file-regexp-alist
355 ("\\w\\w\\w \\w\\w\\w +[0-9]+ [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9] \\(.*\\):$" 1) 355 ("\\w\\w\\w \\w\\w\\w +[0-9]+ [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9] \\(.*\\):$" 1)
356 ) 356 )
357 "Alist specifying how to match lines that indicate a new current file. 357 "Alist specifying how to match lines that indicate a new current file.
358 Note that the match is done at the beginning of lines. 358 Note that the match is done at the beginning of lines.
359 Each elt has the form (REGEXP IDX). 359 Each elt has the form (REGEXP IDX).
360 If REGEXP matches, the IDX'th subexpression gives the file name. This is 360 If REGEXP matches, the IDX'th subexpression gives the file name. This is
361 used with compilers that don't indicate file name in every error message.") 361 used with compilers that don't indicate file name in every error message.")
362 362
363 ;; There is no generally useful regexp that will match non messages, but 363 ;; There is no generally useful regexp that will match non messages, but
364 ;; in special cases there might be one. The lines that are not matched by 364 ;; in special cases there might be one. The lines that are not matched by
365 ;; a regexp take much longer time than the ones that are recognized so if 365 ;; a regexp take much longer time than the ones that are recognized so if
367 (defvar compilation-nomessage-regexp-alist 367 (defvar compilation-nomessage-regexp-alist
368 '( 368 '(
369 ) 369 )
370 "Alist specifying how to match lines that have no message. 370 "Alist specifying how to match lines that have no message.
371 Note that the match is done at the beginning of lines. 371 Note that the match is done at the beginning of lines.
372 Each elt has the form (REGEXP). This alist is by default empty, but if 372 Each elt has the form (REGEXP). This alist is by default empty, but if
373 you have some good regexps here, the parsing of messages will be faster.") 373 you have some good regexps here, the parsing of messages will be faster.")
374 374
375 (defcustom compilation-error-screen-columns t 375 (defcustom compilation-error-screen-columns t
376 "*If non-nil, column numbers in error messages are screen columns. 376 "*If non-nil, column numbers in error messages are screen columns.
377 Otherwise they are interpreted as character positions, with 377 Otherwise they are interpreted as character positions, with
382 :type 'boolean 382 :type 'boolean
383 :group 'compilation 383 :group 'compilation
384 :version "20.4") 384 :version "20.4")
385 385
386 (defcustom compilation-read-command t 386 (defcustom compilation-read-command t
387 "*If not nil, M-x compile reads the compilation command to use. 387 "*Non-nil means \\[compile] reads the compilation command to use.
388 Otherwise, M-x compile just uses the value of `compile-command'." 388 Otherwise, \\[compile] just uses the value of `compile-command'."
389 :type 'boolean 389 :type 'boolean
390 :group 'compilation) 390 :group 'compilation)
391 391
392 ;;;###autoload 392 ;;;###autoload
393 (defcustom compilation-ask-about-save t 393 (defcustom compilation-ask-about-save t
394 "*If not nil, M-x compile asks which buffers to save before compiling. 394 "*Non-nil means \\[compile] asks which buffers to save before compiling.
395 Otherwise, it saves all modified buffers without asking." 395 Otherwise, it saves all modified buffers without asking."
396 :type 'boolean 396 :type 'boolean
397 :group 'compilation) 397 :group 'compilation)
398 398
399 (defvar grep-regexp-alist 399 (defvar grep-regexp-alist
651 (forward-char 1)) 651 (forward-char 1))
652 (point)))))) 652 (point))))))
653 653
654 ;;;###autoload 654 ;;;###autoload
655 (defun grep-find (command-args) 655 (defun grep-find (command-args)
656 "Run grep via find, with user-specified args, and collect output in a buffer. 656 "Run grep via find, with user-specified args COMMAND-ARGS.
657 Collect output in a buffer.
657 While find runs asynchronously, you can use the \\[next-error] command 658 While find runs asynchronously, you can use the \\[next-error] command
658 to find the text that grep hits refer to. 659 to find the text that grep hits refer to.
659 660
660 This command uses a special history list for its arguments, so you can 661 This command uses a special history list for its arguments, so you can
661 easily repeat a find command." 662 easily repeat a find command."
834 (select-window outwin) 835 (select-window outwin)
835 (goto-char (point-max))))) 836 (goto-char (point-max)))))
836 ;; Make it so the next C-x ` will use this buffer. 837 ;; Make it so the next C-x ` will use this buffer.
837 (setq compilation-last-buffer outbuf))) 838 (setq compilation-last-buffer outbuf)))
838 839
839 ;; Set the height of WINDOW according to compilation-window-height.
840 (defun compilation-set-window-height (window) 840 (defun compilation-set-window-height (window)
841 "Set the height of WINDOW according to `compilation-window-height'."
841 (and compilation-window-height 842 (and compilation-window-height
842 (= (window-width window) (frame-width (window-frame window))) 843 (= (window-width window) (frame-width (window-frame window)))
843 ;; If window is alone in its frame, aside from a minibuffer, 844 ;; If window is alone in its frame, aside from a minibuffer,
844 ;; don't change its height. 845 ;; don't change its height.
845 (not (eq window (frame-root-window (window-frame window)))) 846 (not (eq window (frame-root-window (window-frame window))))
945 946
946 (defun compilation-revert-buffer (ignore-auto noconfirm) 947 (defun compilation-revert-buffer (ignore-auto noconfirm)
947 (if (or noconfirm (yes-or-no-p (format "Restart compilation? "))) 948 (if (or noconfirm (yes-or-no-p (format "Restart compilation? ")))
948 (apply 'compile-internal compilation-arguments))) 949 (apply 'compile-internal compilation-arguments)))
949 950
950 ;; Prepare the buffer for the compilation parsing commands to work.
951 (defun compilation-setup () 951 (defun compilation-setup ()
952 "Prepare the buffer for the compilation parsing commands to work."
952 ;; Make the buffer's mode line show process state. 953 ;; Make the buffer's mode line show process state.
953 (setq mode-line-process '(":%s")) 954 (setq mode-line-process '(":%s"))
954 (set (make-local-variable 'compilation-error-list) nil) 955 (set (make-local-variable 'compilation-error-list) nil)
955 (set (make-local-variable 'compilation-old-error-list) nil) 956 (set (make-local-variable 'compilation-old-error-list) nil)
956 (set (make-local-variable 'compilation-parsing-end) (copy-marker 1)) 957 (set (make-local-variable 'compilation-parsing-end) (copy-marker 1))
957 (set (make-local-variable 'compilation-directory-stack) 958 (set (make-local-variable 'compilation-directory-stack)
958 (list default-directory)) 959 (list default-directory))
959 (setq compilation-last-buffer (current-buffer))) 960 (setq compilation-last-buffer (current-buffer)))
960 961
961 (defvar compilation-shell-minor-mode nil 962 (defvar compilation-shell-minor-mode nil
962 "Non-nil when in compilation-shell-minor-mode. 963 "Non-nil when in `compilation-shell-minor-mode'.
963 In this minor mode, all the error-parsing commands of the 964 In this minor mode, all the error-parsing commands of the
964 Compilation major mode are available but bound to keys that don't 965 Compilation major mode are available but bound to keys that don't
965 collide with Shell mode.") 966 collide with Shell mode.")
966 (make-variable-buffer-local 'compilation-shell-minor-mode) 967 (make-variable-buffer-local 'compilation-shell-minor-mode)
967 968
973 (setq minor-mode-map-alist (cons (cons 'compilation-shell-minor-mode 974 (setq minor-mode-map-alist (cons (cons 'compilation-shell-minor-mode
974 compilation-shell-minor-mode-map) 975 compilation-shell-minor-mode-map)
975 minor-mode-map-alist))) 976 minor-mode-map-alist)))
976 977
977 (defvar compilation-minor-mode nil 978 (defvar compilation-minor-mode nil
978 "Non-nil when in compilation-minor-mode. 979 "Non-nil when in `compilation-minor-mode'.
979 In this minor mode, all the error-parsing commands of the 980 In this minor mode, all the error-parsing commands of the
980 Compilation major mode are available.") 981 Compilation major mode are available.")
981 (make-variable-buffer-local 'compilation-minor-mode) 982 (make-variable-buffer-local 'compilation-minor-mode)
982 983
983 (or (assq 'compilation-minor-mode minor-mode-alist) 984 (or (assq 'compilation-minor-mode minor-mode-alist)
1014 (> (prefix-numeric-value arg) 0))) 1015 (> (prefix-numeric-value arg) 0)))
1015 (let ((mode-line-process)) 1016 (let ((mode-line-process))
1016 (compilation-setup) 1017 (compilation-setup)
1017 (run-hooks 'compilation-minor-mode-hook)))) 1018 (run-hooks 'compilation-minor-mode-hook))))
1018 1019
1019 ;; Write msg in the current buffer and hack its mode-line-process.
1020 (defun compilation-handle-exit (process-status exit-status msg) 1020 (defun compilation-handle-exit (process-status exit-status msg)
1021 "Write msg in the current buffer and hack its mode-line-process."
1021 (let ((buffer-read-only nil) 1022 (let ((buffer-read-only nil)
1022 (status (if compilation-exit-message-function 1023 (status (if compilation-exit-message-function
1023 (funcall compilation-exit-message-function 1024 (funcall compilation-exit-message-function
1024 process-status exit-status msg) 1025 process-status exit-status msg)
1025 (cons msg exit-status))) 1026 (cons msg exit-status)))
1096 (run-hooks 'compilation-filter-hook) 1097 (run-hooks 'compilation-filter-hook)
1097 ;; this seems redundant since we insert-before-marks -stefan 1098 ;; this seems redundant since we insert-before-marks -stefan
1098 ;;(set-marker (process-mark proc) (point)) 1099 ;;(set-marker (process-mark proc) (point))
1099 ))))) 1100 )))))
1100 1101
1101 ;; Return the cdr of compilation-old-error-list for the error containing point.
1102 (defun compile-error-at-point () 1102 (defun compile-error-at-point ()
1103 "Return the cdr of `compilation-old-error-list' for error containing point."
1103 (compile-reinitialize-errors nil (point)) 1104 (compile-reinitialize-errors nil (point))
1104 (let ((errors compilation-old-error-list)) 1105 (let ((errors compilation-old-error-list))
1105 (while (and errors 1106 (while (and errors
1106 (> (point) (car (car errors)))) 1107 (> (point) (car (car errors))))
1107 (setq errors (cdr errors))) 1108 (setq errors (cdr errors)))
1113 (or compilation-shell-minor-mode compilation-minor-mode 1114 (or compilation-shell-minor-mode compilation-minor-mode
1114 (eq major-mode 'compilation-mode)))) 1115 (eq major-mode 'compilation-mode))))
1115 1116
1116 (defun compilation-next-error (n) 1117 (defun compilation-next-error (n)
1117 "Move point to the next error in the compilation buffer. 1118 "Move point to the next error in the compilation buffer.
1119 Prefix arg N says how many error messages to move forwards (or
1120 backwards, if negative).
1118 Does NOT find the source line like \\[next-error]." 1121 Does NOT find the source line like \\[next-error]."
1119 (interactive "p") 1122 (interactive "p")
1120 (or (compilation-buffer-p (current-buffer)) 1123 (or (compilation-buffer-p (current-buffer))
1121 (error "Not in a compilation buffer.")) 1124 (error "Not in a compilation buffer"))
1122 (setq compilation-last-buffer (current-buffer)) 1125 (setq compilation-last-buffer (current-buffer))
1123 1126
1124 (let ((errors (compile-error-at-point))) 1127 (let ((errors (compile-error-at-point)))
1125 1128
1126 ;; Move to the error after the one containing point. 1129 ;; Move to the error after the one containing point.
1140 (nth (1- n) compilation-error-list) 1143 (nth (1- n) compilation-error-list)
1141 (error "Moved past last error")))))))) 1144 (error "Moved past last error"))))))))
1142 1145
1143 (defun compilation-previous-error (n) 1146 (defun compilation-previous-error (n)
1144 "Move point to the previous error in the compilation buffer. 1147 "Move point to the previous error in the compilation buffer.
1148 Prefix arg N says how many error messages to move backwards (or
1149 forwards, if negative).
1145 Does NOT find the source line like \\[next-error]." 1150 Does NOT find the source line like \\[next-error]."
1146 (interactive "p") 1151 (interactive "p")
1147 (compilation-next-error (- n))) 1152 (compilation-next-error (- n)))
1148 1153
1149 1154
1166 1171
1167 (defun compilation-next-file (n) 1172 (defun compilation-next-file (n)
1168 "Move point to the next error for a different file than the current one." 1173 "Move point to the next error for a different file than the current one."
1169 (interactive "p") 1174 (interactive "p")
1170 (or (compilation-buffer-p (current-buffer)) 1175 (or (compilation-buffer-p (current-buffer))
1171 (error "Not in a compilation buffer.")) 1176 (error "Not in a compilation buffer"))
1172 (setq compilation-last-buffer (current-buffer)) 1177 (setq compilation-last-buffer (current-buffer))
1173 1178
1174 (let ((reversed (< n 0)) 1179 (let ((reversed (< n 0))
1175 errors filedata) 1180 errors filedata)
1176 1181
1230 "Kill the process made by the \\[compile] command." 1235 "Kill the process made by the \\[compile] command."
1231 (interactive) 1236 (interactive)
1232 (let ((buffer (compilation-find-buffer))) 1237 (let ((buffer (compilation-find-buffer)))
1233 (if (get-buffer-process buffer) 1238 (if (get-buffer-process buffer)
1234 (interrupt-process (get-buffer-process buffer)) 1239 (interrupt-process (get-buffer-process buffer))
1235 (error "The compilation process is not running.")))) 1240 (error "The compilation process is not running"))))
1236 1241
1237 1242
1238 ;; Parse any new errors in the compilation buffer, 1243 ;; Parse any new errors in the compilation buffer,
1239 ;; or reparse from the beginning if the user has asked for that. 1244 ;; or reparse from the beginning if the user has asked for that.
1240 (defun compile-reinitialize-errors (reparse 1245 (defun compile-reinitialize-errors (reparse
1302 (save-excursion 1307 (save-excursion
1303 (set-buffer (window-buffer (posn-window (event-end event)))) 1308 (set-buffer (window-buffer (posn-window (event-end event))))
1304 (goto-char (posn-point (event-end event))) 1309 (goto-char (posn-point (event-end event)))
1305 1310
1306 (or (compilation-buffer-p (current-buffer)) 1311 (or (compilation-buffer-p (current-buffer))
1307 (error "Not in a compilation buffer.")) 1312 (error "Not in a compilation buffer"))
1308 (setq compilation-last-buffer (current-buffer)) 1313 (setq compilation-last-buffer (current-buffer))
1309 ;; `compile-reinitialize-errors' needs to see the complete filename 1314 ;; `compile-reinitialize-errors' needs to see the complete filename
1310 ;; on the line where they clicked the mouse. Since it only looks 1315 ;; on the line where they clicked the mouse. Since it only looks
1311 ;; up to point, moving point to eol makes sure the filename is 1316 ;; up to point, moving point to eol makes sure the filename is
1312 ;; visible to `compile-reinitialize-errors'. 1317 ;; visible to `compile-reinitialize-errors'.
1338 Use this command in a compilation log buffer. Sets the mark at point there. 1343 Use this command in a compilation log buffer. Sets the mark at point there.
1339 \\[universal-argument] as a prefix arg means to reparse the buffer's error messages first; 1344 \\[universal-argument] as a prefix arg means to reparse the buffer's error messages first;
1340 other kinds of prefix arguments are ignored." 1345 other kinds of prefix arguments are ignored."
1341 (interactive "P") 1346 (interactive "P")
1342 (or (compilation-buffer-p (current-buffer)) 1347 (or (compilation-buffer-p (current-buffer))
1343 (error "Not in a compilation buffer.")) 1348 (error "Not in a compilation buffer"))
1344 (setq compilation-last-buffer (current-buffer)) 1349 (setq compilation-last-buffer (current-buffer))
1345 (compile-reinitialize-errors (consp argp) (point)) 1350 (compile-reinitialize-errors (consp argp) (point))
1346 1351
1347 ;; Move to bol; the marker for the error on this line will point there. 1352 ;; Move to bol; the marker for the error on this line will point there.
1348 (beginning-of-line) 1353 (beginning-of-line)
1630 (display-buffer (marker-buffer (car next-error)))))) 1635 (display-buffer (marker-buffer (car next-error))))))
1631 (set-window-point w (car next-error)) 1636 (set-window-point w (car next-error))
1632 (set-window-start w (car next-error)) 1637 (set-window-start w (car next-error))
1633 (compilation-set-window-height w))) 1638 (compilation-set-window-height w)))
1634 1639
1635 ;; Find a buffer for file FILENAME.
1636 ;; Search the directories in compilation-search-path.
1637 ;; A nil in compilation-search-path means to try the
1638 ;; current directory, which is passed in DIR.
1639 ;; If FILENAME is not found at all, ask the user where to find it.
1640 ;; Pop up the buffer containing MARKER and scroll to MARKER if we ask the user.
1641 (defun compilation-find-file (marker filename dir &rest formats) 1640 (defun compilation-find-file (marker filename dir &rest formats)
1641 "Find a buffer for file FILENAME.
1642 Search the directories in compilation-search-path.
1643 A nil in compilation-search-path means to try the
1644 current directory, which is passed in DIR.
1645 If FILENAME is not found at all, ask the user where to find it.
1646 Pop up the buffer containing MARKER and scroll to MARKER if we ask the user."
1642 (or formats (setq formats '("%s"))) 1647 (or formats (setq formats '("%s")))
1643 (let ((dirs compilation-search-path) 1648 (let ((dirs compilation-search-path)
1644 buffer thisdir fmts name) 1649 buffer thisdir fmts name)
1645 (if (file-name-absolute-p filename) 1650 (if (file-name-absolute-p filename)
1646 ;; The file name is absolute. Use its explicit directory as 1651 ;; The file name is absolute. Use its explicit directory as
1726 ;; so bump our counter. 1731 ;; so bump our counter.
1727 (setq groupings (1+ groupings)))))))) 1732 (setq groupings (1+ groupings))))))))
1728 groupings)) 1733 groupings))
1729 1734
1730 (defvar compilation-current-file nil 1735 (defvar compilation-current-file nil
1731 "Used by compilation-parse-errors to store filename for file being compiled") 1736 "Used by `compilation-parse-errors' to store filename for file being compiled.")
1732 1737
1733 ;; This variable is not used as a global variable. It's defined here just to 1738 ;; This variable is not used as a global variable. It's defined here just to
1734 ;; shut up the byte compiler. It's bound and used by compilation-parse-errors 1739 ;; shut up the byte compiler. It's bound and used by compilation-parse-errors
1735 ;; and set by compile-collect-regexps. 1740 ;; and set by compile-collect-regexps.
1736 (defvar compilation-regexps nil) 1741 (defvar compilation-regexps nil)
1813 ;; Check that we have a file name. 1818 ;; Check that we have a file name.
1814 (or filename 1819 (or filename
1815 ;; No file name in message, we must have seen it before 1820 ;; No file name in message, we must have seen it before
1816 (setq filename compilation-current-file) 1821 (setq filename compilation-current-file)
1817 (error "\ 1822 (error "\
1818 An error message with no file name and no file name has been seen earlier.")) 1823 An error message with no file name and no file name has been seen earlier"))
1819 1824
1820 ;; Check for a comint-file-name-prefix and prepend it if 1825 ;; Check for a comint-file-name-prefix and prepend it if
1821 ;; appropriate. (This is very useful for 1826 ;; appropriate. (This is very useful for
1822 ;; compilation-minor-mode in an rlogin-mode buffer.) 1827 ;; compilation-minor-mode in an rlogin-mode buffer.)
1823 (and (boundp 'comint-file-name-prefix) 1828 (and (boundp 'comint-file-name-prefix)
1968 (cons (cons (car (car this)) (cons type (cdr (car this)))) 1973 (cons (cons (car (car this)) (cons type (cdr (car this))))
1969 compilation-regexps)) 1974 compilation-regexps))
1970 (setq this (cdr this))))) 1975 (setq this (cdr this)))))
1971 1976
1972 (defun compile-buffer-substring (index) 1977 (defun compile-buffer-substring (index)
1973 ;; Get substring matched by INDEXth subexpression. 1978 "Get substring matched by INDEXth subexpression."
1974 (if index 1979 (if index
1975 (let ((beg (match-beginning index))) 1980 (let ((beg (match-beginning index)))
1976 (if beg (buffer-substring beg (match-end index)))))) 1981 (if beg (buffer-substring beg (match-end index))))))
1977 1982
1978 ;; If directory DIR is a subdir of ORIG or of ORIG's parent, 1983 ;; If directory DIR is a subdir of ORIG or of ORIG's parent,