diff options
| author | João Távora | 2018-06-15 15:48:59 +0100 |
|---|---|---|
| committer | João Távora | 2018-06-15 15:49:44 +0100 |
| commit | 115decb07d99be74c114141a6745cfd3603c7aaf (patch) | |
| tree | d19f9e60fa532c55aa2bea7f37a3f1bd47c8451f | |
| parent | 4221809b00e526892b7ff3979b3829eb493f0616 (diff) | |
| download | emacs-115decb07d99be74c114141a6745cfd3603c7aaf.tar.gz emacs-115decb07d99be74c114141a6745cfd3603c7aaf.zip | |
Fix a bug in Flymake handling of region-specific reports
The backend's diagnostic list must be updated too, not just cleared.
* lisp/progmodes/flymake.el (flymake--diag): Add overlay field.
(flymake--highlight-line): Return created overlay.
(flymake--handle-report): Iterate the backend's diagnostics, not
the overlays. Set diagnostic overlay.
(flymake--run-backend): Don't clean diagnostic list here.
(flymake-mode): Call delete-overlay directly.
| -rw-r--r-- | lisp/progmodes/flymake.el | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index e3c07fc898c..eb0eebf672b 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -14,10 +14,10 @@ | |||
| 14 | ;; the Free Software Foundation, either version 3 of the License, or | 14 | ;; the Free Software Foundation, either version 3 of the License, or |
| 15 | ;; (at your option) any later version. | 15 | ;; (at your option) any later version. |
| 16 | 16 | ||
| 17 | ;; GNU Emacs is distributed in the hope that it will be useful, | 17 | ;; GNU Emacs is distributed in the hope that it will be useful, but |
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | ;; GNU General Public License for more details. | 20 | ;; General Public License for more details. |
| 21 | 21 | ||
| 22 | ;; You should have received a copy of the GNU General Public License | 22 | ;; You should have received a copy of the GNU General Public License |
| 23 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | 23 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. |
| @@ -292,7 +292,7 @@ generated it." | |||
| 292 | 292 | ||
| 293 | (cl-defstruct (flymake--diag | 293 | (cl-defstruct (flymake--diag |
| 294 | (:constructor flymake--diag-make)) | 294 | (:constructor flymake--diag-make)) |
| 295 | buffer beg end type text backend data) | 295 | buffer beg end type text backend data overlay) |
| 296 | 296 | ||
| 297 | ;;;###autoload | 297 | ;;;###autoload |
| 298 | (defun flymake-make-diagnostic (buffer | 298 | (defun flymake-make-diagnostic (buffer |
| @@ -354,10 +354,6 @@ verify FILTER, a function, and sort them by COMPARE (using KEY)." | |||
| 354 | #'identity)) | 354 | #'identity)) |
| 355 | ovs)))) | 355 | ovs)))) |
| 356 | 356 | ||
| 357 | (defun flymake--delete-own-overlays (&optional filter beg end) | ||
| 358 | "Delete Flymake overlays matching FILTER between BEG and END." | ||
| 359 | (mapc #'delete-overlay (flymake--overlays :filter filter :beg beg :end end))) | ||
| 360 | |||
| 361 | (defface flymake-error | 357 | (defface flymake-error |
| 362 | '((((supports :underline (:style wave))) | 358 | '((((supports :underline (:style wave))) |
| 363 | :underline (:style wave :color "Red1")) | 359 | :underline (:style wave :color "Red1")) |
| @@ -630,7 +626,8 @@ associated `flymake-category' return DEFAULT." | |||
| 630 | ;; Some properties can't be overridden. | 626 | ;; Some properties can't be overridden. |
| 631 | ;; | 627 | ;; |
| 632 | (overlay-put ov 'evaporate t) | 628 | (overlay-put ov 'evaporate t) |
| 633 | (overlay-put ov 'flymake-diagnostic diagnostic))) | 629 | (overlay-put ov 'flymake-diagnostic diagnostic) |
| 630 | ov)) | ||
| 634 | 631 | ||
| 635 | ;; Nothing in Flymake uses this at all any more, so this is just for | 632 | ;; Nothing in Flymake uses this at all any more, so this is just for |
| 636 | ;; third-party compatibility. | 633 | ;; third-party compatibility. |
| @@ -717,21 +714,28 @@ report applies to that region." | |||
| 717 | (setq new-diags report-action) | 714 | (setq new-diags report-action) |
| 718 | (save-restriction | 715 | (save-restriction |
| 719 | (widen) | 716 | (widen) |
| 720 | ;; Decide whether to delete some of this backend's overlays | 717 | ;; Before adding to backend's diagnostic list, decide if |
| 721 | (let ((ov-filter | 718 | ;; some or all must be deleted. When deleting, also delete |
| 722 | (lambda (ov) | 719 | ;; the associated overlay. |
| 723 | (eq backend | 720 | (cond |
| 724 | (flymake--diag-backend | 721 | (region |
| 725 | (overlay-get ov 'flymake-diagnostic)))))) | 722 | (dolist (diag (flymake--backend-state-diags state)) |
| 726 | (cond | 723 | (let ((diag-beg (flymake--diag-beg diag)) |
| 727 | (region (flymake--delete-own-overlays ov-filter | 724 | (diag-end (flymake--diag-beg diag))) |
| 728 | (car region) | 725 | (when (and (< diag-beg (cdr region)) |
| 729 | (cdr region))) | 726 | (> diag-end (car region))) |
| 730 | (first-report (flymake--delete-own-overlays ov-filter)))) | 727 | (delete-overlay (flymake--diag-overlay diag)) |
| 728 | (setf (flymake--backend-state-diags state) | ||
| 729 | (delq diag (flymake--backend-state-diags state))))))) | ||
| 730 | (first-report | ||
| 731 | (dolist (diag (flymake--backend-state-diags state)) | ||
| 732 | (delete-overlay (flymake--diag-overlay diag))) | ||
| 733 | (setf (flymake--backend-state-diags state) nil))) | ||
| 731 | ;; Now make new ones | 734 | ;; Now make new ones |
| 732 | (mapc (lambda (diag) | 735 | (mapc (lambda (diag) |
| 733 | (flymake--highlight-line diag) | 736 | (let ((overlay (flymake--highlight-line diag))) |
| 734 | (setf (flymake--diag-backend diag) backend)) | 737 | (setf (flymake--diag-backend diag) backend |
| 738 | (flymake--diag-overlay diag) overlay))) | ||
| 735 | new-diags) | 739 | new-diags) |
| 736 | (setf (flymake--backend-state-diags state) | 740 | (setf (flymake--backend-state-diags state) |
| 737 | (append new-diags (flymake--backend-state-diags state))) | 741 | (append new-diags (flymake--backend-state-diags state))) |
| @@ -812,7 +816,6 @@ with a report function." | |||
| 812 | (flymake--with-backend-state backend state | 816 | (flymake--with-backend-state backend state |
| 813 | (setf (flymake--backend-state-running state) run-token | 817 | (setf (flymake--backend-state-running state) run-token |
| 814 | (flymake--backend-state-disabled state) nil | 818 | (flymake--backend-state-disabled state) nil |
| 815 | (flymake--backend-state-diags state) nil | ||
| 816 | (flymake--backend-state-reported-p state) nil)) | 819 | (flymake--backend-state-reported-p state) nil)) |
| 817 | ;; FIXME: Should use `condition-case-unless-debug' here, but don't | 820 | ;; FIXME: Should use `condition-case-unless-debug' here, but don't |
| 818 | ;; for two reasons: (1) that won't let me catch errors from inside | 821 | ;; for two reasons: (1) that won't let me catch errors from inside |
| @@ -963,7 +966,7 @@ special *Flymake log* buffer." :group 'flymake :lighter | |||
| 963 | (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t) | 966 | (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t) |
| 964 | ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t) | 967 | ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t) |
| 965 | 968 | ||
| 966 | (flymake--delete-own-overlays) | 969 | (mapc #'delete-overlay (flymake--overlays)) |
| 967 | 970 | ||
| 968 | (when flymake-timer | 971 | (when flymake-timer |
| 969 | (cancel-timer flymake-timer) | 972 | (cancel-timer flymake-timer) |