diff options
| author | João Távora | 2017-09-22 01:31:23 +0100 |
|---|---|---|
| committer | João Távora | 2017-10-03 13:52:24 +0100 |
| commit | b0bb181f9359aff07b09b919b8af397ef39d6784 (patch) | |
| tree | 48ddd698be7ade48bb40d9390c1e98a3ff8273cd | |
| parent | 54beebb4e0d919c7ee6dcdd7d774d851c35f85b7 (diff) | |
| download | emacs-b0bb181f9359aff07b09b919b8af397ef39d6784.tar.gz emacs-b0bb181f9359aff07b09b919b8af397ef39d6784.zip | |
Protect Flymake's eager checks against commands like fill-paragraph
If flymake-start-syntax-check-on-newline is t, check should start as
soon as a newline is seen by after-change-functions. But don't rush
it: since the buffer state might not be final, we might end up with
invalid diagnostic regions after some commands silently insert and
delete newlines (looking at you, fill-paragraph).
* lisp/progmodes/flymake.el (flymake-after-change-function): Pass
`deferred' to flymake--start-syntax-check.
(flymake--start-syntax-check): Take optional `deferred' arg.
| -rw-r--r-- | lisp/progmodes/flymake.el | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index b32e799e672..b5abf5c6ffe 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -475,6 +475,17 @@ If TYPE doesn't declare PROP in either | |||
| 475 | (flymake-report-status "" "") | 475 | (flymake-report-status "" "") |
| 476 | (flymake-report-status (format "%d/%d" err-count warn-count) ""))))) | 476 | (flymake-report-status (format "%d/%d" err-count warn-count) ""))))) |
| 477 | 477 | ||
| 478 | (defun flymake--start-syntax-check (&optional deferred) | ||
| 479 | (cl-labels ((start | ||
| 480 | () | ||
| 481 | (remove-hook 'post-command-hook #'start 'local) | ||
| 482 | (setq flymake-check-start-time (float-time)) | ||
| 483 | (flymake-proc-start-syntax-check))) | ||
| 484 | (if (and deferred | ||
| 485 | this-command) | ||
| 486 | (add-hook 'post-command-hook #'start 'append 'local) | ||
| 487 | (start)))) | ||
| 488 | |||
| 478 | ;;;###autoload | 489 | ;;;###autoload |
| 479 | (define-minor-mode flymake-mode nil | 490 | (define-minor-mode flymake-mode nil |
| 480 | :group 'flymake :lighter flymake-mode-line | 491 | :group 'flymake :lighter flymake-mode-line |
| @@ -538,7 +549,7 @@ If TYPE doesn't declare PROP in either | |||
| 538 | (let((new-text (buffer-substring start stop))) | 549 | (let((new-text (buffer-substring start stop))) |
| 539 | (when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) | 550 | (when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) |
| 540 | (flymake-log 3 "starting syntax check as new-line has been seen") | 551 | (flymake-log 3 "starting syntax check as new-line has been seen") |
| 541 | (flymake--start-syntax-check)) | 552 | (flymake--start-syntax-check 'deferred)) |
| 542 | (setq flymake-last-change-time (float-time)))) | 553 | (setq flymake-last-change-time (float-time)))) |
| 543 | 554 | ||
| 544 | (defun flymake-after-save-hook () | 555 | (defun flymake-after-save-hook () |
| @@ -590,9 +601,6 @@ If TYPE doesn't declare PROP in either | |||
| 590 | 601 | ||
| 591 | (provide 'flymake) | 602 | (provide 'flymake) |
| 592 | 603 | ||
| 593 | (defun flymake--start-syntax-check () | ||
| 594 | (flymake-proc-start-syntax-check)) | ||
| 595 | |||
| 596 | (declare-function flymake-proc-start-syntax-check "flymake-proc") | 604 | (declare-function flymake-proc-start-syntax-check "flymake-proc") |
| 597 | (declare-function flymake-can-syntax-check-file "flymake-proc") | 605 | (declare-function flymake-can-syntax-check-file "flymake-proc") |
| 598 | 606 | ||