aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2020-04-13 08:00:14 +0300
committerEli Zaretskii2020-04-13 08:00:14 +0300
commitff09b4eeac7703ed60acc8c8635a5baf7a6fda34 (patch)
treeb98126e3ee3c5aaf503197f222cbd3ae2ff84bce
parent63e8d0ea877117394f76b5213eecf0441b88c7e6 (diff)
downloademacs-ff09b4eeac7703ed60acc8c8635a5baf7a6fda34.tar.gz
emacs-ff09b4eeac7703ed60acc8c8635a5baf7a6fda34.zip
Fix 'flymake-show-diagnostics-buffer' when line numbers are displayed
* lisp/progmodes/flymake.el (flymake--diagnostics-buffer-entries): Do nothing if 'flymake--diagnostics-buffer-source' is not a buffer. (Bug#40529)
-rw-r--r--lisp/progmodes/flymake.el65
1 files changed, 36 insertions, 29 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 25a2152f005..7fca9dac1af 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1321,35 +1321,42 @@ POS can be a buffer position or a button"
1321 (flymake-show-diagnostic (if (button-type pos) (button-start pos) pos)))) 1321 (flymake-show-diagnostic (if (button-type pos) (button-start pos) pos))))
1322 1322
1323(defun flymake--diagnostics-buffer-entries () 1323(defun flymake--diagnostics-buffer-entries ()
1324 (with-current-buffer flymake--diagnostics-buffer-source 1324 ;; Do nothing if 'flymake--diagnostics-buffer-source' has not yet
1325 (cl-loop for diag in 1325 ;; been set to a valid buffer. This could happen when this function
1326 (cl-sort (flymake-diagnostics) #'< :key #'flymake-diagnostic-beg) 1326 ;; is called too early. For example 'global-display-line-numbers-mode'
1327 for (line . col) = 1327 ;; calls us from its mode hook, when the diagnostic buffer has just
1328 (save-excursion 1328 ;; been created by 'flymake-show-diagnostics-buffer', but is not yet
1329 (goto-char (flymake--diag-beg diag)) 1329 ;; set up properly.
1330 (cons (line-number-at-pos) 1330 (when (bufferp flymake--diagnostics-buffer-source)
1331 (- (point) 1331 (with-current-buffer flymake--diagnostics-buffer-source
1332 (line-beginning-position)))) 1332 (cl-loop for diag in
1333 for type = (flymake--diag-type diag) 1333 (cl-sort (flymake-diagnostics) #'< :key #'flymake-diagnostic-beg)
1334 collect 1334 for (line . col) =
1335 (list (list :diagnostic diag 1335 (save-excursion
1336 :line line 1336 (goto-char (flymake--diag-beg diag))
1337 :severity (flymake--lookup-type-property 1337 (cons (line-number-at-pos)
1338 type 1338 (- (point)
1339 'severity (warning-numeric-level :error))) 1339 (line-beginning-position))))
1340 `[,(format "%s" line) 1340 for type = (flymake--diag-type diag)
1341 ,(format "%s" col) 1341 collect
1342 ,(propertize (format "%s" 1342 (list (list :diagnostic diag
1343 (flymake--lookup-type-property 1343 :line line
1344 type 'flymake-type-name type)) 1344 :severity (flymake--lookup-type-property
1345 'face (flymake--lookup-type-property 1345 type
1346 type 'mode-line-face 'flymake-error)) 1346 'severity (warning-numeric-level :error)))
1347 (,(format "%s" (flymake--diag-text diag)) 1347 `[,(format "%s" line)
1348 mouse-face highlight 1348 ,(format "%s" col)
1349 help-echo "mouse-2: visit this diagnostic" 1349 ,(propertize (format "%s"
1350 face nil 1350 (flymake--lookup-type-property
1351 action flymake-goto-diagnostic 1351 type 'flymake-type-name type))
1352 mouse-action flymake-goto-diagnostic)])))) 1352 'face (flymake--lookup-type-property
1353 type 'mode-line-face 'flymake-error))
1354 (,(format "%s" (flymake--diag-text diag))
1355 mouse-face highlight
1356 help-echo "mouse-2: visit this diagnostic"
1357 face nil
1358 action flymake-goto-diagnostic
1359 mouse-action flymake-goto-diagnostic)])))))
1353 1360
1354(define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode 1361(define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode
1355 "Flymake diagnostics" 1362 "Flymake diagnostics"