[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-27 ff09b4e: Fix 'flymake-show-diagnostics-buffer' when line number
From: |
Eli Zaretskii |
Subject: |
emacs-27 ff09b4e: Fix 'flymake-show-diagnostics-buffer' when line numbers are displayed |
Date: |
Mon, 13 Apr 2020 01:01:48 -0400 (EDT) |
branch: emacs-27
commit ff09b4eeac7703ed60acc8c8635a5baf7a6fda34
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
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)
---
lisp/progmodes/flymake.el | 65 ++++++++++++++++++++++++++---------------------
1 file changed, 36 insertions(+), 29 deletions(-)
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 25a2152..7fca9da 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1321,35 +1321,42 @@ POS can be a buffer position or a button"
(flymake-show-diagnostic (if (button-type pos) (button-start pos) pos))))
(defun flymake--diagnostics-buffer-entries ()
- (with-current-buffer flymake--diagnostics-buffer-source
- (cl-loop for diag in
- (cl-sort (flymake-diagnostics) #'< :key #'flymake-diagnostic-beg)
- for (line . col) =
- (save-excursion
- (goto-char (flymake--diag-beg diag))
- (cons (line-number-at-pos)
- (- (point)
- (line-beginning-position))))
- for type = (flymake--diag-type diag)
- collect
- (list (list :diagnostic diag
- :line line
- :severity (flymake--lookup-type-property
- type
- 'severity (warning-numeric-level :error)))
- `[,(format "%s" line)
- ,(format "%s" col)
- ,(propertize (format "%s"
- (flymake--lookup-type-property
- type 'flymake-type-name type))
- 'face (flymake--lookup-type-property
- type 'mode-line-face 'flymake-error))
- (,(format "%s" (flymake--diag-text diag))
- mouse-face highlight
- help-echo "mouse-2: visit this diagnostic"
- face nil
- action flymake-goto-diagnostic
- mouse-action flymake-goto-diagnostic)]))))
+ ;; Do nothing if 'flymake--diagnostics-buffer-source' has not yet
+ ;; been set to a valid buffer. This could happen when this function
+ ;; is called too early. For example 'global-display-line-numbers-mode'
+ ;; calls us from its mode hook, when the diagnostic buffer has just
+ ;; been created by 'flymake-show-diagnostics-buffer', but is not yet
+ ;; set up properly.
+ (when (bufferp flymake--diagnostics-buffer-source)
+ (with-current-buffer flymake--diagnostics-buffer-source
+ (cl-loop for diag in
+ (cl-sort (flymake-diagnostics) #'< :key
#'flymake-diagnostic-beg)
+ for (line . col) =
+ (save-excursion
+ (goto-char (flymake--diag-beg diag))
+ (cons (line-number-at-pos)
+ (- (point)
+ (line-beginning-position))))
+ for type = (flymake--diag-type diag)
+ collect
+ (list (list :diagnostic diag
+ :line line
+ :severity (flymake--lookup-type-property
+ type
+ 'severity (warning-numeric-level
:error)))
+ `[,(format "%s" line)
+ ,(format "%s" col)
+ ,(propertize (format "%s"
+ (flymake--lookup-type-property
+ type 'flymake-type-name type))
+ 'face (flymake--lookup-type-property
+ type 'mode-line-face
'flymake-error))
+ (,(format "%s" (flymake--diag-text diag))
+ mouse-face highlight
+ help-echo "mouse-2: visit this diagnostic"
+ face nil
+ action flymake-goto-diagnostic
+ mouse-action flymake-goto-diagnostic)])))))
(define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode
"Flymake diagnostics"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-27 ff09b4e: Fix 'flymake-show-diagnostics-buffer' when line numbers are displayed,
Eli Zaretskii <=