1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-30 08:09:04 +00:00

(compile-reinitialize-errors): Rename first arg from ARGP to REPARSE.

Test only its nilness.
(compile-goto-error): Pass (consp ARGP) to compile-reinitialize-errors
instead of ARGP itself.
(next-error): Code broken out into two new functions; call them.
(compilation-next-error-locus): New function; bulk of code from next-error.
Silently skip errors whose source loci are markers in killed buffers.
(compilation-goto-locus): New function, final code from next-error.
This commit is contained in:
Roland McGrath 1994-03-07 22:31:48 +00:00
parent acdf173af7
commit eaa3cac5f4

View File

@ -633,13 +633,14 @@ Does NOT find the source line like \\[next-error]."
;; Parse any new errors in the compilation buffer,
;; or reparse from the beginning if the user has asked for that.
(defun compile-reinitialize-errors (argp &optional limit-search find-at-least)
(defun compile-reinitialize-errors (reparse
&optional limit-search find-at-least)
(save-excursion
(set-buffer compilation-last-buffer)
;; If we are out of errors, or if user says "reparse",
;; discard the info we have, to force reparsing.
(if (or (eq compilation-error-list t)
(consp argp))
reparse)
(compilation-forget-errors))
(if (and compilation-error-list
(or (not limit-search)
@ -686,7 +687,7 @@ other kinds of prefix arguments are ignored."
(or (compilation-buffer-p (current-buffer))
(error "Not in a compilation buffer."))
(setq compilation-last-buffer (current-buffer))
(compile-reinitialize-errors argp (point))
(compile-reinitialize-errors (consp argp) (point))
;; Move to bol; the marker for the error on this line will point there.
(beginning-of-line)
@ -763,29 +764,43 @@ See variables `compilation-parse-errors-function' and
\`compilation-error-regexp-alist' for customization ideas."
(interactive "P")
(setq compilation-last-buffer (compilation-find-buffer))
(compile-reinitialize-errors argp nil
(compilation-goto-locus (compilation-next-error-locus
;; We want to pass a number here only if
;; we got a numeric prefix arg, not just C-u.
(and (not (consp argp))
(if (< (prefix-numeric-value argp) 1)
0
(1- (prefix-numeric-value argp)))))
;; Make ARGP nil if the prefix arg was just C-u,
;; since that means to reparse the errors, which the
;; compile-reinitialize-errors call just did.
;; Now we are only interested in a numeric prefix arg.
(if (consp argp)
(setq argp nil))
(prefix-numeric-value argp))
(consp argp))))
;;;###autoload (define-key ctl-x-map "`" 'next-error)
(defun compilation-next-error-locus (&optional move reparse)
"Visit next compilation error and return locus in corresponding source code.
This operates on the output from the \\[compile] command.
If all preparsed error messages have been processed,
the error message buffer is checked for new ones.
Returns a cons (ERROR . SOURCE) of two markers: ERROR is a marker at the
location of the error message in the compilation buffer, and SOURCE is a
marker at the location in the source code indicated by the error message.
Optional first arg MOVE says how many error messages to move forwards (or
backwards, if negative); default is 1. Optional second arg REPARSE, if
non-nil, says to reparse the error message buffer and reset to the first
error (plus MOVE - 1).
The current buffer should be the desired compilation output buffer."
(or move (setq move 1))
(compile-reinitialize-errors reparse nil (and (not reparse)
(if (< move 1) 0 (1- move))))
(let (next-errors next-error)
(save-excursion
(set-buffer compilation-last-buffer)
;; compilation-error-list points to the "current" error.
(setq next-errors
(if (> (prefix-numeric-value argp) 0)
(nthcdr (1- (prefix-numeric-value argp))
(if (> move 0)
(nthcdr (1- move)
compilation-error-list)
;; Zero or negative arg; we need to move back in the list.
(let ((n (1- (prefix-numeric-value argp)))
(let ((n (1- move))
(i 0)
(e compilation-old-error-list))
;; See how many cdrs away the current error is from the start.
@ -797,10 +812,9 @@ See variables `compilation-parse-errors-function' and
(nthcdr (+ i n) compilation-old-error-list))))
next-error (car next-errors))
(while
(progn
(if (null next-error)
(progn
(if argp (if (> (prefix-numeric-value argp) 0)
(if move (if (> move 0)
(error "Moved past last error")
(error "Moved back past first error")))
(compilation-forget-errors)
@ -878,9 +892,10 @@ See variables `compilation-parse-errors-function' and
(setq last-line this)
(setcdr (car errors) (point-marker))))
(setq errors (cdr errors)))))))))
;; If we didn't get a marker for this error,
;; go on to the next one.
(not (markerp (cdr next-error))))))
;; If we didn't get a marker for this error, or this
;; marker's buffer was killed, go on to the next one.
(or (not (markerp (cdr next-error)))
(not (marker-buffer (cdr next-error))))))
(setq next-errors compilation-error-list
next-error (car next-errors))))
@ -890,7 +905,14 @@ See variables `compilation-parse-errors-function' and
(equal (cdr (car compilation-error-list)) (cdr next-error)))
(setq compilation-error-list (cdr compilation-error-list)))
;; We now have a marker for the position of the error.
;; We now have a marker for the position of the error source code.
;; NEXT-ERROR is a cons (ERROR . SOURCE) of two markers.
next-error))
(defun compilation-goto-locus (next-error)
"Jump to an error locus returned by `compilation-next-error-locus'.
Takes one argument, a cons (ERROR . SOURCE) of two markers.
Selects a window with point at SOURCE, with another window displaying ERROR."
(switch-to-buffer (marker-buffer (cdr next-error)))
(goto-char (cdr next-error))
;; If narrowing got in the way of
@ -904,10 +926,8 @@ See variables `compilation-parse-errors-function' and
(let* ((pop-up-windows t)
(w (display-buffer (marker-buffer (car next-error)))))
(set-window-point w (car next-error))
(set-window-start w (car next-error)))))
;;;###autoload (define-key ctl-x-map "`" 'next-error)
(set-window-start w (car next-error))))
;; Find a buffer for file FILENAME.
;; Search the directories in compilation-search-path.
;; A nil in compilation-search-path means to try the