diff options
| -rw-r--r-- | lisp/ChangeLog | 16 | ||||
| -rw-r--r-- | lisp/progmodes/flymake.el | 248 |
2 files changed, 124 insertions, 140 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c1877a947d0..4af6886a499 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,21 @@ | |||
| 1 | 2006-01-03 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2006-01-03 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * progmodes/flymake.el (flymake-check-start-time) | ||
| 4 | (flymake-check-was-interrupted, flymake-err-info, flymake-is-running) | ||
| 5 | (flymake-last-change-time, flymake-new-err-info, flymake-timer): | ||
| 6 | Move definition, so we can remove redundant earlier declaration. | ||
| 7 | (flymake-replace-regexp-in-string, flymake-split-string) | ||
| 8 | (flymake-get-temp-dir): Use defalias. | ||
| 9 | (flymake-popup-menu): Remove `pos' argument. Use posn-at-point. | ||
| 10 | (flymake-xemacs-window-edges): Remove unused function. | ||
| 11 | (flymake-get-point-pixel-pos): Move. | ||
| 12 | (flymake-pid-to-names, flymake-reg-names) | ||
| 13 | (flymake-get-source-buffer-name, flymake-unreg-names): Remove. | ||
| 14 | Replace by a simple list flymake-processes and by process-buffer. | ||
| 15 | Update callers. Other than simplify the code, it uses buffers rather | ||
| 16 | than buffer-names so it doesn't get confused by uniquify. | ||
| 17 | (flymake-buffer-data): The global value should just be nil. | ||
| 18 | |||
| 3 | * emacs-lisp/bytecomp.el (byte-compile-file-form-defalias): | 19 | * emacs-lisp/bytecomp.el (byte-compile-file-form-defalias): |
| 4 | Optimize the body of a defalias like any other code. | 20 | Optimize the body of a defalias like any other code. |
| 5 | 21 | ||
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 6f5d0855e19..568964705ff 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -1,6 +1,6 @@ | |||
| 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> |
| @@ -32,16 +32,33 @@ | |||
| 32 | 32 | ||
| 33 | ;;; Code: | 33 | ;;; Code: |
| 34 | 34 | ||
| 35 | ;;;; [[ Silence the byte-compiler | 35 | (defvar flymake-is-running nil |
| 36 | "If t, flymake syntax check process is running for the current buffer.") | ||
| 37 | (make-variable-buffer-local 'flymake-is-running) | ||
| 36 | 38 | ||
| 37 | (defvar flymake-check-start-time) | 39 | (defvar flymake-timer nil |
| 38 | (defvar flymake-check-was-interrupted) | 40 | "Timer for starting syntax check.") |
| 39 | (defvar flymake-err-info) | 41 | (make-variable-buffer-local 'flymake-timer) |
| 40 | (defvar flymake-is-running) | ||
| 41 | (defvar flymake-last-change-time) | ||
| 42 | (defvar flymake-new-err-info) | ||
| 43 | 42 | ||
| 44 | ;;;; ]] | 43 | (defvar flymake-last-change-time nil |
| 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 |
| @@ -69,25 +86,30 @@ | |||
| 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) |
| @@ -99,20 +121,26 @@ Zero-length substrings at the beginning and end of the list are omitted." | |||
| 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. |
| @@ -121,10 +149,9 @@ MENU-DATA is a list of error and warning messages returned by | |||
| 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 |
| @@ -141,21 +168,10 @@ See `x-popup-menu' for the menu specifier format." | |||
| 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 |
| 158 | 172 | ||
| 173 | (unless (eval-when-compile (fboundp 'posn-at-point)) | ||
| 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) |
| @@ -167,6 +183,24 @@ See `x-popup-menu' for the menu specifier format." | |||
| 167 | (selected-frame) | 183 | (selected-frame) |
| 168 | (selected-window))) | 184 | (selected-window))) |
| 169 | 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) | ||
| 203 | |||
| 170 | ;;;; ]] | 204 | ;;;; ]] |
| 171 | 205 | ||
| 172 | (defcustom flymake-log-level -1 | 206 | (defcustom flymake-log-level -1 |
| @@ -203,24 +237,10 @@ are the string substitutions (see `format')." | |||
| 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 | |||
| 209 | (defun flymake-reg-names (pid source-buffer-name) | ||
| 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 | 242 | ||
| 223 | (defvar flymake-buffer-data (flymake-makehash) | 243 | (defvar flymake-buffer-data nil |
| 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) |
| @@ -604,10 +624,10 @@ Find master file, patch and save it." | |||
| 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)))) | ||
| 609 | 628 | ||
| 610 | (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid) | 629 | (flymake-log 3 "received %d byte(s) of output from process %d" |
| 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))))) |
| @@ -617,18 +637,18 @@ It's flymake process filter." | |||
| 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 |
| @@ -689,11 +709,6 @@ It's flymake process filter." | |||
| 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 | ||
| @@ -703,11 +718,6 @@ It's flymake process filter." | |||
| 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 | 720 | ||
| 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 | |||
| 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)) |
| @@ -1193,11 +1203,10 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 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) |
| @@ -1205,7 +1214,8 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 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" |
| @@ -1216,20 +1226,20 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 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) |
| @@ -1241,31 +1251,6 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1241 | (flymake-stop-all-syntax-checks) | 1251 | (flymake-stop-all-syntax-checks) |
| 1242 | (call-interactively 'compile)) | 1252 | (call-interactively 'compile)) |
| 1243 | 1253 | ||
| 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 | |||
| 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 |
| @@ -1294,33 +1279,16 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 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))) |