comparison lisp/progmodes/flymake.el @ 68002:84f2196866ae

(flymake-check-start-time, flymake-check-was-interrupted, flymake-err-info) (flymake-is-running, flymake-last-change-time, flymake-new-err-info) (flymake-timer): Move definitions, so we can remove earlier declarations. (flymake-replace-regexp-in-string, flymake-split-string) (flymake-get-temp-dir): Use defalias. (flymake-popup-menu): Remove `pos' argument. Use posn-at-point. (flymake-xemacs-window-edges): Remove unused function. (flymake-get-point-pixel-pos): Move. (flymake-pid-to-names, flymake-reg-names) (flymake-get-source-buffer-name, flymake-unreg-names): Remove. Replace by a simple list flymake-processes and by process-buffer. Update callers. Other than simplify the code, it uses buffers rather than buffer-names so it doesn't get confused by uniquify. (flymake-buffer-data): The global value should just be nil.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 03 Jan 2006 18:44:42 +0000
parents 83b7f7a9b7c9
children a45d40da31da
comparison
equal deleted inserted replaced
68001:8e733b93ffdc 68002:84f2196866ae
1 ;;; flymake.el -- a universal on-the-fly syntax checker 1 ;;; flymake.el -- a universal on-the-fly syntax checker
2 2
3 ;; Copyright (C) 2003, 2004, 2005 Free Software Foundation 3 ;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
4 4
5 ;; Author: Pavel Kobiakov <pk_at_work@yahoo.com> 5 ;; Author: Pavel Kobiakov <pk_at_work@yahoo.com>
6 ;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.com> 6 ;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.com>
7 ;; Version: 0.3 7 ;; Version: 0.3
8 ;; Keywords: c languages tools 8 ;; Keywords: c languages tools
30 ;; checks using the external syntax check tool (for C/C++ this 30 ;; checks using the external syntax check tool (for C/C++ this
31 ;; is usually the compiler) 31 ;; is usually the compiler)
32 32
33 ;;; Code: 33 ;;; Code:
34 34
35 ;;;; [[ Silence the byte-compiler 35 (defvar flymake-is-running nil
36 36 "If t, flymake syntax check process is running for the current buffer.")
37 (defvar flymake-check-start-time) 37 (make-variable-buffer-local 'flymake-is-running)
38 (defvar flymake-check-was-interrupted) 38
39 (defvar flymake-err-info) 39 (defvar flymake-timer nil
40 (defvar flymake-is-running) 40 "Timer for starting syntax check.")
41 (defvar flymake-last-change-time) 41 (make-variable-buffer-local 'flymake-timer)
42 (defvar flymake-new-err-info) 42
43 43 (defvar flymake-last-change-time nil
44 ;;;; ]] 44 "Time of last buffer change.")
45 (make-variable-buffer-local 'flymake-last-change-time)
46
47 (defvar flymake-check-start-time nil
48 "Time at which syntax check was started.")
49 (make-variable-buffer-local 'flymake-check-start-time)
50
51 (defvar flymake-check-was-interrupted nil
52 "Non-nil if syntax check was killed by `flymake-compile'.")
53 (make-variable-buffer-local 'flymake-check-was-interrupted)
54
55 (defvar flymake-err-info nil
56 "Sorted list of line numbers and lists of err info in the form (file, err-text).")
57 (make-variable-buffer-local 'flymake-err-info)
58
59 (defvar flymake-new-err-info nil
60 "Same as `flymake-err-info', effective when a syntax check is in progress.")
61 (make-variable-buffer-local 'flymake-new-err-info)
45 62
46 ;;;; [[ Xemacs overlay compatibility 63 ;;;; [[ Xemacs overlay compatibility
47 (if (featurep 'xemacs) (progn 64 (if (featurep 'xemacs) (progn
48 (autoload 'make-overlay "overlay" "Overlay compatibility kit." t) 65 (autoload 'make-overlay "overlay" "Overlay compatibility kit." t)
49 (autoload 'overlayp "overlay" "Overlay compatibility kit." t) 66 (autoload 'overlayp "overlay" "Overlay compatibility kit." t)
67 (if (featurep 'xemacs) 84 (if (featurep 'xemacs)
68 (lambda () 85 (lambda ()
69 (multiple-value-bind (s0 s1 s2) (current-time) 86 (multiple-value-bind (s0 s1 s2) (current-time)
70 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2))))))) 87 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2)))))))
71 88
72 (defsubst flymake-replace-regexp-in-string (regexp rep str) 89 (defalias 'flymake-replace-regexp-in-string
73 (if (fboundp 'replace-in-string) 90 (if (eval-when-compile (fboundp 'replace-regexp-in-string))
74 (replace-in-string str regexp rep) 91 'replace-regexp-in-string
75 (replace-regexp-in-string regexp rep str))) 92 (lambda (regexp rep str)
76 93 (replace-in-string str regexp rep))))
77 (defun flymake-split-string (str pattern) 94
78 "Split STR into a list of substrings bounded by PATTERN. 95 (defalias 'flymake-split-string
96 (if (condition-case nil (equal (split-string " bc " " " t) '("bc"))
97 (error nil))
98 (lambda (str pattern) (split-string str pattern t))
99 (lambda (str pattern)
100 "Split STR into a list of substrings bounded by PATTERN.
79 Zero-length substrings at the beginning and end of the list are omitted." 101 Zero-length substrings at the beginning and end of the list are omitted."
80 (let* ((splitted (split-string str pattern))) 102 (let ((split (split-string str pattern)))
81 (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0)))) 103 (if (and (> (length split) 0) (= 0 (length (elt split 0))))
82 (setq splitted (cdr splitted))) 104 (setq split (cdr split)))
83 (if (and (> (length splitted) 0) (= 0 (length (elt splitted (1- (length splitted)))))) 105 (if (and (> (length split) 0) (= 0 (length (elt split (1- (length split))))))
84 (setq splitted (reverse (cdr (reverse splitted))))) 106 (setq split (nreverse (cdr (nreverse split)))))
85 splitted)) 107 split))))
86 108
87 (defsubst flymake-get-temp-dir () 109 (defalias 'flymake-get-temp-dir
88 (if (fboundp 'temp-directory) 110 (if (fboundp 'temp-directory)
89 (temp-directory) 111 'temp-directory
90 temporary-file-directory)) 112 (lambda () temporary-file-directory)))
91 113
92 (defalias 'flymake-line-beginning-position 114 (defalias 'flymake-line-beginning-position
93 (if (fboundp 'line-beginning-position) 115 (if (fboundp 'line-beginning-position)
94 'line-beginning-position 116 'line-beginning-position
95 (lambda (&optional arg) (save-excursion (beginning-of-line arg) (point))))) 117 (lambda (&optional arg) (save-excursion (beginning-of-line arg) (point)))))
97 (defalias 'flymake-line-end-position 119 (defalias 'flymake-line-end-position
98 (if (fboundp 'line-end-position) 120 (if (fboundp 'line-end-position)
99 'line-end-position 121 'line-end-position
100 (lambda (&optional arg) (save-excursion (end-of-line arg) (point))))) 122 (lambda (&optional arg) (save-excursion (end-of-line arg) (point)))))
101 123
102 (defun flymake-popup-menu (pos menu-data) 124
103 "Pop up the flymake menu at position POS, using the data MENU-DATA. 125 (defun flymake-popup-menu (menu-data)
126 "Pop up the flymake menu at point, using the data MENU-DATA.
104 POS is a list of the form ((X Y) WINDOW), where X and Y are 127 POS is a list of the form ((X Y) WINDOW), where X and Y are
105 pixels positions from the top left corner of WINDOW's frame. 128 pixels positions from the top left corner of WINDOW's frame.
106 MENU-DATA is a list of error and warning messages returned by 129 MENU-DATA is a list of error and warning messages returned by
107 `flymake-make-err-menu-data'." 130 `flymake-make-err-menu-data'."
108 (if (featurep 'xemacs) 131 (if (featurep 'xemacs)
109 (let* ((x-pos (nth 0 (nth 0 pos))) 132 (let* ((pos (flymake-get-point-pixel-pos))
110 (y-pos (nth 1 (nth 0 pos))) 133 (x-pos (nth 0 pos))
134 (y-pos (nth 1 pos))
111 (fake-event-props '(button 1 x 1 y 1))) 135 (fake-event-props '(button 1 x 1 y 1)))
112 (setq fake-event-props (plist-put fake-event-props 'x x-pos)) 136 (setq fake-event-props (plist-put fake-event-props 'x x-pos))
113 (setq fake-event-props (plist-put fake-event-props 'y y-pos)) 137 (setq fake-event-props (plist-put fake-event-props 'y y-pos))
114 (popup-menu (flymake-make-xemacs-menu menu-data) (make-event 'button-press fake-event-props))) 138 (popup-menu (flymake-make-xemacs-menu menu-data)
115 (x-popup-menu pos (flymake-make-emacs-menu menu-data)))) 139 (make-event 'button-press fake-event-props)))
140 (x-popup-menu (if (eval-when-compile (fboundp 'posn-at-point))
141 (posn-at-point)
142 (list (flymake-get-point-pixel-pos) (selected-window)))
143 (flymake-make-emacs-menu menu-data))))
116 144
117 (defun flymake-make-emacs-menu (menu-data) 145 (defun flymake-make-emacs-menu (menu-data)
118 "Return a menu specifier using MENU-DATA. 146 "Return a menu specifier using MENU-DATA.
119 MENU-DATA is a list of error and warning messages returned by 147 MENU-DATA is a list of error and warning messages returned by
120 `flymake-make-err-menu-data'. 148 `flymake-make-err-menu-data'.
121 See `x-popup-menu' for the menu specifier format." 149 See `x-popup-menu' for the menu specifier format."
122 (let* ((menu-title (nth 0 menu-data)) 150 (let* ((menu-title (nth 0 menu-data))
123 (menu-items (nth 1 menu-data)) 151 (menu-items (nth 1 menu-data))
124 (menu-commands nil)) 152 (menu-commands (mapcar (lambda (foo)
125 (setq menu-commands (mapcar (lambda (foo) 153 (cons (nth 0 foo) (nth 1 foo)))
126 (cons (nth 0 foo) (nth 1 foo))) 154 menu-items)))
127 menu-items))
128 (list menu-title (cons "" menu-commands)))) 155 (list menu-title (cons "" menu-commands))))
129 156
130 (if (featurep 'xemacs) (progn 157 (if (featurep 'xemacs) (progn
131 158
132 (defun flymake-nop ()) 159 (defun flymake-nop ())
139 (setq menu-commands (mapcar (lambda (foo) 166 (setq menu-commands (mapcar (lambda (foo)
140 (vector (nth 0 foo) (or (nth 1 foo) '(flymake-nop)) t)) 167 (vector (nth 0 foo) (or (nth 1 foo) '(flymake-nop)) t))
141 menu-items)) 168 menu-items))
142 (cons menu-title menu-commands))) 169 (cons menu-title menu-commands)))
143 170
144 (defun flymake-xemacs-window-edges (&optional window)
145 (let ((edges (window-pixel-edges window))
146 tmp)
147 (setq tmp edges)
148 (setcar tmp (/ (car tmp) (face-width 'default)))
149 (setq tmp (cdr tmp))
150 (setcar tmp (/ (car tmp) (face-height 'default)))
151 (setq tmp (cdr tmp))
152 (setcar tmp (/ (car tmp) (face-width 'default)))
153 (setq tmp (cdr tmp))
154 (setcar tmp (/ (car tmp) (face-height 'default)))
155 edges))
156
157 )) ;; xemacs 171 )) ;; xemacs
172
173 (unless (eval-when-compile (fboundp 'posn-at-point))
158 174
159 (defun flymake-current-row () 175 (defun flymake-current-row ()
160 "Return current row number in current frame." 176 "Return current row number in current frame."
161 (if (fboundp 'window-edges) 177 (if (fboundp 'window-edges)
162 (+ (car (cdr (window-edges))) (count-lines (window-start) (point))) 178 (+ (car (cdr (window-edges))) (count-lines (window-start) (point)))
164 180
165 (defun flymake-selected-frame () 181 (defun flymake-selected-frame ()
166 (if (fboundp 'window-edges) 182 (if (fboundp 'window-edges)
167 (selected-frame) 183 (selected-frame)
168 (selected-window))) 184 (selected-window)))
185
186 (defun flymake-get-point-pixel-pos ()
187 "Return point position in pixels: (x, y)."
188 (let ((mouse-pos (mouse-position))
189 (pixel-pos nil)
190 (ret nil))
191 (if (car (cdr mouse-pos))
192 (progn
193 (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row))
194 (setq pixel-pos (mouse-pixel-position))
195 (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos)))
196 (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos)))))
197 (progn
198 (setq ret '(0 0))))
199 (flymake-log 3 "mouse pos is %s" ret)
200 ret))
201
202 ) ;; End of (unless (fboundp 'posn-at-point)
169 203
170 ;;;; ]] 204 ;;;; ]]
171 205
172 (defcustom flymake-log-level -1 206 (defcustom flymake-log-level -1
173 "Logging level, only messages with level lower or equal will be logged. 207 "Logging level, only messages with level lower or equal will be logged.
201 "Set VAL at position POS in LIST." 235 "Set VAL at position POS in LIST."
202 (let ((tmp (copy-sequence list))) ; (???) 236 (let ((tmp (copy-sequence list))) ; (???)
203 (setcar (nthcdr pos tmp) val) 237 (setcar (nthcdr pos tmp) val)
204 tmp)) 238 tmp))
205 239
206 (defvar flymake-pid-to-names (flymake-makehash) 240 (defvar flymake-processes nil
207 "Hash table mapping PIDs to source buffer names and output files.") 241 "List of currently active flymake processes.")
208 242
209 (defun flymake-reg-names (pid source-buffer-name) 243 (defvar flymake-buffer-data nil
210 "Associate PID with SOURCE-BUFFER-NAME in `flymake-pid-to-names'."
211 (unless (stringp source-buffer-name)
212 (error "Invalid buffer name"))
213 (puthash pid (list source-buffer-name) flymake-pid-to-names))
214
215 (defun flymake-get-source-buffer-name (pid)
216 "Return buffer name associated with PID in `flymake-pid-to-names'."
217 (nth 0 (gethash pid flymake-pid-to-names)))
218
219 (defun flymake-unreg-names (pid)
220 "Remove the entry associated with PID from `flymake-pid-to-names'."
221 (remhash pid flymake-pid-to-names))
222
223 (defvar flymake-buffer-data (flymake-makehash)
224 "Data specific to syntax check tool, in name-value pairs.") 244 "Data specific to syntax check tool, in name-value pairs.")
225 245
226 (make-variable-buffer-local 'flymake-buffer-data) 246 (make-variable-buffer-local 'flymake-buffer-data)
227 247
228 (defun flymake-get-buffer-value (buffer name) 248 (defun flymake-get-buffer-value (buffer name)
602 (buffer-substring (point-min) (point-max)))) 622 (buffer-substring (point-min) (point-max))))
603 623
604 (defun flymake-process-filter (process output) 624 (defun flymake-process-filter (process output)
605 "Parse OUTPUT and highlight error lines. 625 "Parse OUTPUT and highlight error lines.
606 It's flymake process filter." 626 It's flymake process filter."
607 (let* ((pid (process-id process)) 627 (let ((source-buffer (process-buffer process)))
608 (source-buffer (get-buffer (flymake-get-source-buffer-name pid)))) 628
609 629 (flymake-log 3 "received %d byte(s) of output from process %d"
610 (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid) 630 (length output) (process-id process))
611 (when source-buffer 631 (when source-buffer
612 (with-current-buffer source-buffer 632 (with-current-buffer source-buffer
613 (flymake-parse-output-and-residual output))))) 633 (flymake-parse-output-and-residual output)))))
614 634
615 (defun flymake-process-sentinel (process event) 635 (defun flymake-process-sentinel (process event)
616 "Sentinel for syntax check buffers." 636 "Sentinel for syntax check buffers."
617 (if (memq (process-status process) '(signal exit)) 637 (if (memq (process-status process) '(signal exit))
618 (let*((exit-status (process-exit-status process)) 638 (let*((exit-status (process-exit-status process))
619 (command (process-command process)) 639 (command (process-command process))
620 (pid (process-id process)) 640 (source-buffer (process-buffer process))
621 (source-buffer (get-buffer (flymake-get-source-buffer-name pid)))
622 (cleanup-f (flymake-get-cleanup-function (buffer-file-name source-buffer)))) 641 (cleanup-f (flymake-get-cleanup-function (buffer-file-name source-buffer))))
623 642
624 (flymake-log 2 "process %d exited with code %d" pid exit-status) 643 (flymake-log 2 "process %d exited with code %d"
644 (process-id process) exit-status)
625 (condition-case err 645 (condition-case err
626 (progn 646 (progn
627 (flymake-log 3 "cleaning up using %s" cleanup-f) 647 (flymake-log 3 "cleaning up using %s" cleanup-f)
628 (funcall cleanup-f source-buffer) 648 (funcall cleanup-f source-buffer)
629 649
630 (flymake-unreg-names pid)
631 (delete-process process) 650 (delete-process process)
651 (setq flymake-processes (delq process flymake-processes))
632 652
633 (when source-buffer 653 (when source-buffer
634 (with-current-buffer source-buffer 654 (with-current-buffer source-buffer
635 655
636 (flymake-parse-residual) 656 (flymake-parse-residual)
687 (flymake-parse-err-lines 707 (flymake-parse-err-lines
688 flymake-new-err-info 708 flymake-new-err-info
689 (list flymake-output-residual))) 709 (list flymake-output-residual)))
690 (setq flymake-output-residual nil))) 710 (setq flymake-output-residual nil)))
691 711
692 (defvar flymake-err-info nil
693 "Sorted list of line numbers and lists of err info in the form (file, err-text).")
694
695 (make-variable-buffer-local 'flymake-err-info)
696
697 (defun flymake-er-make-er (line-no line-err-info-list) 712 (defun flymake-er-make-er (line-no line-err-info-list)
698 (list line-no line-err-info-list)) 713 (list line-no line-err-info-list))
699 714
700 (defun flymake-er-get-line (err-info) 715 (defun flymake-er-get-line (err-info)
701 (nth 0 err-info)) 716 (nth 0 err-info))
702 717
703 (defun flymake-er-get-line-err-info-list (err-info) 718 (defun flymake-er-get-line-err-info-list (err-info)
704 (nth 1 err-info)) 719 (nth 1 err-info))
705
706 (defvar flymake-new-err-info nil
707 "Same as `flymake-err-info', effective when a syntax check is in progress.")
708
709 (make-variable-buffer-local 'flymake-new-err-info)
710 720
711 ;; getters/setters for line-err-info: (file, line, type, text). 721 ;; getters/setters for line-err-info: (file, line, type, text).
712 (defun flymake-ler-make-ler (file line type text &optional full-file) 722 (defun flymake-ler-make-ler (file line type text &optional full-file)
713 (list file line type text full-file)) 723 (list file line type text full-file))
714 724
1191 (condition-case err 1201 (condition-case err
1192 (progn 1202 (progn
1193 (when dir 1203 (when dir
1194 (let ((default-directory dir)) 1204 (let ((default-directory dir))
1195 (flymake-log 3 "starting process on dir %s" default-directory))) 1205 (flymake-log 3 "starting process on dir %s" default-directory)))
1196 (setq process (get-process (apply 'start-process "flymake-proc" nil cmd args))) 1206 (setq process (apply 'start-process "flymake-proc" (current-buffer) cmd args))
1197 (set-process-sentinel process 'flymake-process-sentinel) 1207 (set-process-sentinel process 'flymake-process-sentinel)
1198 (set-process-filter process 'flymake-process-filter) 1208 (set-process-filter process 'flymake-process-filter)
1199 1209 (push process flymake-processes)
1200 (flymake-reg-names (process-id process) (buffer-name))
1201 1210
1202 (setq flymake-is-running t) 1211 (setq flymake-is-running t)
1203 (setq flymake-last-change-time nil) 1212 (setq flymake-last-change-time nil)
1204 (setq flymake-check-start-time (flymake-float-time)) 1213 (setq flymake-check-start-time (flymake-float-time))
1205 1214
1206 (flymake-report-status nil "*") 1215 (flymake-report-status nil "*")
1207 (flymake-log 2 "started process %d, command=%s, dir=%s" 1216 (flymake-log 2 "started process %d, command=%s, dir=%s"
1208 (process-id process) (process-command process) default-directory) 1217 (process-id process) (process-command process)
1218 default-directory)
1209 process) 1219 process)
1210 (error 1220 (error
1211 (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s" 1221 (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s"
1212 cmd args (error-message-string err))) 1222 cmd args (error-message-string err)))
1213 (source-file-name buffer-file-name) 1223 (source-file-name buffer-file-name)
1214 (cleanup-f (flymake-get-cleanup-function source-file-name))) 1224 (cleanup-f (flymake-get-cleanup-function source-file-name)))
1215 (flymake-log 0 err-str) 1225 (flymake-log 0 err-str)
1216 (funcall cleanup-f (current-buffer)) 1226 (funcall cleanup-f (current-buffer))
1217 (flymake-report-fatal-status "PROCERR" err-str)))))) 1227 (flymake-report-fatal-status "PROCERR" err-str))))))
1218 1228
1219 (defun flymake-kill-process (pid &optional rest) 1229 (defun flymake-kill-process (proc)
1220 "Kill process PID." 1230 "Kill process PROC."
1221 (signal-process pid 9) 1231 (kill-process proc)
1222 (let* ((buffer-name (flymake-get-source-buffer-name pid))) 1232 (let* ((buf (process-buffer proc)))
1223 (when (and buffer-name (get-buffer buffer-name)) 1233 (when (buffer-live-p buf)
1224 (with-current-buffer (get-buffer buffer-name) 1234 (with-current-buffer buf
1225 (setq flymake-check-was-interrupted t)))) 1235 (setq flymake-check-was-interrupted t))))
1226 (flymake-log 1 "killed process %d" pid)) 1236 (flymake-log 1 "killed process %d" (process-id proc)))
1227 1237
1228 (defun flymake-stop-all-syntax-checks () 1238 (defun flymake-stop-all-syntax-checks ()
1229 "Kill all syntax check processes." 1239 "Kill all syntax check processes."
1230 (interactive) 1240 (interactive)
1231 (let ((pids (copy-hash-table flymake-pid-to-names))) 1241 (while flymake-processes
1232 (maphash 'flymake-kill-process pids))) 1242 (flymake-kill-process (pop flymake-processes))))
1233 1243
1234 (defun flymake-compilation-is-running () 1244 (defun flymake-compilation-is-running ()
1235 (and (boundp 'compilation-in-progress) 1245 (and (boundp 'compilation-in-progress)
1236 compilation-in-progress)) 1246 compilation-in-progress))
1237 1247
1238 (defun flymake-compile () 1248 (defun flymake-compile ()
1239 "Kill all flymake syntax checks, start compilation." 1249 "Kill all flymake syntax checks, start compilation."
1240 (interactive) 1250 (interactive)
1241 (flymake-stop-all-syntax-checks) 1251 (flymake-stop-all-syntax-checks)
1242 (call-interactively 'compile)) 1252 (call-interactively 'compile))
1243
1244 (defvar flymake-is-running nil
1245 "If t, flymake syntax check process is running for the current buffer.")
1246
1247 (make-variable-buffer-local 'flymake-is-running)
1248
1249 (defvar flymake-timer nil
1250 "Timer for starting syntax check.")
1251
1252 (make-variable-buffer-local 'flymake-timer)
1253
1254 (defvar flymake-last-change-time nil
1255 "Time of last buffer change.")
1256
1257 (make-variable-buffer-local 'flymake-last-change-time)
1258
1259 (defvar flymake-check-start-time nil
1260 "Time at which syntax check was started.")
1261
1262 (make-variable-buffer-local 'flymake-check-start-time)
1263
1264 (defvar flymake-check-was-interrupted nil
1265 "Non-nil if syntax check was killed by `flymake-compile'.")
1266
1267 (make-variable-buffer-local 'flymake-check-was-interrupted)
1268 1253
1269 (defcustom flymake-no-changes-timeout 0.5 1254 (defcustom flymake-no-changes-timeout 0.5
1270 "Time to wait after last change before starting compilation." 1255 "Time to wait after last change before starting compilation."
1271 :group 'flymake 1256 :group 'flymake
1272 :type 'number) 1257 :type 'number)
1292 1277
1293 (defun flymake-count-lines () 1278 (defun flymake-count-lines ()
1294 "Return number of lines in buffer BUFFER." 1279 "Return number of lines in buffer BUFFER."
1295 (count-lines (point-min) (point-max))) 1280 (count-lines (point-min) (point-max)))
1296 1281
1297 (defun flymake-get-point-pixel-pos ()
1298 "Return point position in pixels: (x, y)."
1299 (let ((mouse-pos (mouse-position))
1300 (pixel-pos nil)
1301 (ret nil))
1302 (if (car (cdr mouse-pos))
1303 (progn
1304 (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row))
1305 (setq pixel-pos (mouse-pixel-position))
1306 (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos)))
1307 (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos)))))
1308 (progn
1309 (setq ret '(0 0))))
1310 (flymake-log 3 "mouse pos is %s" ret)
1311 ret))
1312
1313 (defun flymake-display-err-menu-for-current-line () 1282 (defun flymake-display-err-menu-for-current-line ()
1314 "Display a menu with errors/warnings for current line if it has errors and/or warnings." 1283 "Display a menu with errors/warnings for current line if it has errors and/or warnings."
1315 (interactive) 1284 (interactive)
1316 (let* ((line-no (flymake-current-line-no)) 1285 (let* ((line-no (flymake-current-line-no))
1317 (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))) 1286 (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
1318 (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) 1287 (menu-data (flymake-make-err-menu-data line-no line-err-info-list))
1319 (choice nil) 1288 (choice nil))
1320 (menu-pos (list (flymake-get-point-pixel-pos) (selected-window))))
1321 (if menu-data 1289 (if menu-data
1322 (progn 1290 (progn
1323 (setq choice (flymake-popup-menu menu-pos menu-data)) 1291 (setq choice (flymake-popup-menu menu-data))
1324 (flymake-log 3 "choice=%s" choice) 1292 (flymake-log 3 "choice=%s" choice)
1325 (when choice 1293 (when choice
1326 (eval choice))) 1294 (eval choice)))
1327 (flymake-log 1 "no errors for line %d" line-no)))) 1295 (flymake-log 1 "no errors for line %d" line-no))))
1328 1296