- (if flymake-mode
- (if (flymake-can-syntax-check-file (buffer-file-name))
- (flymake-mode-on)
- (flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name)))
- (flymake-mode-off)))
+ (cond
+
+ ;; Turning the mode ON.
+ (flymake-mode
+ (if (not (flymake-can-syntax-check-file buffer-file-name))
+ (flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name))
+ (add-hook 'after-change-functions 'flymake-after-change-function nil t)
+ (add-hook 'after-save-hook 'flymake-after-save-hook nil t)
+ (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
+ ;;+(add-hook 'find-file-hook 'flymake-find-file-hook)
+
+ (flymake-report-status (current-buffer) "" "")
+
+ (setq flymake-timer
+ (run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
+
+ (when flymake-start-syntax-check-on-find-file
+ (flymake-start-syntax-check-for-current-buffer))))
+
+ ;; Turning the mode OFF.
+ (t
+ (remove-hook 'after-change-functions 'flymake-after-change-function t)
+ (remove-hook 'after-save-hook 'flymake-after-save-hook t)
+ (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t)
+ ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t)