aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2018-06-05 17:20:43 +0100
committerJoão Távora2018-06-05 17:36:21 +0100
commit4a51deb993d923767f0eddd4f350e636fe8d7c0b (patch)
tree0e883da5b2bfb30642aacf2dc9a21d0d8090526a
parentfa794d1b603e52e2a80d69c5610b782904ee6a69 (diff)
downloademacs-4a51deb993d923767f0eddd4f350e636fe8d7c0b.tar.gz
emacs-4a51deb993d923767f0eddd4f350e636fe8d7c0b.zip
When navigating Flymake diagnostics, consider their severity
The FILTER arg of flymake-goto-next-error, a list of types, includes every diagnostic with a severity number `eq` to those types. * lisp/progmodes/flymake.el (flymake--severity): New helper. (flymake-goto-next-error, flymake-goto-prev-error): Clarify meaning of FILTER. (flymake-goto-next-error): Interpret filter as a severity filter. (flymake--mode-line-format): Simplify.
-rw-r--r--lisp/progmodes/flymake.el39
1 files changed, 22 insertions, 17 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 27bf1bd17a9..d8959c8356a 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -540,6 +540,11 @@ associated `flymake-category' return DEFAULT."
540 (cadr cat-probe)) 540 (cadr cat-probe))
541 default)))) 541 default))))
542 542
543(defun flymake--severity (type)
544 "Get the severity for diagnostic TYPE."
545 (flymake--lookup-type-property type 'severity
546 (warning-numeric-level :error)))
547
543(defun flymake--fringe-overlay-spec (bitmap &optional recursed) 548(defun flymake--fringe-overlay-spec (bitmap &optional recursed)
544 (if (and (symbolp bitmap) 549 (if (and (symbolp bitmap)
545 (boundp bitmap) 550 (boundp bitmap)
@@ -980,8 +985,9 @@ arg, skip any diagnostics with a severity less than `:warning'.
980If `flymake-wrap-around' is non-nil and no more next diagnostics, 985If `flymake-wrap-around' is non-nil and no more next diagnostics,
981resumes search from top. 986resumes search from top.
982 987
983FILTER is a list of diagnostic types, or nil, if no filter is to 988FILTER is a list of diagnostic types. Only diagnostics with
984be applied." 989matching severities matching are considered. If nil (the
990default) no filter is applied."
985 ;; TODO: let filter be a number, a severity below which diags are 991 ;; TODO: let filter be a number, a severity below which diags are
986 ;; skipped. 992 ;; skipped.
987 (interactive (list 1 993 (interactive (list 1
@@ -995,9 +1001,12 @@ be applied."
995 ov 1001 ov
996 'flymake-diagnostic))) 1002 'flymake-diagnostic)))
997 (and diag 1003 (and diag
998 (or (not filter) 1004 (or
999 (memq (flymake--diag-type diag) 1005 (not filter)
1000 filter))))) 1006 (cl-find
1007 (flymake--severity
1008 (flymake--diag-type diag))
1009 filter :key #'flymake--severity)))))
1001 :compare (if (cl-plusp n) #'< #'>) 1010 :compare (if (cl-plusp n) #'< #'>)
1002 :key #'overlay-start)) 1011 :key #'overlay-start))
1003 (tail (cl-member-if (lambda (ov) 1012 (tail (cl-member-if (lambda (ov)
@@ -1021,10 +1030,10 @@ be applied."
1021 (funcall (overlay-get target 'help-echo) 1030 (funcall (overlay-get target 'help-echo)
1022 (selected-window) target (point))))) 1031 (selected-window) target (point)))))
1023 (interactive 1032 (interactive
1024 (user-error "No more Flymake errors%s" 1033 (user-error "No more Flymake diagnostics%s"
1025 (if filter 1034 (if filter
1026 (format " of types %s" filter) 1035 (format " of %s severity"
1027 "")))))) 1036 (mapconcat #'symbol-name filter ", ")) ""))))))
1028 1037
1029(defun flymake-goto-prev-error (&optional n filter interactive) 1038(defun flymake-goto-prev-error (&optional n filter interactive)
1030 "Go to Nth previous Flymake diagnostic that matches FILTER. 1039 "Go to Nth previous Flymake diagnostic that matches FILTER.
@@ -1035,8 +1044,9 @@ prefix arg, skip any diagnostics with a severity less than
1035If `flymake-wrap-around' is non-nil and no more previous 1044If `flymake-wrap-around' is non-nil and no more previous
1036diagnostics, resumes search from bottom. 1045diagnostics, resumes search from bottom.
1037 1046
1038FILTER is a list of diagnostic types found in, or nil, if no 1047FILTER is a list of diagnostic types. Only diagnostics with
1039filter is to be applied." 1048matching severities matching are considered. If nil (the
1049default) no filter is applied."
1040 (interactive (list 1 (if current-prefix-arg 1050 (interactive (list 1 (if current-prefix-arg
1041 '(:error :warning)) 1051 '(:error :warning))
1042 t)) 1052 t))
@@ -1117,17 +1127,12 @@ filter is to be applied."
1117 ,@(unless (or all-disabled 1127 ,@(unless (or all-disabled
1118 (null known)) 1128 (null known))
1119 (cl-loop 1129 (cl-loop
1120 with get-severity = (lambda (type)
1121 (flymake--lookup-type-property
1122 type
1123 'severity
1124 (warning-numeric-level :error)))
1125 for (type . severity) 1130 for (type . severity)
1126 in (cl-sort (mapcar (lambda (type) 1131 in (cl-sort (mapcar (lambda (type)
1127 (cons type (funcall get-severity type))) 1132 (cons type (flymake--severity type)))
1128 (cl-union (hash-table-keys diags-by-type) 1133 (cl-union (hash-table-keys diags-by-type)
1129 '(:error :warning) 1134 '(:error :warning)
1130 :key get-severity)) 1135 :key #'flymake--severity))
1131 #'> 1136 #'>
1132 :key #'cdr) 1137 :key #'cdr)
1133 for diags = (gethash type diags-by-type) 1138 for diags = (gethash type diags-by-type)