I always get error when use flymake-mode. And flymake-mode turn off.

So I want to check whether flymake-mode is on. If it is not on, I will turn it on before call flymake-next-error.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Most minor modes are defined using the
define-minor-modemacro. For buffer-local modes, that macro creates a buffer-local variable of the same name as the mode itself1. The variable is non-nilwhen the mode is enabled for the current buffer.Therefore to check whether
flymake-modeis enabled, you can test the variableflymake-mode(noting that this variable might not be defined at all if the mode has not been enabled):Which, as Thom point out in the comments, can be expressed using the convenient macro:
Which we can use as the condition for an
iforwhenorunlessexpression:1 For global minor modes, the corresponding variable is global; but flymake-mode is buffer-local.