From: João Távora Date: Tue, 11 Apr 2023 12:35:43 +0000 (+0100) Subject: Flymake: take advantage of new Eldoc options X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=560950468588117b264a9f916fb578e0eb2a124a;p=emacs.git Flymake: take advantage of new Eldoc options Only echo the first line of a potentially very large error message. * lisp/progmodes/flymake.el: (flymake-diagnostic-oneliner): New helper. (flymake--tabulated-entries-1) (flymake-eldoc-function): Use it. (Version): Bump to 1.3.2. (Package-Requires): Use Eldoc 1.14.0. --- diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index a352adbba19..1cd9f0a6b0c 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -4,9 +4,9 @@ ;; Author: Pavel Kobyakov ;; Maintainer: João Távora -;; Version: 1.2.2 +;; Version: 1.3.2 ;; Keywords: c languages tools -;; Package-Requires: ((emacs "26.1") (eldoc "1.1.0") (project "0.7.1")) +;; Package-Requires: ((emacs "26.1") (eldoc "1.14.0") (project "0.7.1")) ;; This is a GNU ELPA :core package. Avoid functionality that is not ;; compatible with the version of Emacs recorded above. @@ -371,6 +371,12 @@ diagnostics at BEG." (flymake--diag-accessor flymake-diagnostic-end flymake--diag-end end) (flymake--diag-accessor flymake-diagnostic-buffer flymake--diag-locus locus) +(defun flymake-diagnostic-oneliner (diag) + "Get truncated one-line text string for diagnostic DIAG." + (let ((txt (flymake-diagnostic-text diag))) + (substring txt 0 (cl-loop for i from 0 for a across txt + when (eq a ?\n) return i)))) + (cl-defun flymake--overlays (&key beg end filter compare key) "Get flymake-related overlays. If BEG is non-nil and END is nil, consider only `overlays-at' @@ -1254,10 +1260,17 @@ START and STOP and LEN are as in `after-change-functions'." (defun flymake-eldoc-function (report-doc &rest _) "Document diagnostics at point. Intended for `eldoc-documentation-functions' (which see)." - (let ((diags (flymake-diagnostics (point)))) - (when diags - (funcall report-doc - (mapconcat #'flymake-diagnostic-text diags "\n"))))) + (when-let ((diags (flymake-diagnostics (point)))) + (funcall report-doc + (mapconcat #'flymake-diagnostic-text diags "\n") + :echo (mapconcat (lambda (d) + (propertize (flymake-diagnostic-oneliner d) + 'face + (flymake--lookup-type-property + (flymake-diagnostic-type d) + 'face + 'flymake-error))) + diags "\n")))) (defun flymake-goto-next-error (&optional n filter interactive) "Go to Nth next Flymake diagnostic that matches FILTER. @@ -1582,8 +1595,7 @@ filename of the diagnostic relative to that directory." "\\1\\2" bname) "(anon)") 'help-echo (format "From `%s' backend" backend)) - (,(replace-regexp-in-string "\n.*" "" - (flymake-diagnostic-text diag)) + (,(flymake-diagnostic-oneliner diag) mouse-face highlight help-echo "mouse-2: visit this diagnostic" face nil