diff options
| author | Leo Liu | 2012-07-14 20:02:22 +0800 |
|---|---|---|
| committer | Leo Liu | 2012-07-14 20:02:22 +0800 |
| commit | 28ca98ac5218a3a14ae57f425ac226fc8fc0f6e4 (patch) | |
| tree | 7486daed1baba46f5320021e0ec16ffea5beb7a2 | |
| parent | cd276f6ef3d46505dcaf6245c303713023e74ae2 (diff) | |
| download | emacs-28ca98ac5218a3a14ae57f425ac226fc8fc0f6e4.tar.gz emacs-28ca98ac5218a3a14ae57f425ac226fc8fc0f6e4.zip | |
Add fringe bitmap indicators for flymake
Fixes: debbugs:11253
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/progmodes/flymake.el | 46 |
2 files changed, 46 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e2964ddb1b5..8fee2598235 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2012-07-14 Leo Liu <sdl.web@gmail.com> | 1 | 2012-07-14 Leo Liu <sdl.web@gmail.com> |
| 2 | 2 | ||
| 3 | Add fringe bitmap indicators for flymake. (Bug#11253) | ||
| 4 | * progmodes/flymake.el (flymake-highlight-line): Use fringe bitmaps. | ||
| 5 | (flymake-make-overlay): New arg BITMAP. | ||
| 6 | (flymake-error-bitmap, flymake-warning-bitmap) | ||
| 7 | (flymake-fringe-indicator-position): New user variables. | ||
| 8 | |||
| 3 | * fringe.el: New bitmap exclamation-mark. | 9 | * fringe.el: New bitmap exclamation-mark. |
| 4 | 10 | ||
| 5 | 2012-07-14 Jan Djärv <jan.h.d@swipnet.se> | 11 | 2012-07-14 Jan Djärv <jan.h.d@swipnet.se> |
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 85f8b64cf44..ad285274928 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -763,15 +763,46 @@ line number outside the file being compiled." | |||
| 763 | "Determine whether overlay OV was created by flymake." | 763 | "Determine whether overlay OV was created by flymake." |
| 764 | (and (overlayp ov) (overlay-get ov 'flymake-overlay))) | 764 | (and (overlayp ov) (overlay-get ov 'flymake-overlay))) |
| 765 | 765 | ||
| 766 | (defun flymake-make-overlay (beg end tooltip-text face mouse-face) | 766 | (defcustom flymake-error-bitmap '(exclamation-mark error) |
| 767 | "Bitmap used in the fringe for indicating errors. | ||
| 768 | The value may also be a list of two elements where the second | ||
| 769 | element specifies the face for the bitmap." | ||
| 770 | :group 'flymake | ||
| 771 | :type 'symbol) | ||
| 772 | |||
| 773 | (defcustom flymake-warning-bitmap 'question-mark | ||
| 774 | "Bitmap used in the fringe for indicating warnings. | ||
| 775 | The value may also be a list of two elements where the second | ||
| 776 | element specifies the face for the bitmap." | ||
| 777 | :group 'flymake | ||
| 778 | :type 'symbol) | ||
| 779 | |||
| 780 | (defcustom flymake-fringe-indicator-position 'left-fringe | ||
| 781 | "The position to put flymake fringe indicator. | ||
| 782 | The value can be nil, left-fringe or right-fringe. | ||
| 783 | Fringe indicators are disabled if nil." | ||
| 784 | :group 'flymake | ||
| 785 | :type '(choice (const left-fringe) | ||
| 786 | (const right-fringe) | ||
| 787 | (const :tag "No fringe indicators" nil))) | ||
| 788 | |||
| 789 | (defun flymake-make-overlay (beg end tooltip-text face bitmap mouse-face) | ||
| 767 | "Allocate a flymake overlay in range BEG and END." | 790 | "Allocate a flymake overlay in range BEG and END." |
| 768 | (when (not (flymake-region-has-flymake-overlays beg end)) | 791 | (when (not (flymake-region-has-flymake-overlays beg end)) |
| 769 | (let ((ov (make-overlay beg end nil t t))) | 792 | (let ((ov (make-overlay beg end nil t t)) |
| 793 | (fringe (and flymake-fringe-indicator-position | ||
| 794 | (propertize "!" 'display | ||
| 795 | (cons flymake-fringe-indicator-position | ||
| 796 | (if (listp bitmap) | ||
| 797 | bitmap | ||
| 798 | (list bitmap))))))) | ||
| 770 | (overlay-put ov 'face face) | 799 | (overlay-put ov 'face face) |
| 771 | (overlay-put ov 'mouse-face mouse-face) | 800 | (overlay-put ov 'mouse-face mouse-face) |
| 772 | (overlay-put ov 'help-echo tooltip-text) | 801 | (overlay-put ov 'help-echo tooltip-text) |
| 773 | (overlay-put ov 'flymake-overlay t) | 802 | (overlay-put ov 'flymake-overlay t) |
| 774 | (overlay-put ov 'priority 100) | 803 | (overlay-put ov 'priority 100) |
| 804 | (overlay-put ov 'evaporate t) | ||
| 805 | (overlay-put ov 'before-string fringe) | ||
| 775 | ;;+(flymake-log 3 "created overlay %s" ov) | 806 | ;;+(flymake-log 3 "created overlay %s" ov) |
| 776 | ov) | 807 | ov) |
| 777 | (flymake-log 3 "created an overlay at (%d-%d)" beg end))) | 808 | (flymake-log 3 "created an overlay at (%d-%d)" beg end))) |
| @@ -815,7 +846,8 @@ Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting." | |||
| 815 | (beg line-beg) | 846 | (beg line-beg) |
| 816 | (end line-end) | 847 | (end line-end) |
| 817 | (tooltip-text (flymake-ler-text (nth 0 line-err-info-list))) | 848 | (tooltip-text (flymake-ler-text (nth 0 line-err-info-list))) |
| 818 | (face nil)) | 849 | (face nil) |
| 850 | (bitmap nil)) | ||
| 819 | 851 | ||
| 820 | (goto-char line-beg) | 852 | (goto-char line-beg) |
| 821 | (while (looking-at "[ \t]") | 853 | (while (looking-at "[ \t]") |
| @@ -839,10 +871,12 @@ Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting." | |||
| 839 | (setq end (point))) | 871 | (setq end (point))) |
| 840 | 872 | ||
| 841 | (if (> (flymake-get-line-err-count line-err-info-list "e") 0) | 873 | (if (> (flymake-get-line-err-count line-err-info-list "e") 0) |
| 842 | (setq face 'flymake-errline) | 874 | (setq face 'flymake-errline |
| 843 | (setq face 'flymake-warnline)) | 875 | bitmap flymake-error-bitmap) |
| 876 | (setq face 'flymake-warnline | ||
| 877 | bitmap flymake-warning-bitmap)) | ||
| 844 | 878 | ||
| 845 | (flymake-make-overlay beg end tooltip-text face nil))) | 879 | (flymake-make-overlay beg end tooltip-text face bitmap nil))) |
| 846 | 880 | ||
| 847 | (defun flymake-parse-err-lines (err-info-list lines) | 881 | (defun flymake-parse-err-lines (err-info-list lines) |
| 848 | "Parse err LINES, store info in ERR-INFO-LIST." | 882 | "Parse err LINES, store info in ERR-INFO-LIST." |