Function: compilation-next-error
compilation-next-error is an interactive and byte-compiled function
defined in compile.el.gz.
Signature
(compilation-next-error N &optional DIFFERENT-FILE PT)
Documentation
Move point to the next error in the compilation buffer.
This function does NOT find the source line like C-x ` (next-error),
but you can use M-x compilation-display-error (compilation-display-error) to find and
display the corresponding source code.
Prefix arg N says how many error messages to move forwards (or
backwards, if negative).
Where the current error ends and the next one begins is determined
by the rules from compilation-error-regexp-alist that matched
the compilation messages; this function moves point to where
the \+compilation-message text property changes its value.
In general, all the messages that have the same line and column
numbers are considered parts of a single compilation message.
Optional arg DIFFERENT-FILE, if non-nil, means find next error for a file that is different from the current one. Optional arg PT, if non-nil, specifies the value of point to start looking for the next message. In interacvtive invocations, DIFFERENT-FILE and PT are always nil.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/compile.el.gz
(defun compilation-next-error (n &optional different-file pt)
"Move point to the next error in the compilation buffer.
This function does NOT find the source line like \\[next-error],
but you can use \\[compilation-display-error] to find and
display the corresponding source code.
Prefix arg N says how many error messages to move forwards (or
backwards, if negative).
Where the current error ends and the next one begins is determined
by the rules from `compilation-error-regexp-alist' that matched
the compilation messages; this function moves point to where
the \\+`compilation-message' text property changes its value.
In general, all the messages that have the same line and column
numbers are considered parts of a single compilation message.
Optional arg DIFFERENT-FILE, if non-nil, means find next error for a
file that is different from the current one.
Optional arg PT, if non-nil, specifies the value of point to start
looking for the next message.
In interacvtive invocations, DIFFERENT-FILE and PT are always nil."
(interactive "p")
(or (compilation-buffer-p (current-buffer))
(error "Not in a compilation buffer"))
(or pt (setq pt (point)))
(compilation--ensure-parse pt)
(let* ((msg (get-text-property pt 'compilation-message))
;; `loc', `msg', and `last' are used by the compilation-loop macro.
(loc (and msg (compilation--message->loc msg)))
last)
(if (zerop n)
(unless (or msg ; find message near here
(setq msg (get-text-property (max (1- pt) (point-min))
'compilation-message)))
(setq pt (previous-single-property-change pt 'compilation-message nil
(line-beginning-position)))
(unless (setq msg (get-text-property (max (1- pt) (point-min))
'compilation-message))
(setq pt (compilation-next-single-property-change
pt 'compilation-message nil
(line-end-position)))
(or (setq msg (get-text-property pt 'compilation-message))
(setq pt (point)))))
(setq last (compilation--loc->file-struct loc))
(if (>= n 0)
(compilation-loop > compilation-next-single-property-change 1-
(if (get-buffer-process (current-buffer))
"No more %ss yet"
"Past last %s")
(point-max))
;; Don't move "back" to message at or before point.
;; Pass an explicit (point-min) to make sure pt is non-nil.
(setq pt (previous-single-property-change
pt 'compilation-message nil (point-min)))
(compilation-loop < previous-single-property-change 1+
"Moved back before first %s" (point-min))))
(goto-char pt)
(or msg
(user-error "No %s here" compilation-error))))