"it is superseded by `warning-minimum-log-level.'"
"26.1")
+(defcustom flymake-wrap-around t
+ "If non-nil, moving to errors wraps around buffer boundaries."
+ :group 'flymake :type 'boolean)
+
(defvar-local flymake-timer nil
"Timer for starting syntax check.")
(flymake-mode)
(flymake-log :warning "Turned on in `flymake-find-file-hook'")))
-(defun flymake-goto-next-error (&optional n interactive)
- "Go to next, or Nth next, flymake error in buffer."
- (interactive (list 1 t))
+(defun flymake-goto-next-error (&optional n filter interactive)
+ "Go to Nth next flymake error in buffer matching FILTER.
+FILTER is a list of diagnostic types found in
+`flymake-diagnostic-types-alist', or nil, if no filter is to be
+applied.
+
+Interactively, always goes to the next error. Also
+interactively, FILTER is determined by the prefix arg. With no
+prefix arg, don't use a filter, otherwise only consider
+diagnostics of type `:error' and `:warning'."
+ (interactive (list 1
+ (if current-prefix-arg
+ '(:error :warning))
+ t))
(let* ((n (or n 1))
- (ovs (flymake--overlays :filter 'flymake--diagnostic
+ (ovs (flymake--overlays :filter
+ (lambda (ov)
+ (let ((diag (overlay-get
+ ov
+ 'flymake--diagnostic)))
+ (and diag
+ (or (not filter)
+ (memq (flymake--diag-type diag)
+ filter)))))
:compare (if (cl-plusp n) #'< #'>)
:key #'overlay-start))
- (chain (cl-member-if (lambda (ov)
- (if (cl-plusp n)
- (> (overlay-start ov)
- (point))
- (< (overlay-start ov)
- (point))))
- ovs))
+ (tail (cl-member-if (lambda (ov)
+ (if (cl-plusp n)
+ (> (overlay-start ov)
+ (point))
+ (< (overlay-start ov)
+ (point))))
+ ovs))
+ (chain (if flymake-wrap-around
+ (if tail
+ (progn (setcdr (last tail) ovs) tail)
+ (and ovs (setcdr (last ovs) ovs)))
+ tail))
(target (nth (1- n) chain)))
(cond (target
(goto-char (overlay-start target))
(funcall (overlay-get target 'help-echo)
nil nil (point)))))
(interactive
- (user-error "No more flymake errors")))))
+ (user-error "No more flymake errors%s"
+ (if filter
+ (format " of types %s" filter)
+ ""))))))
+
+(defun flymake-goto-prev-error (&optional n filter interactive)
+ "Go to Nth previous flymake error in buffer matching FILTER.
+FILTER is a list of diagnostic types found in
+`flymake-diagnostic-types-alist', or nil, if no filter is to be
+applied.
+
+Interactively, always goes to the previous error. Also
+interactively, FILTER is determined by the prefix arg. With no
+prefix arg, don't use a filter, otherwise only consider
+diagnostics of type `:error' and `:warning'."
+ (interactive (list 1 (if current-prefix-arg
+ '(:error :warning))
+ t))
+ (flymake-goto-next-error (- (or n 1)) filter interactive))
-(defun flymake-goto-prev-error (&optional n interactive)
- "Go to previous, or Nth previous, flymake error in buffer."
- (interactive (list 1 t))
- (flymake-goto-next-error (- (or n 1)) interactive))
(provide 'flymake)
(should (eq 'flymake-warning (face-at-point)))
(flymake-goto-next-error)
(should (eq 'flymake-error (face-at-point)))
- (should-error (flymake-goto-next-error nil t)) ))
+ (let ((flymake-wrap-around nil))
+ (should-error (flymake-goto-next-error nil nil t))) ))
(defmacro flymake-tests--assert-set (set
should
(should (eq 'flymake-warning (face-at-point))) ; dolor
(flymake-goto-next-error)
(should (eq 'flymake-error (face-at-point))) ; prognata
- (should-error (flymake-goto-next-error nil t))))))
+ (let ((flymake-wrap-around nil))
+ (should-error (flymake-goto-next-error nil nil t)))))))
(provide 'flymake-tests)