Mercurial > emacs
comparison lisp/progmodes/flymake.el @ 60904:6c1fb526eda5
Use with-current-buffer.
(flymake-float-time, flymake-get-temp-dir, flymake-replace-regexp-in-string)
(flymake-line-beginning-position, flymake-current-row, flymake-selected-frame)
(flymake-line-end-position, flymake-popup-menu): Avoid testing for `xemacs'.
(flymake-nop): Move.
(flymake-region-has-flymake-overlays): Return the computed value.
(flymake-reformat-err-line-patterns-from-compile-el): Use dolist.
Remove unused var `endline'.
(flymake-get-line-count): Remove unused function.
(flymake-display-err-menu-for-current-line): Unused var `move-mouse-pos'.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 24 Mar 2005 22:55:54 +0000 |
parents | 29db3b79c3fa |
children | 6611fdf35049 |
comparison
equal
deleted
inserted
replaced
60903:29db3b79c3fa | 60904:6c1fb526eda5 |
---|---|
47 (defsubst flymake-makehash (&optional test) | 47 (defsubst flymake-makehash (&optional test) |
48 (if (fboundp 'make-hash-table) | 48 (if (fboundp 'make-hash-table) |
49 (if test (make-hash-table :test test) (make-hash-table)) | 49 (if test (make-hash-table :test test) (make-hash-table)) |
50 (makehash test))) | 50 (makehash test))) |
51 | 51 |
52 (defun flymake-float-time () | 52 (defalias 'flymake-float-time |
53 (if (featurep 'xemacs) | 53 (if (fboundp 'float-time) |
54 (let ((tm (current-time))) | 54 'float-time |
55 (multiple-value-bind (s0 s1 s2) (current-time) | 55 (lambda () |
56 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2)))) | 56 (multiple-value-bind (s0 s1 s2) (current-time) |
57 (float-time))) | 57 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2)))))) |
58 | 58 |
59 (defsubst flymake-replace-regexp-in-string (regexp rep str) | 59 (defsubst flymake-replace-regexp-in-string (regexp rep str) |
60 (if (featurep 'xemacs) | 60 (if (fboundp 'replace-regexp-in-string) |
61 (replace-in-string str regexp rep) | 61 (replace-regexp-in-string regexp rep str) |
62 (replace-regexp-in-string regexp rep str))) | 62 (replace-in-string str regexp rep))) |
63 | 63 |
64 (defun flymake-split-string (str pattern) | 64 (defun flymake-split-string (str pattern) |
65 "Split, then remove first and/or last in case it's empty." | 65 "Split, then remove first and/or last in case it's empty." |
66 (let* ((splitted (split-string str pattern))) | 66 (let* ((splitted (split-string str pattern))) |
67 (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0)))) | 67 (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0)))) |
69 (if (and (> (length splitted) 0) (= 0 (length (elt splitted (1- (length splitted)))))) | 69 (if (and (> (length splitted) 0) (= 0 (length (elt splitted (1- (length splitted)))))) |
70 (setq splitted (reverse (cdr (reverse splitted))))) | 70 (setq splitted (reverse (cdr (reverse splitted))))) |
71 splitted)) | 71 splitted)) |
72 | 72 |
73 (defsubst flymake-get-temp-dir () | 73 (defsubst flymake-get-temp-dir () |
74 (if (featurep 'xemacs) | 74 (if (fboundp 'temp-directory) |
75 (temp-directory) | 75 (temp-directory) |
76 temporary-file-directory)) | 76 temporary-file-directory)) |
77 | 77 |
78 (defun flymake-line-beginning-position () | 78 (defalias 'flymake-line-beginning-position |
79 (save-excursion | 79 (if (fboundp 'line-beginning-position) |
80 (beginning-of-line) | 80 'line-beginning-position |
81 (point))) | 81 (lambda (&optional arg) (save-excursion (beginning-of-line arg) (point))))) |
82 | 82 |
83 (defun flymake-line-end-position () | 83 (defalias 'flymake-line-end-position |
84 (save-excursion | 84 (if (fboundp 'line-end-position) |
85 (end-of-line) | 85 'line-end-position |
86 (point))) | 86 (lambda (&optional arg) (save-excursion (end-of-line arg) (point))))) |
87 | 87 |
88 (defun flymake-popup-menu (pos menu-data) | 88 (defun flymake-popup-menu (pos menu-data) |
89 (if (featurep 'xemacs) | 89 (if (and (fboundp 'popup-menu) (fboundp 'make-event)) |
90 (let* ((x-pos (nth 0 (nth 0 pos))) | 90 (let* ((x-pos (nth 0 (nth 0 pos))) |
91 (y-pos (nth 1 (nth 0 pos))) | 91 (y-pos (nth 1 (nth 0 pos))) |
92 (fake-event-props '(button 1 x 1 y 1))) | 92 (fake-event-props '(button 1 x 1 y 1))) |
93 (setq fake-event-props (plist-put fake-event-props 'x x-pos)) | 93 (setq fake-event-props (plist-put fake-event-props 'x x-pos)) |
94 (setq fake-event-props (plist-put fake-event-props 'y y-pos)) | 94 (setq fake-event-props (plist-put fake-event-props 'y y-pos)) |
102 (setq menu-commands (mapcar (lambda (foo) | 102 (setq menu-commands (mapcar (lambda (foo) |
103 (cons (nth 0 foo) (nth 1 foo))) | 103 (cons (nth 0 foo) (nth 1 foo))) |
104 menu-items)) | 104 menu-items)) |
105 (list menu-title (cons "" menu-commands)))) | 105 (list menu-title (cons "" menu-commands)))) |
106 | 106 |
107 (if (featurep 'xemacs) (progn | |
108 | |
107 (defun flymake-nop ()) | 109 (defun flymake-nop ()) |
108 | |
109 (if (featurep 'xemacs) (progn | |
110 | 110 |
111 (defun flymake-make-xemacs-menu (menu-data) | 111 (defun flymake-make-xemacs-menu (menu-data) |
112 (let* ((menu-title (nth 0 menu-data)) | 112 (let* ((menu-title (nth 0 menu-data)) |
113 (menu-items (nth 1 menu-data)) | 113 (menu-items (nth 1 menu-data)) |
114 (menu-commands nil)) | 114 (menu-commands nil)) |
132 | 132 |
133 )) ;; xemacs | 133 )) ;; xemacs |
134 | 134 |
135 (defun flymake-current-row () | 135 (defun flymake-current-row () |
136 "Return current row number in current frame." | 136 "Return current row number in current frame." |
137 (if (featurep 'xemacs) | 137 (if (fboundp 'window-edges) |
138 (count-lines (window-start) (point)) | 138 (+ (car (cdr (window-edges))) (count-lines (window-start) (point))) |
139 (+ (car (cdr (window-edges))) (count-lines (window-start) (point))))) | 139 (count-lines (window-start) (point)))) |
140 | 140 |
141 (defun flymake-selected-frame () | 141 (defun flymake-selected-frame () |
142 (if (featurep 'xemacs) | 142 (if (fboundp 'window-edges) |
143 (selected-window) | 143 (selected-frame) |
144 (selected-frame))) | 144 (selected-window))) |
145 | 145 |
146 ;;;; ]] | 146 ;;;; ]] |
147 | 147 |
148 (defcustom flymake-log-level -1 | 148 (defcustom flymake-log-level -1 |
149 "Logging level, only messages with level > flymake-log-level will not be logged | 149 "Logging level, only messages with level lower or equal will be logged. |
150 -1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG" | 150 -1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG" |
151 :group 'flymake | 151 :group 'flymake |
152 :type 'integer) | 152 :type 'integer) |
153 | 153 |
154 (defun flymake-log (level text &rest args) | 154 (defun flymake-log (level text &rest args) |
197 (unless (bufferp buffer) | 197 (unless (bufferp buffer) |
198 (error "Invalid buffer")) | 198 (error "Invalid buffer")) |
199 | 199 |
200 (if (eq buffer (current-buffer)) | 200 (if (eq buffer (current-buffer)) |
201 (symbol-value var-name) | 201 (symbol-value var-name) |
202 (save-excursion | 202 (with-current-buffer buffer |
203 (set-buffer buffer) | |
204 (symbol-value var-name)))) | 203 (symbol-value var-name)))) |
205 | 204 |
206 (defun flymake-set-buffer-var (buffer var-name var-value) | 205 (defun flymake-set-buffer-var (buffer var-name var-value) |
207 "Switch to BUFFER if necessary and set local variable VAR-NAME to VAR-VALUE." | 206 "Switch to BUFFER if necessary and set local variable VAR-NAME to VAR-VALUE." |
208 (unless (bufferp buffer) | 207 (unless (bufferp buffer) |
209 (error "Invalid buffer")) | 208 (error "Invalid buffer")) |
210 | 209 |
211 (if (eq buffer (current-buffer)) | 210 (if (eq buffer (current-buffer)) |
212 (set var-name var-value) | 211 (set var-name var-value) |
213 (save-excursion | 212 (with-current-buffer buffer |
214 (set-buffer buffer) | |
215 (set var-name var-value)))) | 213 (set var-name var-value)))) |
216 | 214 |
217 (defvar flymake-buffer-data (flymake-makehash) | 215 (defvar flymake-buffer-data (flymake-makehash) |
218 "Data specific to syntax check tool, in name-value pairs.") | 216 "Data specific to syntax check tool, in name-value pairs.") |
219 | 217 |
535 (insert rep))) | 533 (insert rep))) |
536 | 534 |
537 (defun flymake-read-file-to-temp-buffer (file-name) | 535 (defun flymake-read-file-to-temp-buffer (file-name) |
538 "Insert contents of FILE-NAME into newly created temp buffer." | 536 "Insert contents of FILE-NAME into newly created temp buffer." |
539 (let* ((temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (file-name-nondirectory file-name)))))) | 537 (let* ((temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (file-name-nondirectory file-name)))))) |
540 (save-excursion | 538 (with-current-buffer temp-buffer |
541 (set-buffer temp-buffer) | |
542 (insert-file-contents file-name)) | 539 (insert-file-contents file-name)) |
543 temp-buffer)) | 540 temp-buffer)) |
544 | 541 |
545 (defun flymake-copy-buffer-to-temp-buffer (buffer) | 542 (defun flymake-copy-buffer-to-temp-buffer (buffer) |
546 "Copy contents of BUFFER into newly created temp buffer." | 543 "Copy contents of BUFFER into newly created temp buffer." |
547 (let ((contents nil) | 544 (let ((contents nil) |
548 (temp-buffer nil)) | 545 (temp-buffer nil)) |
549 (save-excursion | 546 (with-current-buffer buffer |
550 (set-buffer buffer) | |
551 (setq contents (buffer-string)) | 547 (setq contents (buffer-string)) |
552 | 548 |
553 (setq temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (buffer-name buffer))))) | 549 (setq temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (buffer-name buffer))))) |
554 (set-buffer temp-buffer) | 550 (set-buffer temp-buffer) |
555 (insert contents)) | 551 (insert contents)) |
616 nil)))) | 612 nil)))) |
617 | 613 |
618 (defun flymake-save-buffer-in-file (buffer file-name) | 614 (defun flymake-save-buffer-in-file (buffer file-name) |
619 (or buffer | 615 (or buffer |
620 (error "Invalid buffer")) | 616 (error "Invalid buffer")) |
621 (save-excursion | 617 (with-current-buffer buffer |
622 (save-restriction | 618 (save-restriction |
623 (set-buffer buffer) | |
624 (widen) | 619 (widen) |
625 (make-directory (file-name-directory file-name) 1) | 620 (make-directory (file-name-directory file-name) 1) |
626 (write-region (point-min) (point-max) file-name nil 566))) | 621 (write-region (point-min) (point-max) file-name nil 566))) |
627 (flymake-log 3 "saved buffer %s in file %s" (buffer-name buffer) file-name)) | 622 (flymake-log 3 "saved buffer %s in file %s" (buffer-name buffer) file-name)) |
628 | 623 |
663 | 658 |
664 (flymake-unreg-names pid) | 659 (flymake-unreg-names pid) |
665 (delete-process process) | 660 (delete-process process) |
666 | 661 |
667 (when source-buffer | 662 (when source-buffer |
668 (save-excursion | 663 (with-current-buffer source-buffer |
669 (set-buffer source-buffer) | |
670 | 664 |
671 (flymake-parse-residual source-buffer) | 665 (flymake-parse-residual source-buffer) |
672 (flymake-post-syntax-check source-buffer exit-status command) | 666 (flymake-post-syntax-check source-buffer exit-status command) |
673 (flymake-set-buffer-is-running source-buffer nil)))) | 667 (flymake-set-buffer-is-running source-buffer nil)))) |
674 (error | 668 (error |
704 (flymake-report-status source-buffer nil ""))) ; "STOPPED" | 698 (flymake-report-status source-buffer nil ""))) ; "STOPPED" |
705 (flymake-report-status source-buffer (format "%d/%d" err-count warn-count) "")))) | 699 (flymake-report-status source-buffer (format "%d/%d" err-count warn-count) "")))) |
706 | 700 |
707 (defun flymake-parse-output-and-residual (source-buffer output) | 701 (defun flymake-parse-output-and-residual (source-buffer output) |
708 "Split OUTPUT into lines, merge in residual if necessary." | 702 "Split OUTPUT into lines, merge in residual if necessary." |
709 (save-excursion | 703 (with-current-buffer source-buffer |
710 (set-buffer source-buffer) | |
711 (let* ((buffer-residual (flymake-get-buffer-output-residual source-buffer)) | 704 (let* ((buffer-residual (flymake-get-buffer-output-residual source-buffer)) |
712 (total-output (if buffer-residual (concat buffer-residual output) output)) | 705 (total-output (if buffer-residual (concat buffer-residual output) output)) |
713 (lines-and-residual (flymake-split-output total-output)) | 706 (lines-and-residual (flymake-split-output total-output)) |
714 (lines (nth 0 lines-and-residual)) | 707 (lines (nth 0 lines-and-residual)) |
715 (new-residual (nth 1 lines-and-residual))) | 708 (new-residual (nth 1 lines-and-residual))) |
719 (flymake-get-buffer-new-err-info source-buffer) | 712 (flymake-get-buffer-new-err-info source-buffer) |
720 source-buffer lines))))) | 713 source-buffer lines))))) |
721 | 714 |
722 (defun flymake-parse-residual (source-buffer) | 715 (defun flymake-parse-residual (source-buffer) |
723 "Parse residual if it's non empty." | 716 "Parse residual if it's non empty." |
724 (save-excursion | 717 (with-current-buffer source-buffer |
725 (set-buffer source-buffer) | |
726 (when (flymake-get-buffer-output-residual source-buffer) | 718 (when (flymake-get-buffer-output-residual source-buffer) |
727 (flymake-set-buffer-new-err-info source-buffer (flymake-parse-err-lines | 719 (flymake-set-buffer-new-err-info source-buffer (flymake-parse-err-lines |
728 (flymake-get-buffer-new-err-info source-buffer) | 720 (flymake-get-buffer-new-err-info source-buffer) |
729 source-buffer | 721 source-buffer |
730 (list (flymake-get-buffer-output-residual source-buffer)))) | 722 (list (flymake-get-buffer-output-residual source-buffer)))) |
844 (setq count (1- count)))) | 836 (setq count (1- count)))) |
845 err-info-list) | 837 err-info-list) |
846 | 838 |
847 (defun flymake-highlight-err-lines (buffer err-info-list) | 839 (defun flymake-highlight-err-lines (buffer err-info-list) |
848 "Highlight error lines in BUFFER using info from ERR-INFO-LIST." | 840 "Highlight error lines in BUFFER using info from ERR-INFO-LIST." |
849 (save-excursion | 841 (with-current-buffer buffer |
850 (set-buffer buffer) | |
851 (let* ((idx 0) | 842 (let* ((idx 0) |
852 (count (length err-info-list))) | 843 (count (length err-info-list))) |
853 (while (< idx count) | 844 (while (< idx count) |
854 (flymake-highlight-line (car (nth idx err-info-list)) (nth 1 (nth idx err-info-list))) | 845 (flymake-highlight-line (car (nth idx err-info-list)) (nth 1 (nth idx err-info-list))) |
855 (setq idx (1+ idx)))))) | 846 (setq idx (1+ idx)))))) |
871 ov) | 862 ov) |
872 (flymake-log 3 "created an overlay at (%d-%d)" beg end))) | 863 (flymake-log 3 "created an overlay at (%d-%d)" beg end))) |
873 | 864 |
874 (defun flymake-delete-own-overlays (buffer) | 865 (defun flymake-delete-own-overlays (buffer) |
875 "Delete all flymake overlays in BUFFER." | 866 "Delete all flymake overlays in BUFFER." |
876 (save-excursion | 867 (with-current-buffer buffer |
877 (set-buffer buffer) | |
878 (let ((ov (overlays-in (point-min) (point-max)))) | 868 (let ((ov (overlays-in (point-min) (point-max)))) |
879 (while (consp ov) | 869 (while (consp ov) |
880 (when (flymake-overlay-p (car ov)) | 870 (when (flymake-overlay-p (car ov)) |
881 (delete-overlay (car ov)) | 871 (delete-overlay (car ov)) |
882 ;;+(flymake-log 3 "deleted overlay %s" ov) | 872 ;;+(flymake-log 3 "deleted overlay %s" ov) |
889 (let ((ov (overlays-in beg end)) | 879 (let ((ov (overlays-in beg end)) |
890 (has-flymake-overlays nil)) | 880 (has-flymake-overlays nil)) |
891 (while (consp ov) | 881 (while (consp ov) |
892 (when (flymake-overlay-p (car ov)) | 882 (when (flymake-overlay-p (car ov)) |
893 (setq has-flymake-overlays t)) | 883 (setq has-flymake-overlays t)) |
894 (setq ov (cdr ov))))) | 884 (setq ov (cdr ov))) |
885 has-flymake-overlays)) | |
895 | 886 |
896 (defface flymake-errline-face | 887 (defface flymake-errline-face |
897 ;;+ '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) | 888 ;;+ '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) |
898 ;;+ '((((class color)) (:underline "OrangeRed")) | 889 ;;+ '((((class color)) (:underline "OrangeRed")) |
899 '((((class color)) (:background "LightPink")) | 890 '((((class color)) (:background "LightPink")) |
984 | 975 |
985 (defun flymake-reformat-err-line-patterns-from-compile-el (original-list) | 976 (defun flymake-reformat-err-line-patterns-from-compile-el (original-list) |
986 "Grab error line patterns from ORIGINAL-LIST in compile.el format. | 977 "Grab error line patterns from ORIGINAL-LIST in compile.el format. |
987 Convert it to flymake internal format." | 978 Convert it to flymake internal format." |
988 (let* ((converted-list '())) | 979 (let* ((converted-list '())) |
989 (mapcar | 980 (dolist (item original-list) |
990 (lambda (item) | 981 (setq item (cdr item)) |
991 (setq item (cdr item)) | 982 (let ((regexp (nth 0 item)) |
992 (let ((regexp (nth 0 item)) | 983 (file (nth 1 item)) |
993 (file (nth 1 item)) | 984 (line (nth 2 item)) |
994 (line (nth 2 item)) | 985 (col (nth 3 item))) |
995 (col (nth 3 item)) | 986 (if (consp file) (setq file (car file))) |
996 end-line) | 987 (if (consp line) (setq line (car line))) |
997 (if (consp file) (setq file (car file))) | 988 (if (consp col) (setq col (car col))) |
998 (if (consp line) (setq end-line (cdr line) line (car line))) | 989 |
999 (if (consp col) (setq col (car col))) | 990 (when (not (functionp line)) |
1000 | 991 (setq converted-list (cons (list regexp file line col) converted-list))))) |
1001 (when (not (functionp line)) | |
1002 (setq converted-list (cons (list regexp file line col) converted-list))))) | |
1003 original-list) | |
1004 converted-list)) | 992 converted-list)) |
1005 | 993 |
1006 (eval-when-compile | 994 (eval-when-compile |
1007 (require 'compile)) | 995 (require 'compile)) |
1008 | 996 |
1209 ) | 1197 ) |
1210 | 1198 |
1211 (defun flymake-get-program-dir (buffer) | 1199 (defun flymake-get-program-dir (buffer) |
1212 "Get dir to start program in." | 1200 "Get dir to start program in." |
1213 (unless (bufferp buffer) | 1201 (unless (bufferp buffer) |
1214 (error "Invlid buffer")) | 1202 (error "Invalid buffer")) |
1215 (save-excursion | 1203 (with-current-buffer buffer |
1216 (set-buffer buffer) | |
1217 default-directory)) | 1204 default-directory)) |
1218 | 1205 |
1219 (defun flymake-safe-delete-file (file-name) | 1206 (defun flymake-safe-delete-file (file-name) |
1220 (when (and file-name (file-exists-p file-name)) | 1207 (when (and file-name (file-exists-p file-name)) |
1221 (delete-file file-name) | 1208 (delete-file file-name) |
1236 | 1223 |
1237 (defun flymake-start-syntax-check (buffer) | 1224 (defun flymake-start-syntax-check (buffer) |
1238 "Start syntax checking for buffer BUFFER." | 1225 "Start syntax checking for buffer BUFFER." |
1239 (unless (bufferp buffer) | 1226 (unless (bufferp buffer) |
1240 (error "Expected a buffer")) | 1227 (error "Expected a buffer")) |
1241 (save-excursion | 1228 (with-current-buffer buffer |
1242 (set-buffer buffer) | |
1243 (flymake-log 3 "flymake is running: %s" (flymake-get-buffer-is-running buffer)) | 1229 (flymake-log 3 "flymake is running: %s" (flymake-get-buffer-is-running buffer)) |
1244 (when (and (not (flymake-get-buffer-is-running buffer)) | 1230 (when (and (not (flymake-get-buffer-is-running buffer)) |
1245 (flymake-can-syntax-check-file (buffer-file-name buffer))) | 1231 (flymake-can-syntax-check-file (buffer-file-name buffer))) |
1246 (when (or (not flymake-compilation-prevents-syntax-check) | 1232 (when (or (not flymake-compilation-prevents-syntax-check) |
1247 (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP") | 1233 (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP") |
1383 | 1369 |
1384 (defun flymake-on-timer-event (buffer) | 1370 (defun flymake-on-timer-event (buffer) |
1385 "Start a syntax check for buffer BUFFER if necessary." | 1371 "Start a syntax check for buffer BUFFER if necessary." |
1386 ;;+(flymake-log 3 "timer: running=%s, time=%s, cur-time=%s" (flymake-get-buffer-is-running buffer) (flymake-get-buffer-last-change-time buffer) (flymake-float-time)) | 1372 ;;+(flymake-log 3 "timer: running=%s, time=%s, cur-time=%s" (flymake-get-buffer-is-running buffer) (flymake-get-buffer-last-change-time buffer) (flymake-float-time)) |
1387 (when (and (bufferp buffer) (not (flymake-get-buffer-is-running buffer))) | 1373 (when (and (bufferp buffer) (not (flymake-get-buffer-is-running buffer))) |
1388 (save-excursion | 1374 (with-current-buffer buffer |
1389 (set-buffer buffer) | |
1390 (when (and (flymake-get-buffer-last-change-time buffer) | 1375 (when (and (flymake-get-buffer-last-change-time buffer) |
1391 (> (flymake-float-time) (+ flymake-no-changes-timeout (flymake-get-buffer-last-change-time buffer)))) | 1376 (> (flymake-float-time) (+ flymake-no-changes-timeout (flymake-get-buffer-last-change-time buffer)))) |
1392 (flymake-set-buffer-last-change-time buffer nil) | 1377 (flymake-set-buffer-last-change-time buffer nil) |
1393 (flymake-log 3 "starting syntax check as more than 1 second passed since last change") | 1378 (flymake-log 3 "starting syntax check as more than 1 second passed since last change") |
1394 (flymake-start-syntax-check buffer))))) | 1379 (flymake-start-syntax-check buffer))))) |
1403 (interactive) | 1388 (interactive) |
1404 (let ((beg (point-min)) | 1389 (let ((beg (point-min)) |
1405 (end (if (= (point) (point-max)) (point) (1+ (point))))) | 1390 (end (if (= (point) (point-max)) (point) (1+ (point))))) |
1406 (count-lines beg end))) | 1391 (count-lines beg end))) |
1407 | 1392 |
1408 (defun flymake-get-line-count (buffer) | |
1409 "Return number of lines in buffer BUFFER." | |
1410 (unless (bufferp buffer) | |
1411 (error "Invalid buffer")) | |
1412 (save-excursion | |
1413 (set-buffer buffer) | |
1414 (count-lines (point-min) (point-max)))) | |
1415 | |
1416 (defun flymake-count-lines (buffer) | 1393 (defun flymake-count-lines (buffer) |
1417 "Return number of lines in buffer BUFFER." | 1394 "Return number of lines in buffer BUFFER." |
1418 (save-excursion | 1395 (with-current-buffer buffer |
1419 (set-buffer buffer) | |
1420 (count-lines (point-min) (point-max)))) | 1396 (count-lines (point-min) (point-max)))) |
1421 | 1397 |
1422 (defun flymake-get-point-pixel-pos () | 1398 (defun flymake-get-point-pixel-pos () |
1423 "Return point position in pixels: (x, y)." | 1399 "Return point position in pixels: (x, y)." |
1424 (let ((mouse-pos (mouse-position)) | 1400 (let ((mouse-pos (mouse-position)) |
1441 (let* ((line-no (flymake-current-line-no)) | 1417 (let* ((line-no (flymake-current-line-no)) |
1442 (line-err-info-list (nth 0 (flymake-find-err-info (flymake-get-buffer-err-info (current-buffer)) line-no))) | 1418 (line-err-info-list (nth 0 (flymake-find-err-info (flymake-get-buffer-err-info (current-buffer)) line-no))) |
1443 (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) | 1419 (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) |
1444 (choice nil) | 1420 (choice nil) |
1445 (mouse-pos (flymake-get-point-pixel-pos)) | 1421 (mouse-pos (flymake-get-point-pixel-pos)) |
1446 (moved-mouse-pos (list (car mouse-pos) (+ 10 (car (cdr mouse-pos))))) | |
1447 (menu-pos (list (flymake-get-point-pixel-pos) (selected-window)))) | 1422 (menu-pos (list (flymake-get-point-pixel-pos) (selected-window)))) |
1448 (if menu-data | 1423 (if menu-data |
1449 (progn | 1424 (progn |
1450 (setq choice (flymake-popup-menu menu-pos menu-data)) | 1425 (setq choice (flymake-popup-menu menu-pos menu-data)) |
1451 (flymake-log 3 "choice=%s" choice) | 1426 (flymake-log 3 "choice=%s" choice) |
1523 (flymake-set-buffer-var buffer 'flymake-mode-line-status status)) | 1498 (flymake-set-buffer-var buffer 'flymake-mode-line-status status)) |
1524 | 1499 |
1525 (defun flymake-report-status (buffer e-w &optional status) | 1500 (defun flymake-report-status (buffer e-w &optional status) |
1526 "Show status in mode line." | 1501 "Show status in mode line." |
1527 (when (bufferp buffer) | 1502 (when (bufferp buffer) |
1528 (save-excursion | 1503 (with-current-buffer buffer |
1529 (set-buffer buffer) | |
1530 (when e-w | 1504 (when e-w |
1531 (flymake-set-buffer-mode-line-e-w buffer e-w) | 1505 (flymake-set-buffer-mode-line-e-w buffer e-w) |
1532 ) | 1506 ) |
1533 (when status | 1507 (when status |
1534 (flymake-set-buffer-mode-line-status buffer status)) | 1508 (flymake-set-buffer-mode-line-status buffer status)) |
1551 (defun flymake-report-fatal-status (buffer status warning) | 1525 (defun flymake-report-fatal-status (buffer status warning) |
1552 "Display a warning and switch flymake mode off." | 1526 "Display a warning and switch flymake mode off." |
1553 (when flymake-gui-warnings-enabled | 1527 (when flymake-gui-warnings-enabled |
1554 (flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning)) | 1528 (flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning)) |
1555 ) | 1529 ) |
1556 (save-excursion | 1530 (with-current-buffer buffer |
1557 (set-buffer buffer) | |
1558 (flymake-mode 0) | 1531 (flymake-mode 0) |
1559 (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s" | 1532 (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s" |
1560 (buffer-name buffer) status warning))) | 1533 (buffer-name buffer) status warning))) |
1561 | 1534 |
1562 (defun flymake-mode (&optional arg) | 1535 (defun flymake-mode (&optional arg) |