diff options
| author | João Távora | 2023-09-21 22:35:05 +0100 |
|---|---|---|
| committer | João Távora | 2023-09-21 22:35:31 +0100 |
| commit | 9db3fbd369121ddd34e7f4febe8688d758a5dbb7 (patch) | |
| tree | 449fba224c84f465a98fa0d59b5e7f8e9351cd08 | |
| parent | a45d33d8aa80482d185a130059dd099e24d7aec1 (diff) | |
| download | emacs-9db3fbd369121ddd34e7f4febe8688d758a5dbb7.tar.gz emacs-9db3fbd369121ddd34e7f4febe8688d758a5dbb7.zip | |
Flymake: new 'short' option for flymake-show-diagnostics-at-end-of-line
bug#66041
* lisp/progmodes/flymake.el (Version): Bump to 1.3.6
(flymake-eol-information-face): New face.
(flymake-show-diagnostics-at-end-of-line): Support new value short.
(flymake--eol-overlay-summary): Rework.
(flymake--highlight-line):
| -rw-r--r-- | lisp/progmodes/flymake.el | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index ffe95cce6ca..6fabea3bda8 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.4 | 7 | ;; Version: 1.3.6 |
| 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 | ||
| @@ -461,10 +461,22 @@ See variable `flymake-show-diagnostics-at-end-of-line'." | |||
| 461 | "Face like `flymake-note-echo', but for end-of-line overlays." | 461 | "Face like `flymake-note-echo', but for end-of-line overlays." |
| 462 | :package-version '(Flymake . "1.3.5")) | 462 | :package-version '(Flymake . "1.3.5")) |
| 463 | 463 | ||
| 464 | (defface flymake-eol-information-face | ||
| 465 | '((t :inherit (flymake-end-of-line-diagnostics-face) | ||
| 466 | :box nil | ||
| 467 | :slant italic)) | ||
| 468 | "Face used for information about end-of-line diagnostics." | ||
| 469 | :package-version '(Flymake . "1.3.6")) | ||
| 470 | |||
| 464 | (defcustom flymake-show-diagnostics-at-end-of-line nil | 471 | (defcustom flymake-show-diagnostics-at-end-of-line nil |
| 465 | "If non-nil, add diagnostic summary messages at end-of-line." | 472 | "If non-nil, add diagnostic summary messages at end-of-line. |
| 466 | :type 'boolean | 473 | The value `short' means that only the most severe diagnostic |
| 467 | :package-version '(Flymake . "1.3.4")) | 474 | shall be shown. Any other non-nil value means show all |
| 475 | diagnostic summaries at end-of-line." | ||
| 476 | :type '(choice (const :tag "Display most severe diagnostic" short) | ||
| 477 | (const :tag "Display all diagnostics" t) | ||
| 478 | (const :tag "Don't display diagnostics at end-of-line" nil)) | ||
| 479 | :package-version '(Flymake . "1.3.6")) | ||
| 468 | 480 | ||
| 469 | (define-obsolete-face-alias 'flymake-warnline 'flymake-warning "26.1") | 481 | (define-obsolete-face-alias 'flymake-warnline 'flymake-warning "26.1") |
| 470 | (define-obsolete-face-alias 'flymake-errline 'flymake-error "26.1") | 482 | (define-obsolete-face-alias 'flymake-errline 'flymake-error "26.1") |
| @@ -704,20 +716,34 @@ associated `flymake-category' return DEFAULT." | |||
| 704 | 716 | ||
| 705 | (defun flymake--eol-overlay-summary (src-ovs) | 717 | (defun flymake--eol-overlay-summary (src-ovs) |
| 706 | "Helper function for `flymake--eol-overlay-update'." | 718 | "Helper function for `flymake--eol-overlay-update'." |
| 707 | (cl-loop | 719 | (cl-flet ((summarize (d) |
| 708 | for s in src-ovs | 720 | (propertize (flymake-diagnostic-oneliner d t) 'face |
| 709 | for d = (overlay-get s 'flymake-diagnostic) | 721 | (flymake--lookup-type-property (flymake--diag-type d) |
| 710 | for type = (flymake--diag-type d) | 722 | 'eol-face)))) |
| 711 | for eol-face = (flymake--lookup-type-property type 'eol-face) | 723 | (let* ((diags |
| 712 | concat (propertize (flymake-diagnostic-oneliner d t) 'face eol-face) into retval | 724 | (cl-sort |
| 713 | concat " " | 725 | (mapcar (lambda (o) (overlay-get o 'flymake-diagnostic)) src-ovs) |
| 714 | into retval | 726 | #'> |
| 715 | finally | 727 | :key (lambda (d) (flymake--severity (flymake-diagnostic-type d))))) |
| 716 | (setq retval (concat " " retval)) | 728 | (summary |
| 717 | (put-text-property 0 1 'cursor t retval) | 729 | (concat |
| 718 | (cl-return retval))) | 730 | " " |
| 731 | (cond ((eq flymake-show-diagnostics-at-end-of-line 'short) | ||
| 732 | (concat | ||
| 733 | (summarize (car diags)) | ||
| 734 | (and (cdr diags) | ||
| 735 | (concat | ||
| 736 | " " | ||
| 737 | (propertize (format "and %s more" | ||
| 738 | (1- (length diags))) | ||
| 739 | 'face 'flymake-eol-information-face))))) | ||
| 740 | (t | ||
| 741 | (mapconcat #'summarize diags " ")))))) | ||
| 742 | (put-text-property 0 1 'cursor t summary) | ||
| 743 | summary))) | ||
| 719 | 744 | ||
| 720 | (defun flymake--update-eol-overlays () | 745 | (defun flymake--update-eol-overlays () |
| 746 | "Update the `before-string' property of end-of-line overlays." | ||
| 721 | (save-excursion | 747 | (save-excursion |
| 722 | (widen) | 748 | (widen) |
| 723 | (dolist (o (overlays-in (point-min) (point-max))) | 749 | (dolist (o (overlays-in (point-min) (point-max))) |