;;; compile.el --- run compiler as inferior of Emacs, parse error messages
-;; Copyright (C) 1985-1987, 1993-1999, 2001-2011
+;; Copyright (C) 1985-1987, 1993-1999, 2001-2012
;; Free Software Foundation, Inc.
;; Authors: Roland McGrath <roland@gnu.org>,
after `call-process' inserts the grep output into the buffer.")
(defvar compilation-filter-start nil
- "Start of the text inserted by `compilation-filter'.
-This is bound to a buffer position before running `compilation-filter-hook'.")
+ "Position of the start of the text inserted by `compilation-filter'.
+This is bound before running `compilation-filter-hook'.")
(defvar compilation-first-column 1
- "*This is how compilers number the first column, usually 1 or 0.")
+ "This is how compilers number the first column, usually 1 or 0.
+If this is buffer-local in the destination buffer, Emacs obeys
+that value, otherwise it uses the value in the *compilation*
+buffer. This enables a major-mode to specify its own value.")
(defvar compilation-parse-errors-filename-function nil
"Function to call to post-process filenames while parsing error messages.
;;;###autoload
(defvar compilation-process-setup-function nil
- "*Function to call to customize the compilation process.
+ "Function to call to customize the compilation process.
This function is called immediately before the compilation process is
started. It can be used to set any variables or functions that are used
while processing the output of the compilation process.")
(python-tracebacks-and-caml
"^[ \t]*File \\(\"?\\)\\([^,\" \n\t<>]+\\)\\1, lines? \\([0-9]+\\)-?\\([0-9]+\\)?\\(?:$\\|,\
-\\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:\\)?\\([ \n]Warning:\\)?\\)"
+\\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:\\)?\\([ \n]Warning\\(?: [0-9]+\\)?:\\)?\\)"
2 (3 . 4) (5 . 6) (7))
(comma
each character occupying one column.
The default is to use screen columns, which requires that the compilation
program and Emacs agree about the display width of the characters,
-especially the TAB character."
+especially the TAB character.
+If this is buffer-local in the destination buffer, Emacs obeys
+that value, otherwise it uses the value in the *compilation*
+buffer. This enables a major-mode to specify its own value."
:type 'boolean
:group 'compilation
:version "20.4")
(defvar compilation-locs ())
(defvar compilation-debug nil
- "*Set this to t before creating a *compilation* buffer.
+ "Set this to t before creating a *compilation* buffer.
Then every error line will have a debug text property with the matcher that
fit this line and the match data. Use `describe-text-properties'.")
;; (make-variable-buffer-local 'compilation-buffer-modtime)
(defvar compilation-skip-to-next-location t
- "*If non-nil, skip multiple error messages for the same source location.")
+ "If non-nil, skip multiple error messages for the same source location.")
(defcustom compilation-skip-threshold 1
"Compilation motion commands skip less important messages.
(setq col (funcall col))
(and
(setq col (match-string-no-properties col))
- (setq col (- (string-to-number col) compilation-first-column)))))
+ (setq col (string-to-number col)))))
(if (and end-col (functionp end-col))
(setq end-col (funcall end-col))
(if (and end-col (setq end-col (match-string-no-properties end-col)))
- (setq end-col (- (string-to-number end-col) compilation-first-column -1))
+ (setq end-col (- (string-to-number end-col) -1))
(if end-line (setq end-col -1))))
(if (consp type) ; not a static type, check what it is.
(setq type (or (and (car type) (match-end (car type)) 1)
"Go to column COL on the current line.
If SCREEN is non-nil, columns are screen columns, otherwise, they are
just char-counts."
+ (setq col (- col compilation-first-column))
(if screen
(move-to-column (max col 0))
(goto-char (min (+ (line-beginning-position) col) (line-end-position)))))
(cadr (compilation--file-struct->loc-tree file-struct)))
(marker
(if marker-line (compilation--loc->marker (cadr marker-line))))
- (compilation-error-screen-columns compilation-error-screen-columns)
+ (screen-columns compilation-error-screen-columns)
+ (first-column compilation-first-column)
end-marker loc end-loc)
(if (not (and marker (marker-buffer marker)))
(setq marker nil) ; no valid marker for this file
- (setq loc (or line 1)) ; normalize no linenumber to line 1
+ (unless line (setq line 1)) ; normalize no linenumber to line 1
(catch 'marker ; find nearest loc, at least one exists
(dolist (x (cddr (compilation--file-struct->loc-tree
file-struct))) ; Loop over remaining lines.
- (if (> (car x) loc) ; still bigger
+ (if (> (car x) line) ; Still bigger.
(setq marker-line x)
- (if (> (- (or (car marker-line) 1) loc)
- (- loc (car x))) ; current line is nearer
+ (if (> (- (or (car marker-line) 1) line)
+ (- line (car x))) ; Current line is nearer.
(setq marker-line x))
(throw 'marker t))))
(setq marker (compilation--loc->marker (cadr marker-line))
marker-line (or (car marker-line) 1))
(with-current-buffer (marker-buffer marker)
- (save-excursion
+ (let ((screen-columns
+ ;; Obey the compilation-error-screen-columns of the target
+ ;; buffer if its major mode set it buffer-locally.
+ (if (local-variable-p 'compilation-error-screen-columns)
+ compilation-error-screen-columns screen-columns))
+ (compilation-first-column
+ (if (local-variable-p 'compilation-first-column)
+ compilation-first-column first-column)))
+ (save-excursion
(save-restriction
(widen)
(goto-char (marker-position marker))
- (when (or end-col end-line)
+ ;; Set end-marker if appropriate and go to line.
+ (if (not (or end-col end-line))
+ (beginning-of-line (- line marker-line -1))
(beginning-of-line (- (or end-line line) marker-line -1))
(if (or (null end-col) (< end-col 0))
(end-of-line)
- (compilation-move-to-column
- end-col compilation-error-screen-columns))
- (setq end-marker (point-marker)))
- (beginning-of-line (if end-line
- (- line end-line -1)
- (- loc marker-line -1)))
+ (compilation-move-to-column end-col screen-columns))
+ (setq end-marker (point-marker))
+ (when end-line (beginning-of-line (- line end-line -1))))
(if col
- (compilation-move-to-column
- col compilation-error-screen-columns)
+ (compilation-move-to-column col screen-columns)
(forward-to-indentation 0))
- (setq marker (point-marker))))))
+ (setq marker (point-marker)))))))
(setq loc (compilation-assq line (compilation--file-struct->loc-tree
file-struct)))
(setq buffer-read-only t)
(run-mode-hooks 'compilation-mode-hook))
+;;;###autoload
+(put 'define-compilation-mode 'doc-string-elt 3)
+
(defmacro define-compilation-mode (mode name doc &rest body)
"This is like `define-derived-mode' without the PARENT argument.
The parent is always `compilation-mode' and the customizable `compilation-...'
(if (or (eq (get-text-property ,limit 'compilation-message)
(get-text-property opt 'compilation-message))
(eq pt opt))
- (error ,error compilation-error)
+ (user-error ,error compilation-error)
(setq pt ,limit)))
;; prop 'compilation-message usually has 2 changes, on and off, so
;; re-search if off
(or (setq msg (get-text-property pt 'compilation-message))
(if (setq pt (,property-change pt 'compilation-message nil ,limit))
(setq msg (get-text-property pt 'compilation-message)))
- (error ,error compilation-error))
+ (user-error ,error compilation-error))
(or (< (compilation--message->type msg) compilation-skip-threshold)
(if different-file
(eq (prog1 last
(interactive "p")
(when reset
(setq compilation-current-error nil))
- (let* ((columns compilation-error-screen-columns) ; buffer's local value
+ (let* ((screen-columns compilation-error-screen-columns)
+ (first-column compilation-first-column)
(last 1)
(msg (compilation-next-error (or n 1) nil
(or compilation-current-error
marker
(caar (compilation--loc->file-struct loc))
(cadr (car (compilation--loc->file-struct loc))))
- (save-restriction
- (widen)
- (goto-char (point-min))
- ;; Treat file's found lines in forward order, 1 by 1.
- (dolist (line (reverse (cddr (compilation--loc->file-struct loc))))
- (when (car line) ; else this is a filename w/o a line#
- (beginning-of-line (- (car line) last -1))
- (setq last (car line)))
- ;; Treat line's found columns and store/update a marker for each.
- (dolist (col (cdr line))
- (if (compilation--loc->col col)
- (if (eq (compilation--loc->col col) -1)
- ;; Special case for range end.
- (end-of-line)
- (compilation-move-to-column (compilation--loc->col col)
- columns))
- (beginning-of-line)
- (skip-chars-forward " \t"))
- (if (compilation--loc->marker col)
- (set-marker (compilation--loc->marker col) (point))
- (setf (compilation--loc->marker col) (point-marker)))
- ;; (setf (compilation--loc->timestamp col) timestamp)
- )))))
+ (let ((screen-columns
+ ;; Obey the compilation-error-screen-columns of the target
+ ;; buffer if its major mode set it buffer-locally.
+ (if (local-variable-p 'compilation-error-screen-columns)
+ compilation-error-screen-columns screen-columns))
+ (compilation-first-column
+ (if (local-variable-p 'compilation-first-column)
+ compilation-first-column first-column)))
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ ;; Treat file's found lines in forward order, 1 by 1.
+ (dolist (line (reverse (cddr (compilation--loc->file-struct loc))))
+ (when (car line) ; else this is a filename w/o a line#
+ (beginning-of-line (- (car line) last -1))
+ (setq last (car line)))
+ ;; Treat line's found columns and store/update a marker for each.
+ (dolist (col (cdr line))
+ (if (compilation--loc->col col)
+ (if (eq (compilation--loc->col col) -1)
+ ;; Special case for range end.
+ (end-of-line)
+ (compilation-move-to-column (compilation--loc->col col)
+ screen-columns))
+ (beginning-of-line)
+ (skip-chars-forward " \t"))
+ (if (compilation--loc->marker col)
+ (set-marker (compilation--loc->marker col) (point))
+ (setf (compilation--loc->marker col) (point-marker)))
+ ;; (setf (compilation--loc->timestamp col) timestamp)
+ ))))))
(compilation-goto-locus marker (compilation--loc->marker loc)
(compilation--loc->marker end-loc))
(setf (compilation--loc->visited loc) t)))
(if (eq v fs) (remhash k compilation-locs)))
compilation-locs)))
-(add-to-list 'debug-ignored-errors "\\`No more [-a-z ]+s yet\\'")
-(add-to-list 'debug-ignored-errors "\\`Moved past last .*")
-
;;; Compatibility with the old compile.el.
(defvaralias 'compilation-last-buffer 'next-error-last-buffer)