From: João Távora Date: Wed, 4 May 2022 20:47:21 +0000 (+0100) Subject: Consider diagnostic.code when generating flymake diagnostics X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~47 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=29f2ec24713984d561881980aef578faa2a83068;p=emacs.git Consider diagnostic.code when generating flymake diagnostics Not sure this will please everybody, can almost guess someone is going to ask for a custom switch. Instead this info (and the source) should be passed on to Flymake. That's where the custom switch for controlling formatting of diagnostic messages should exist. But that's too much work right now. * eglot.el (eglot-handle-notification): Consider Diagnostic.code. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 81c545e64f9..3a33ad3ec2b 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1957,14 +1957,16 @@ COMMAND is a symbol naming the command." (cond ((null sev) 'eglot-error) ((<= sev 1) 'eglot-error) ((= sev 2) 'eglot-warning) - (t 'eglot-note)))) + (t 'eglot-note))) + (mess (source code message) + (concat source (and code (concat " [" code "]")) ": " message))) (if-let ((buffer (find-buffer-visiting (eglot--uri-to-path uri)))) (with-current-buffer buffer (cl-loop for diag-spec across diagnostics - collect (eglot--dbind ((Diagnostic) range message severity source tags) + collect (eglot--dbind ((Diagnostic) range code message severity source tags) diag-spec - (setq message (concat source ": " message)) + (setq message (mess source code message)) (pcase-let ((`(,beg . ,end) (eglot--range-region range))) ;; Fallback to `flymake-diag-region' if server @@ -2001,8 +2003,8 @@ COMMAND is a symbol naming the command." (cl-loop with path = (expand-file-name (eglot--uri-to-path uri)) for diag-spec across diagnostics - collect (eglot--dbind ((Diagnostic) range message severity source) diag-spec - (setq message (concat source ": " message)) + collect (eglot--dbind ((Diagnostic) code range message severity source) diag-spec + (setq message (mess source code message)) (let* ((start (plist-get range :start)) (line (1+ (plist-get start :line))) (char (1+ (plist-get start :character))))