[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2b48161 21/3
From: |
João Távora |
Subject: |
[Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2b48161 21/39: Tweak Flymake commands flymake-goto-[next/prev]-error |
Date: |
Mon, 2 Oct 2017 20:12:24 -0400 (EDT) |
branch: scratch/flymake-refactor-cleaner-for-emacs-26
commit 2b48161ff386ce77b0d081565f05f6aebe4957f2
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Tweak Flymake commands flymake-goto-[next/prev]-error
Add filters, useful for backends like the upcoming
flymake-elisp-checkdoc backend, for example, which litters everything
with low-priority notes.
Also re-implement wraparound for flymake-goto-next-error. Manual
mentions this, so it's probably a good idea to keep it. Added a new
customization variable flymake-wrap-around to control it.
* lisp/progmodes/flymake.el (flymake-goto-prev-error)
(flymake-goto-next-error): Accept FILTER argument.
(flymake-wrap-around): New variable.
(flymake-goto-next-error): Wrap around according to flymake-wrap-around.
* test/lisp/progmodes/flymake-tests.el
(different-diagnostic-types, dummy-backends): Pass FILTER to
flymake-goto-prev-error.
(different-diagnostic-types)
(dummy-backends): Use flymake-wrap-around.
---
lisp/progmodes/flymake.el | 74 ++++++++++++++++++++++++++++--------
test/lisp/progmodes/flymake-tests.el | 6 ++-
2 files changed, 62 insertions(+), 18 deletions(-)
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 0de3f75..d394adf 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -112,6 +112,10 @@ See `flymake-error-bitmap' and `flymake-warning-bitmap'."
"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.")
@@ -686,20 +690,44 @@ non-nil."
(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))
@@ -708,12 +736,26 @@ non-nil."
(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)
diff --git a/test/lisp/progmodes/flymake-tests.el
b/test/lisp/progmodes/flymake-tests.el
index 921c2f6..fa77a9a 100644
--- a/test/lisp/progmodes/flymake-tests.el
+++ b/test/lisp/progmodes/flymake-tests.el
@@ -129,7 +129,8 @@ 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)) ))
+ (let ((flymake-wrap-around nil))
+ (should-error (flymake-goto-next-error nil nil t))) ))
(defmacro flymake-tests--assert-set (set
should
@@ -244,7 +245,8 @@ 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))))))
+ (let ((flymake-wrap-around nil))
+ (should-error (flymake-goto-next-error nil nil t)))))))
(provide 'flymake-tests)
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 b17ec76 10/39: Flymake warning face easier to distinguish, (continued)
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 b17ec76 10/39: Flymake warning face easier to distinguish, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 79867d3 06/39: Allow running flymake-tests.el from interactive sessions, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 555bea3 11/39: Protect against timer triggers when no flymake-mode, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 da45044 09/39: Flymake's flymake-proc.el parses column numbers from gcc/javac errors, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 9357120 13/39: Echo Flymake error messages when navigating errors interactively, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 86a4f30 07/39: Refactor flymake-tests.el in preparation for more tests, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 8f50239 12/39: Add a new Flymake test for multiple errors and warnings, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4f7d568 14/39: Flymake checks file names before considering diagnostics, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 0a4e420 16/39: Protect Flymake's eager checks against commands like fill-paragraph, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 c8004c6 03/39: Completely rewrite Flymake's subprocess output processing, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2b48161 21/39: Tweak Flymake commands flymake-goto-[next/prev]-error,
João Távora <=
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2dd9e04 24/39: Add interactive flymake-start function, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 a458e1a 26/39: Treat flymake errors as just another type of diagnostic, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4ae24d7 20/39: Flymake's flymake-proc.el backend slightly easier to debug, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4d6d56d 27/39: Remove old flymake-display-err-menu-for-current-line, it's useless, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 ef67227 29/39: Explicitly add a(n empty) keymap for Flymake, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2b735b4 08/39: New Flymake variable flymake-diagnostic-types-alist and much cleanup, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2971cd0 38/39: Minimal tweak as an attempt to future-proof Flymake API, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 c1661fc 36/39: Hook Flymake onto proper checkdoc and byte-compile interfaces, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 38fdbd6 34/39: Capitalize "Flymake" in docstrings and comments, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 b80d29d 39/39: Start rewriting Flymake manual, João Távora, 2017/10/02