[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/flymake-refactor 4fea8a9 30/52: Allow filtering in
From: |
João Távora |
Subject: |
[Emacs-diffs] scratch/flymake-refactor 4fea8a9 30/52: Allow filtering in flymake-goto-[next/prev]-error |
Date: |
Sun, 1 Oct 2017 12:40:48 -0400 (EDT) |
branch: scratch/flymake-refactor
commit 4fea8a94f82ff659dfedf62d39c782ac28719618
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Allow filtering in flymake-goto-[next/prev]-error
It's useful for backends like the upcoming flymake-elisp-checkdoc
backend, for example, which litters everything with low-priority notes.
* lisp/progmodes/flymake-ui.el (flymake-goto-prev-error)
(flymake-goto-next-error): Accept FILTER argument.
* test/lisp/progmodes/flymake-tests.el
(different-diagnostic-types, dummy-backends): Pass FILTER to
flymake-goto-prev-error.
---
lisp/progmodes/flymake-ui.el | 51 +++++++++++++++++++++++++++++-------
test/lisp/progmodes/flymake-tests.el | 4 +--
2 files changed, 44 insertions(+), 11 deletions(-)
diff --git a/lisp/progmodes/flymake-ui.el b/lisp/progmodes/flymake-ui.el
index cd5ffe3..bd46fcf 100644
--- a/lisp/progmodes/flymake-ui.el
+++ b/lisp/progmodes/flymake-ui.el
@@ -642,11 +642,30 @@ sources."
(flymake-mode)
(flymake-log 3 "automatically turned ON")))
-(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)
@@ -664,12 +683,26 @@ sources."
(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-ui)
;;; flymake-ui.el ends here
diff --git a/test/lisp/progmodes/flymake-tests.el
b/test/lisp/progmodes/flymake-tests.el
index 521d045..494d1c9 100644
--- a/test/lisp/progmodes/flymake-tests.el
+++ b/test/lisp/progmodes/flymake-tests.el
@@ -128,7 +128,7 @@ SEVERITY-PREDICATE is used to setup
(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)) ))
+ (should-error (flymake-goto-next-error nil nil t)) ))
(defmacro flymake-tests--assert-set (set
should
@@ -243,7 +243,7 @@ SEVERITY-PREDICATE is used to setup
(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))))))
+ (should-error (flymake-goto-next-error nil nil t))))))
(provide 'flymake-tests)
- [Emacs-diffs] scratch/flymake-refactor 14db516 22/52: flymake-ui.el checks file names before considering diagnostics, (continued)
- [Emacs-diffs] scratch/flymake-refactor 14db516 22/52: flymake-ui.el checks file names before considering diagnostics, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 61ba20b 21/52: Echo flymake error messages when navigating errors interactively, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor b2c4135 15/52: Clarify logic around flymake-diagnostic-types-alist, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor bac7512 12/52: New flymake-diagnostic-types-alist and more cleanup, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 7140018 25/52: Protect flymake-ui against commands like fill-paragraph, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor d3168cf 09/52: Make lisp/progmodes/flymake-ui.el some 150 lines lighter, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor f3b8a72 20/52: Refactor flymake-tests.el in preparation for more tests, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 593d4303 23/52: Add a new flymake test for multiple errors and warnings, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor d68448f 26/52: More cleanup before advancing to backend redesign, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 245114e 33/52: Fix autoload conflict between flymake.el and flymake-ui.el, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 4fea8a9 30/52: Allow filtering in flymake-goto-[next/prev]-error,
João Távora <=
- [Emacs-diffs] scratch/flymake-refactor 192cb7f 24/52: flymake-ui.el highlights GCC notes detected by flymake-proc.el, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 879dcef 29/52: Misc cleanup in flymake-proc.el, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 820b460 35/52: Add interactive flymake-start function, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 8e42a5d 31/52: Cleanup some flymake-ui.el internals, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor e1b913f 36/52: Re-implement wraparound for flymake-goto-next-error, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 3dfe11c 28/52: Simplify flymake logging and erroring., João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 9329265 40/52: Treat flymake errors as just another type of diagnostic, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 38c7d4f 41/52: Remove old flymake-display-err-menu-for-current-line, it's useless, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 7a22358 34/52: A couple of new flymake backends for emacs-lisp-mode, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 9d93d46 42/52: New flymake fringe bitmaps, João Távora, 2017/10/01