1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-10 09:12:15 +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, ;; Parse any new errors in the compilation buffer,
;; or reparse from the beginning if the user has asked for that. ;; 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 (save-excursion
(set-buffer compilation-last-buffer) (set-buffer compilation-last-buffer)
;; If we are out of errors, or if user says "reparse", ;; If we are out of errors, or if user says "reparse",
;; discard the info we have, to force reparsing. ;; discard the info we have, to force reparsing.
(if (or (eq compilation-error-list t) (if (or (eq compilation-error-list t)
(consp argp)) reparse)
(compilation-forget-errors)) (compilation-forget-errors))
(if (and compilation-error-list (if (and compilation-error-list
(or (not limit-search) (or (not limit-search)
@ -686,7 +687,7 @@ other kinds of prefix arguments are ignored."
(or (compilation-buffer-p (current-buffer)) (or (compilation-buffer-p (current-buffer))
(error "Not in a compilation buffer.")) (error "Not in a compilation buffer."))
(setq compilation-last-buffer (current-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. ;; Move to bol; the marker for the error on this line will point there.
(beginning-of-line) (beginning-of-line)
@ -763,29 +764,43 @@ See variables `compilation-parse-errors-function' and
\`compilation-error-regexp-alist' for customization ideas." \`compilation-error-regexp-alist' for customization ideas."
(interactive "P") (interactive "P")
(setq compilation-last-buffer (compilation-find-buffer)) (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 want to pass a number here only if
;; we got a numeric prefix arg, not just C-u. ;; we got a numeric prefix arg, not just C-u.
(and (not (consp argp)) (and (not (consp argp))
(if (< (prefix-numeric-value argp) 1) (prefix-numeric-value argp))
0 (consp argp))))
(1- (prefix-numeric-value argp))))) ;;;###autoload (define-key ctl-x-map "`" 'next-error)
;; Make ARGP nil if the prefix arg was just C-u,
;; since that means to reparse the errors, which the (defun compilation-next-error-locus (&optional move reparse)
;; compile-reinitialize-errors call just did. "Visit next compilation error and return locus in corresponding source code.
;; Now we are only interested in a numeric prefix arg. This operates on the output from the \\[compile] command.
(if (consp argp) If all preparsed error messages have been processed,
(setq argp nil)) 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) (let (next-errors next-error)
(save-excursion (save-excursion
(set-buffer compilation-last-buffer) (set-buffer compilation-last-buffer)
;; compilation-error-list points to the "current" error. ;; compilation-error-list points to the "current" error.
(setq next-errors (setq next-errors
(if (> (prefix-numeric-value argp) 0) (if (> move 0)
(nthcdr (1- (prefix-numeric-value argp)) (nthcdr (1- move)
compilation-error-list) compilation-error-list)
;; Zero or negative arg; we need to move back in the 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) (i 0)
(e compilation-old-error-list)) (e compilation-old-error-list))
;; See how many cdrs away the current error is from the start. ;; 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)))) (nthcdr (+ i n) compilation-old-error-list))))
next-error (car next-errors)) next-error (car next-errors))
(while (while
(progn
(if (null next-error) (if (null next-error)
(progn (progn
(if argp (if (> (prefix-numeric-value argp) 0) (if move (if (> move 0)
(error "Moved past last error") (error "Moved past last error")
(error "Moved back past first error"))) (error "Moved back past first error")))
(compilation-forget-errors) (compilation-forget-errors)
@ -878,9 +892,10 @@ See variables `compilation-parse-errors-function' and
(setq last-line this) (setq last-line this)
(setcdr (car errors) (point-marker)))) (setcdr (car errors) (point-marker))))
(setq errors (cdr errors))))))))) (setq errors (cdr errors)))))))))
;; If we didn't get a marker for this error, ;; If we didn't get a marker for this error, or this
;; go on to the next one. ;; marker's buffer was killed, go on to the next one.
(not (markerp (cdr next-error)))))) (or (not (markerp (cdr next-error)))
(not (marker-buffer (cdr next-error))))))
(setq next-errors compilation-error-list (setq next-errors compilation-error-list
next-error (car next-errors)))) 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))) (equal (cdr (car compilation-error-list)) (cdr next-error)))
(setq compilation-error-list (cdr compilation-error-list))) (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))) (switch-to-buffer (marker-buffer (cdr next-error)))
(goto-char (cdr next-error)) (goto-char (cdr next-error))
;; If narrowing got in the way of ;; If narrowing got in the way of
@ -904,10 +926,8 @@ See variables `compilation-parse-errors-function' and
(let* ((pop-up-windows t) (let* ((pop-up-windows t)
(w (display-buffer (marker-buffer (car next-error))))) (w (display-buffer (marker-buffer (car next-error)))))
(set-window-point w (car next-error)) (set-window-point w (car next-error))
(set-window-start w (car next-error))))) (set-window-start w (car next-error))))
;;;###autoload (define-key ctl-x-map "`" 'next-error)
;; Find a buffer for file FILENAME. ;; Find a buffer for file FILENAME.
;; Search the directories in compilation-search-path. ;; Search the directories in compilation-search-path.
;; A nil in compilation-search-path means to try the ;; A nil in compilation-search-path means to try the