aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2023-04-12 14:41:13 +0100
committerJoão Távora2023-04-12 14:41:35 +0100
commit8fdd7710ec0448fe9d3908ad073ddd4d69917719 (patch)
tree26ab376b12eed59fc4164828d74d0c51c46334ad
parent9d025eab2492519b26d69667a529865ea01f3318 (diff)
downloademacs-8fdd7710ec0448fe9d3908ad073ddd4d69917719.tar.gz
emacs-8fdd7710ec0448fe9d3908ad073ddd4d69917719.zip
Flymake: futher enhance echo-area appearance of diagnostics
Also describe new 'echo-face' property in the Flymake manual, and fix it's mistaken mention of a non-existing 'flymake-severity' property. * doc/misc/flymake.texi: (Flymake error types): Describe new properties and correct mention of 'severity' property. * lisp/progmodes/flymake.el: (flymake-diagnostic-oneliner): Rework. (flymake-error, flymake-warning, flymake-note): Add new 'echo-face' property. (flymake--highlight-line) (flymake-eldoc-function) (flymake--tabulated-entries-1): Use flymake-diagnostic-oneliner (Version): Bump to 1.3.3
-rw-r--r--doc/misc/flymake.texi17
-rw-r--r--lisp/progmodes/flymake.el35
2 files changed, 34 insertions, 18 deletions
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index 03d296a1d42..13616f39f16 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -1,8 +1,8 @@
1\input texinfo @c -*- mode: texinfo; coding: utf-8 -*- 1\input texinfo @c -*- mode: texinfo; coding: utf-8 -*-
2@comment %**start of header 2@comment %**start of header
3@setfilename ../../info/flymake.info 3@setfilename ../../info/flymake.info
4@set VERSION 1.2.2 4@set VERSION 1.3.3
5@set UPDATED November 2021 5@set UPDATED April 2023
6@settitle GNU Flymake @value{VERSION} 6@settitle GNU Flymake @value{VERSION}
7@include docstyle.texi 7@include docstyle.texi
8@syncodeindex pg cp 8@syncodeindex pg cp
@@ -394,7 +394,7 @@ its @code{flymake-overlay-control} property:
394 394
395@item 395@item
396@cindex severity of diagnostic 396@cindex severity of diagnostic
397@code{flymake-severity} is a non-negative integer specifying the 397@code{severity} is a non-negative integer specifying the
398diagnostic's severity. The higher the value, the more serious is the 398diagnostic's severity. The higher the value, the more serious is the
399error. If the overlay property @code{priority} is not specified in 399error. If the overlay property @code{priority} is not specified in
400@code{flymake-overlay-control}, @code{flymake-severity} is used to set 400@code{flymake-overlay-control}, @code{flymake-severity} is used to set
@@ -409,6 +409,17 @@ type, in case the name of the symbol associated with it is very long.
409@vindex flymake-category 409@vindex flymake-category
410@code{flymake-category} is a symbol whose property list is considered 410@code{flymake-category} is a symbol whose property list is considered
411the default for missing values of any other properties. 411the default for missing values of any other properties.
412
413@item
414@cindex mode-line appearance of a diagnostic
415@code{mode-line-face} is a face specifier controlling the appearance
416of the indicator of this type of diagnostic in the mode line.
417
418@item
419@cindex summarized appearance of a diagnostic
420@code{echo-face} is a face specifier controlling the appearance of the
421summarized description of this diagnostic when reading diagnostic
422messages (@pxref{Finding diagnostics}).
412@end itemize 423@end itemize
413 424
414@cindex predefined diagnostic types 425@cindex predefined diagnostic types
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 1cd9f0a6b0c..c751e5bd432 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Pavel Kobyakov <pk_at_work@yahoo.com> 5;; Author: Pavel Kobyakov <pk_at_work@yahoo.com>
6;; Maintainer: João Távora <joaotavora@gmail.com> 6;; Maintainer: João Távora <joaotavora@gmail.com>
7;; Version: 1.3.2 7;; Version: 1.3.3
8;; Keywords: c languages tools 8;; Keywords: c languages tools
9;; Package-Requires: ((emacs "26.1") (eldoc "1.14.0") (project "0.7.1")) 9;; Package-Requires: ((emacs "26.1") (eldoc "1.14.0") (project "0.7.1"))
10 10
@@ -371,11 +371,19 @@ diagnostics at BEG."
371(flymake--diag-accessor flymake-diagnostic-end flymake--diag-end end) 371(flymake--diag-accessor flymake-diagnostic-end flymake--diag-end end)
372(flymake--diag-accessor flymake-diagnostic-buffer flymake--diag-locus locus) 372(flymake--diag-accessor flymake-diagnostic-buffer flymake--diag-locus locus)
373 373
374(defun flymake-diagnostic-oneliner (diag) 374(defun flymake-diagnostic-oneliner (diag &optional nopaintp)
375 "Get truncated one-line text string for diagnostic DIAG." 375 "Get truncated one-line text string for diagnostic DIAG.
376 (let ((txt (flymake-diagnostic-text diag))) 376This is useful for displaying the DIAG's text to the user in
377 (substring txt 0 (cl-loop for i from 0 for a across txt 377confined spaces, such as the echo are. Unless NOPAINTP is t,
378 when (eq a ?\n) return i)))) 378propertize returned text with the `echo-face' property of DIAG's
379type."
380 (let* ((txt (flymake-diagnostic-text diag))
381 (txt (substring txt 0 (cl-loop for i from 0 for a across txt
382 when (eq a ?\n) return i))))
383 (if nopaintp txt
384 (propertize txt 'face
385 (flymake--lookup-type-property
386 (flymake-diagnostic-type diag) 'echo-face 'flymake-error)))))
379 387
380(cl-defun flymake--overlays (&key beg end filter compare key) 388(cl-defun flymake--overlays (&key beg end filter compare key)
381 "Get flymake-related overlays. 389 "Get flymake-related overlays.
@@ -577,18 +585,21 @@ Node `(Flymake)Flymake error types'"
577(put 'flymake-error 'flymake-bitmap 'flymake-error-bitmap) 585(put 'flymake-error 'flymake-bitmap 'flymake-error-bitmap)
578(put 'flymake-error 'severity (warning-numeric-level :error)) 586(put 'flymake-error 'severity (warning-numeric-level :error))
579(put 'flymake-error 'mode-line-face 'compilation-error) 587(put 'flymake-error 'mode-line-face 'compilation-error)
588(put 'flymake-error 'echo-face 'error)
580(put 'flymake-error 'flymake-type-name "error") 589(put 'flymake-error 'flymake-type-name "error")
581 590
582(put 'flymake-warning 'face 'flymake-warning) 591(put 'flymake-warning 'face 'flymake-warning)
583(put 'flymake-warning 'flymake-bitmap 'flymake-warning-bitmap) 592(put 'flymake-warning 'flymake-bitmap 'flymake-warning-bitmap)
584(put 'flymake-warning 'severity (warning-numeric-level :warning)) 593(put 'flymake-warning 'severity (warning-numeric-level :warning))
585(put 'flymake-warning 'mode-line-face 'compilation-warning) 594(put 'flymake-warning 'mode-line-face 'compilation-warning)
595(put 'flymake-warning 'echo-face 'warning)
586(put 'flymake-warning 'flymake-type-name "warning") 596(put 'flymake-warning 'flymake-type-name "warning")
587 597
588(put 'flymake-note 'face 'flymake-note) 598(put 'flymake-note 'face 'flymake-note)
589(put 'flymake-note 'flymake-bitmap 'flymake-note-bitmap) 599(put 'flymake-note 'flymake-bitmap 'flymake-note-bitmap)
590(put 'flymake-note 'severity (warning-numeric-level :debug)) 600(put 'flymake-note 'severity (warning-numeric-level :debug))
591(put 'flymake-note 'mode-line-face 'compilation-info) 601(put 'flymake-note 'mode-line-face 'compilation-info)
602(put 'flymake-note 'echo-face 'compilation-info)
592(put 'flymake-note 'flymake-type-name "note") 603(put 'flymake-note 'flymake-type-name "note")
593 604
594(defun flymake--lookup-type-property (type prop &optional default) 605(defun flymake--lookup-type-property (type prop &optional default)
@@ -736,7 +747,7 @@ Return nil or the overlay created."
736 (lambda (window _ov pos) 747 (lambda (window _ov pos)
737 (with-selected-window window 748 (with-selected-window window
738 (mapconcat 749 (mapconcat
739 #'flymake-diagnostic-text 750 #'flymake-diagnostic-oneliner
740 (flymake-diagnostics pos) 751 (flymake-diagnostics pos)
741 "\n")))) 752 "\n"))))
742 (default-maybe 'severity (warning-numeric-level :error)) 753 (default-maybe 'severity (warning-numeric-level :error))
@@ -1263,13 +1274,7 @@ Intended for `eldoc-documentation-functions' (which see)."
1263 (when-let ((diags (flymake-diagnostics (point)))) 1274 (when-let ((diags (flymake-diagnostics (point))))
1264 (funcall report-doc 1275 (funcall report-doc
1265 (mapconcat #'flymake-diagnostic-text diags "\n") 1276 (mapconcat #'flymake-diagnostic-text diags "\n")
1266 :echo (mapconcat (lambda (d) 1277 :echo (mapconcat #'flymake-diagnostic-oneliner
1267 (propertize (flymake-diagnostic-oneliner d)
1268 'face
1269 (flymake--lookup-type-property
1270 (flymake-diagnostic-type d)
1271 'face
1272 'flymake-error)))
1273 diags "\n")))) 1278 diags "\n"))))
1274 1279
1275(defun flymake-goto-next-error (&optional n filter interactive) 1280(defun flymake-goto-next-error (&optional n filter interactive)
@@ -1595,7 +1600,7 @@ filename of the diagnostic relative to that directory."
1595 "\\1\\2" bname) 1600 "\\1\\2" bname)
1596 "(anon)") 1601 "(anon)")
1597 'help-echo (format "From `%s' backend" backend)) 1602 'help-echo (format "From `%s' backend" backend))
1598 (,(flymake-diagnostic-oneliner diag) 1603 (,(flymake-diagnostic-oneliner diag t)
1599 mouse-face highlight 1604 mouse-face highlight
1600 help-echo "mouse-2: visit this diagnostic" 1605 help-echo "mouse-2: visit this diagnostic"
1601 face nil 1606 face nil