branch: elpa/flycheck
commit 4dd5b394c417b513cdbdd7355b3e5a7f71d3f2b9
Author: JohnC32 <[email protected]>
Commit: GitHub <[email protected]>
Add FlyC:0 and updated the mode menu (#2035)
1. Add FlyC
The existing 'FlyC' mode line indicator had two meanings
- current buffer has not been checked, or
- last check resulted in no warnings and no errors
and the manual indicated that it was the later which I found confusing.
This commit, defines:
FlyC This buffer has not been checked yet.
FlyC:0 Last check resulted and no errors and no warnings.
Also add colors to the mode line status indicator:
- FlyC:0 use 'success face
- FlyC:3|5 use 'error face
- FlyC! use 'error face
Note: The :0 is configurable and can be changed via
`flycheck-mode-success-indicator'.
2. Update the mode menu to add
- "Run checker as compile command" which is `flycheck-compile'.
This is helpful for multiline errors coming from compilers such as
clang.
Also updated the `flycheck-compile' prompt to show the default checker
when
there is one because typing only RET will run the default checker.
- "Flycheck quick help" which runs new sub, `flycheck-quick-help' and
displays
what the mode line indicators mean along with some of the more common
key bindings.
---
CHANGES.rst | 1 +
doc/user/error-reports.rst | 6 ++-
flycheck.el | 101 +++++++++++++++++++++++++++++++++++--------
test/specs/test-mode-line.el | 4 +-
4 files changed, 91 insertions(+), 21 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 5f82d5ddd4..c1f8e420f1 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -7,6 +7,7 @@ New Features
- [#1975]: Add support for ``--expt-relaxed-constexpr`` flag to ``cuda``
checker.
- [#2055]: Add support for ``--expt-extended-lambda`` flag to ``cuda`` checker.
+- [#2035]: Added colors to FlyC mode line and updated mode line menu.
- [#2059]: Enable checkers for new AUCTeX 14 modes.
-----------
diff --git a/doc/user/error-reports.rst b/doc/user/error-reports.rst
index 46fbf2c2be..8052944d42 100644
--- a/doc/user/error-reports.rst
+++ b/doc/user/error-reports.rst
@@ -240,10 +240,12 @@ Like all minor modes Flycheck also has a mode line
indicator. You can see it in
the bottom right corner of the above screenshot. By default the indicator
shows
Flycheck’s current state via one of the following texts:
++-------------+----------------------------------------------------------------+
+|``FlyC`` |Current buffer has not been checked.
|
+-------------+----------------------------------------------------------------+
|``FlyC*`` |Flycheck is checking the buffer currently.
|
+-------------+----------------------------------------------------------------+
-|``FlyC`` |There are no errors or warnings in the current buffer.
|
+|``FlyC:0`` |Last check resulted in no errors and no warnings.
|
+-------------+----------------------------------------------------------------+
|``FlyC:3/5`` |There are three errors and five warnings in the current buffer.
|
+-------------+----------------------------------------------------------------+
@@ -256,6 +258,8 @@ Flycheck’s current state via one of the following texts:
| |look for error messages, and consider :ref:`reporting a bug
|
| |<flycheck-bug-reports>`.
|
+-------------+----------------------------------------------------------------+
+|``FlyC.`` |The last syntax check was manually interrupted.
|
++-------------+----------------------------------------------------------------+
|``FlyC?`` |The last syntax check had a dubious result. The definition of
a|
| |syntax checker may have a bug. Inspect the ``*Messages*``
|
| |buffer and consider :ref:`reporting a bug
|
diff --git a/flycheck.el b/flycheck.el
index 9f5d1eaa82..e8b22235df 100644
--- a/flycheck.el
+++ b/flycheck.el
@@ -1123,6 +1123,12 @@ Set this variable to nil to disable the mode line
completely."
:risky t
:package-version '(flycheck . "0.20"))
+(defcustom flycheck-mode-line-color t
+ "Use colors for Flycheck mode line status."
+ :group 'flycheck
+ :type 'boolean
+ :package-version '(flycheck . "35"))
+
(defcustom flycheck-mode-line-prefix "FlyC"
"Base mode line lighter for Flycheck.
@@ -1135,6 +1141,12 @@ function must be updated to use this variable."
:type 'string
:package-version '(flycheck . "26"))
+(defcustom flycheck-mode-success-indicator ":0"
+ "Success indicator appended to `flycheck-mode-line-prefix'."
+ :group 'flycheck
+ :type 'string
+ :package-version '(flycheck . "35"))
+
(defcustom flycheck-error-list-mode-line
`(,(propertized-buffer-identification "%12b")
" for buffer "
@@ -1209,6 +1221,7 @@ Only has effect when variable `global-flycheck-mode' is
non-nil."
flycheck-checkers))]
["Check current buffer" flycheck-buffer flycheck-mode]
["Clear errors in buffer" flycheck-clear t]
+ ["Run checker as compile command" flycheck-compile flycheck-mode]
"---"
["Go to next error" flycheck-next-error flycheck-mode]
["Go to previous error" flycheck-previous-error flycheck-mode]
@@ -1226,7 +1239,8 @@ Only has effect when variable `global-flycheck-mode' is
non-nil."
["Describe syntax checker" flycheck-describe-checker t]
["Verify setup" flycheck-verify-setup t]
["Show Flycheck version" flycheck-version t]
- ["Read the Flycheck manual" flycheck-info t]))
+ ["Flycheck quick help" flycheck-quick-help t]
+ ["Read the Flycheck manual" flycheck-manual t]))
"Menu of command `flycheck-mode'.")
(easy-menu-add-item nil '("Tools") flycheck-mode-menu-map "Spell Checking")
@@ -1284,6 +1298,42 @@ just return nil."
(interactive)
(browse-url "https://www.flycheck.org"))
+;;;###autoload
+(defun flycheck-quick-help ()
+ "Display brief Flycheck help."
+ (interactive)
+ (with-current-buffer (get-buffer-create "*flycheck-quick-help*")
+ (with-help-window (current-buffer)
+ (flycheck-mode) ;; so that we can exapnd \\[flycheck-<function>]
+ (let ((help
+ (substitute-command-keys
+ "Flycheck automatically runs checks on writable files when changed.
+Mode line status for the current buffer:
+ FlyC Not been checked yet
+ FlyC* Flycheck is running
+ FlyC:0 Last check resulted in no errors and no warnings
+ FlyC:3|5 Checker reported three errors and five warnings
+ FlyC- No checker available
+ FlyC! The checker crashed
+ FlyC. The last syntax check was manually interrupted
+ FlyC? The checker did something unexpected
+
+Key bindings:
+ \\[flycheck-buffer] Check current buffer
+ \\[flycheck-clear] Clear errors in current buffer
+ \\[flycheck-compile] Run checker as compile command
+
+ \\[flycheck-next-error] Next error
+ \\[flycheck-previous-error] Previous error
+ \\[flycheck-list-errors] List all errors
+
+ \\[flycheck-copy-errors-as-kill] Copy error messages at point
+ \\[flycheck-display-error-at-point] Explain error at point
+")))
+ (help-mode)
+ (read-only-mode 0)
+ (insert help)))))
+
(define-obsolete-function-alias 'flycheck-info
'flycheck-manual "Flycheck 26" "Open the Flycheck manual.")
@@ -2936,10 +2986,11 @@ Flycheck displays its status in the mode line. In the
default
configuration, it looks like this:
`FlyC' This buffer has not been checked yet.
-`FlyC-' Flycheck doesn't have a checker for this buffer.
`FlyC*' Flycheck is running. Expect results soon!
-`FlyC:3|2' This buffer contains three warnings and two errors.
+`FlyC:0' Last check resulted in no errors and no warnings.
+`FlyC:3|5' This buffer contains three errors and five warnings.
Use `\\[flycheck-list-errors]' to see the list.
+`FlyC-' Flycheck doesn't have a checker for this buffer.
You may also see the following icons:
`FlyC!' The checker crashed.
@@ -4095,19 +4146,29 @@ refresh the mode line."
STATUS defaults to `flycheck-last-status-change' if omitted or
nil."
- (let ((text (pcase (or status flycheck-last-status-change)
- (`not-checked "")
- (`no-checker "-")
- (`running "*")
- (`errored "!")
- (`finished
- (let-alist (flycheck-count-errors flycheck-current-errors)
- (if (or .error .warning)
- (format ":%s|%s" (or .error 0) (or .warning 0))
- "")))
- (`interrupted ".")
- (`suspicious "?"))))
- (concat " " flycheck-mode-line-prefix text)))
+ (let* ((current-status (or status flycheck-last-status-change))
+ (indicator (pcase current-status
+ (`not-checked "")
+ (`no-checker "-")
+ (`running "*")
+ (`errored "!")
+ (`finished
+ (let-alist (flycheck-count-errors
flycheck-current-errors)
+ (if (or .error .warning)
+ (format ":%s|%s" (or .error 0) (or .warning 0))
+ flycheck-mode-success-indicator)))
+ (`interrupted ".")
+ (`suspicious "?")))
+ (face (when flycheck-mode-line-color
+ (pcase current-status
+ (`errored 'error)
+ (`finished
+ (let-alist (flycheck-count-errors flycheck-current-errors)
+ (if (or .error .warning) 'error 'success))))))
+ (text (format " %s%s" flycheck-mode-line-prefix indicator)))
+ (when face
+ (setq text (propertize text 'face face)))
+ text))
;;; Error levels
@@ -6743,8 +6804,12 @@ Instead of highlighting errors in the buffer, this
command pops
up a separate buffer with the entire output of the syntax checker
tool, just like `compile' (\\[compile])."
(interactive
- (let ((default (flycheck-get-checker-for-buffer)))
- (list (flycheck-read-checker "Run syntax checker as compile command: "
+ (let* ((default (flycheck-get-checker-for-buffer))
+ (prompt (concat
+ "Run syntax checker as compile command"
+ (when default (concat " [" (format "%S" default) "]"))
+ ": ")))
+ (list (flycheck-read-checker prompt
(when (flycheck-checker-get default 'command)
default)
'command))))
diff --git a/test/specs/test-mode-line.el b/test/specs/test-mode-line.el
index fbea857a91..8a6fab3229 100644
--- a/test/specs/test-mode-line.el
+++ b/test/specs/test-mode-line.el
@@ -39,11 +39,11 @@
(it "does not show the number of infos"
(let ((flycheck-current-errors
(list (flycheck-error-new-at 1 1 'info "info"))))
- (expect (flycheck-mode-line-status-text 'finished) :to-equal " FlyC")))
+ (expect (flycheck-mode-line-status-text 'finished) :to-equal " FlyC:0")))
(it "includes the prefix"
(let ((flycheck-mode-line-prefix "foobar")
flycheck-current-errors)
- (expect (flycheck-mode-line-status-text 'finished) :to-equal "
foobar"))))
+ (expect (flycheck-mode-line-status-text 'finished) :to-equal "
foobar:0"))))
;;; test-mode-line.el ends here