diff options
| author | Leo Liu | 2013-12-08 17:18:55 +0800 |
|---|---|---|
| committer | Leo Liu | 2013-12-08 17:18:55 +0800 |
| commit | 974ebc9ccfaafea7cda98d6a4bb4f63d1fa303fb (patch) | |
| tree | 27ded4248731ddbe1eeb2e192ff0648d1368802e /lisp | |
| parent | 3bc9da3286759f895574ecad3234ee3e0973e9df (diff) | |
| download | emacs-974ebc9ccfaafea7cda98d6a4bb4f63d1fa303fb.tar.gz emacs-974ebc9ccfaafea7cda98d6a4bb4f63d1fa303fb.zip | |
Re-write flymake-highlight-line in flymake.el
* progmodes/flymake.el (flymake-highlight-line): Re-write.
(flymake-make-overlay): Remove arg MOUSE-FACE.
(flymake-save-string-to-file, flymake-read-file-to-string): Remove.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/progmodes/flymake.el | 75 |
2 files changed, 20 insertions, 61 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 06d84a4d5a5..4a18af44e21 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-12-08 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * progmodes/flymake.el (flymake-highlight-line): Re-write. | ||
| 4 | (flymake-make-overlay): Remove arg MOUSE-FACE. | ||
| 5 | (flymake-save-string-to-file, flymake-read-file-to-string): Remove. | ||
| 6 | |||
| 1 | 2013-12-08 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2013-12-08 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | * emulation/cua-rect.el (cua--rectangle-highlight-for-redisplay): | 9 | * emulation/cua-rect.el (cua--rectangle-highlight-for-redisplay): |
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index b5e33ff2574..e81504ce947 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -509,16 +509,6 @@ Create parent directories as needed." | |||
| 509 | (write-region nil nil file-name nil 566) | 509 | (write-region nil nil file-name nil 566) |
| 510 | (flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name)) | 510 | (flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name)) |
| 511 | 511 | ||
| 512 | (defun flymake-save-string-to-file (file-name data) | ||
| 513 | "Save string DATA to file FILE-NAME." | ||
| 514 | (write-region data nil file-name nil 566)) | ||
| 515 | |||
| 516 | (defun flymake-read-file-to-string (file-name) | ||
| 517 | "Read contents of file FILE-NAME and return as a string." | ||
| 518 | (with-temp-buffer | ||
| 519 | (insert-file-contents file-name) | ||
| 520 | (buffer-substring (point-min) (point-max)))) | ||
| 521 | |||
| 522 | (defun flymake-process-filter (process output) | 512 | (defun flymake-process-filter (process output) |
| 523 | "Parse OUTPUT and highlight error lines. | 513 | "Parse OUTPUT and highlight error lines. |
| 524 | It's flymake process filter." | 514 | It's flymake process filter." |
| @@ -697,7 +687,7 @@ line number outside the file being compiled." | |||
| 697 | "Determine whether overlay OV was created by flymake." | 687 | "Determine whether overlay OV was created by flymake." |
| 698 | (and (overlayp ov) (overlay-get ov 'flymake-overlay))) | 688 | (and (overlayp ov) (overlay-get ov 'flymake-overlay))) |
| 699 | 689 | ||
| 700 | (defun flymake-make-overlay (beg end tooltip-text face bitmap mouse-face) | 690 | (defun flymake-make-overlay (beg end tooltip-text face bitmap) |
| 701 | "Allocate a flymake overlay in range BEG and END." | 691 | "Allocate a flymake overlay in range BEG and END." |
| 702 | (when (not (flymake-region-has-flymake-overlays beg end)) | 692 | (when (not (flymake-region-has-flymake-overlays beg end)) |
| 703 | (let ((ov (make-overlay beg end nil t t)) | 693 | (let ((ov (make-overlay beg end nil t t)) |
| @@ -708,7 +698,6 @@ line number outside the file being compiled." | |||
| 708 | bitmap | 698 | bitmap |
| 709 | (list bitmap))))))) | 699 | (list bitmap))))))) |
| 710 | (overlay-put ov 'face face) | 700 | (overlay-put ov 'face face) |
| 711 | (overlay-put ov 'mouse-face mouse-face) | ||
| 712 | (overlay-put ov 'help-echo tooltip-text) | 701 | (overlay-put ov 'help-echo tooltip-text) |
| 713 | (overlay-put ov 'flymake-overlay t) | 702 | (overlay-put ov 'flymake-overlay t) |
| 714 | (overlay-put ov 'priority 100) | 703 | (overlay-put ov 'priority 100) |
| @@ -760,42 +749,19 @@ Return t if it has at least one flymake overlay, nil if no overlay." | |||
| 760 | Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting." | 749 | Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting." |
| 761 | (goto-char (point-min)) | 750 | (goto-char (point-min)) |
| 762 | (forward-line (1- line-no)) | 751 | (forward-line (1- line-no)) |
| 763 | (let* ((line-beg (point-at-bol)) | 752 | (pcase-let* ((beg (progn (back-to-indentation) (point))) |
| 764 | (line-end (point-at-eol)) | 753 | (end (progn |
| 765 | (beg line-beg) | 754 | (end-of-line) |
| 766 | (end line-end) | 755 | (skip-chars-backward " \t\f\t\n" beg) |
| 767 | (tooltip-text (flymake-ler-text (nth 0 line-err-info-list))) | 756 | (if (eq (point) beg) |
| 768 | (face nil) | 757 | (line-beginning-position 2) |
| 769 | (bitmap nil)) | 758 | (point)))) |
| 770 | 759 | (tooltip-text (mapconcat #'flymake-ler-text line-err-info-list "\n")) | |
| 771 | (goto-char line-beg) | 760 | (`(,face ,bitmap) |
| 772 | (while (looking-at "[ \t]") | 761 | (if (> (flymake-get-line-err-count line-err-info-list "e") 0) |
| 773 | (forward-char)) | 762 | (list 'flymake-errline flymake-error-bitmap) |
| 774 | 763 | (list 'flymake-warnline flymake-warning-bitmap)))) | |
| 775 | (setq beg (point)) | 764 | (flymake-make-overlay beg end tooltip-text face bitmap))) |
| 776 | |||
| 777 | (goto-char line-end) | ||
| 778 | (while (and (looking-at "[ \t\r\n]") (> (point) 1)) | ||
| 779 | (backward-char)) | ||
| 780 | |||
| 781 | (setq end (1+ (point))) | ||
| 782 | |||
| 783 | (when (<= end beg) | ||
| 784 | (setq beg line-beg) | ||
| 785 | (setq end line-end)) | ||
| 786 | |||
| 787 | (when (= end beg) | ||
| 788 | (goto-char end) | ||
| 789 | (forward-line) | ||
| 790 | (setq end (point))) | ||
| 791 | |||
| 792 | (if (> (flymake-get-line-err-count line-err-info-list "e") 0) | ||
| 793 | (setq face 'flymake-errline | ||
| 794 | bitmap flymake-error-bitmap) | ||
| 795 | (setq face 'flymake-warnline | ||
| 796 | bitmap flymake-warning-bitmap)) | ||
| 797 | |||
| 798 | (flymake-make-overlay beg end tooltip-text face bitmap nil))) | ||
| 799 | 765 | ||
| 800 | (defun flymake-parse-err-lines (err-info-list lines) | 766 | (defun flymake-parse-err-lines (err-info-list lines) |
| 801 | "Parse err LINES, store info in ERR-INFO-LIST." | 767 | "Parse err LINES, store info in ERR-INFO-LIST." |
| @@ -883,19 +849,6 @@ Convert it to flymake internal format." | |||
| 883 | Use `flymake-reformat-err-line-patterns-from-compile-el' to add patterns | 849 | Use `flymake-reformat-err-line-patterns-from-compile-el' to add patterns |
| 884 | from compile.el") | 850 | from compile.el") |
| 885 | 851 | ||
| 886 | ;;(defcustom flymake-err-line-patterns | ||
| 887 | ;; '( | ||
| 888 | ;; ; MS Visual C++ 6.0 | ||
| 889 | ;; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)" | ||
| 890 | ;; 1 3 4) | ||
| 891 | ;; ; jikes | ||
| 892 | ;; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\):[ \t\n]*\\(.+\\)\\)" | ||
| 893 | ;; 1 3 4)) | ||
| 894 | ;; "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx)" | ||
| 895 | ;; :group 'flymake | ||
| 896 | ;; :type '(repeat (string number number number)) | ||
| 897 | ;;) | ||
| 898 | |||
| 899 | (define-obsolete-variable-alias 'flymake-warning-re 'flymake-warning-predicate "24.4") | 852 | (define-obsolete-variable-alias 'flymake-warning-re 'flymake-warning-predicate "24.4") |
| 900 | (defvar flymake-warning-predicate "^[wW]arning" | 853 | (defvar flymake-warning-predicate "^[wW]arning" |
| 901 | "Predicate matching against error text to detect a warning. | 854 | "Predicate matching against error text to detect a warning. |