changeset 4576:fb0a5397e223

(next-error): Handle zero and negative prefix args.
author Roland McGrath <roland@gnu.org>
date Wed, 11 Aug 1993 21:26:38 +0000
parents bf0f07186369
children c071de572565
files lisp/progmodes/compile.el
diffstat 1 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/compile.el	Wed Aug 11 21:10:44 1993 +0000
+++ b/lisp/progmodes/compile.el	Wed Aug 11 21:26:38 1993 +0000
@@ -664,7 +664,7 @@
 
   (next-error 1))
 
-(defun compilation-buffer-p (buffer)
+(defsubst compilation-buffer-p (buffer)
   (assq 'compilation-error-list (buffer-local-variables buffer)))
 
 ;; Return a compilation buffer.
@@ -724,7 +724,9 @@
 			       ;; We want to pass a number here only if
 			       ;; we got a numeric prefix arg, not just C-u.
 			       (and (not (consp argp))
-				    (1- (prefix-numeric-value 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.
@@ -735,8 +737,21 @@
     (save-excursion
       (set-buffer compilation-last-buffer)
       ;; compilation-error-list points to the "current" error.
-      (setq next-errors (nthcdr (1- (prefix-numeric-value argp))
-				compilation-error-list)
+      (setq next-errors 
+	    (if (> (prefix-numeric-value argp) 0)
+		(nthcdr (1- (prefix-numeric-value argp))
+			compilation-error-list)
+	      ;; Zero or negative arg; we need to move back in the list.
+	      (let ((n (1- (prefix-numeric-value argp)))
+		    (i 0)
+		    (e compilation-old-error-list))
+		;; See how many cdrs away the current error is from the start.
+		(while (not (eq e compilation-error-list))
+		  (setq i (1+ i)
+			e (cdr e)))
+		(if (> (- n) i)
+		    (error "Moved back past first error")
+		  (nthcdr (+ i n) compilation-old-error-list))))
 	    next-error (car next-errors))
       (while
 	  (progn