diff options
| author | Leo Liu | 2013-12-08 11:35:32 +0800 |
|---|---|---|
| committer | Leo Liu | 2013-12-08 11:35:32 +0800 |
| commit | a92fa5f1936711cdf36e53aced275adb960474c8 (patch) | |
| tree | 2cab616ba07e66746c709ec1703eddf598c69e6f | |
| parent | 0d9cba29b6737857ea47b9c7d9d9947791e1a5d6 (diff) | |
| download | emacs-a92fa5f1936711cdf36e53aced275adb960474c8.tar.gz emacs-a92fa5f1936711cdf36e53aced275adb960474c8.zip | |
Clean up flymake.el
* lisp/progmodes/flymake.el (flymake, flymake-error-bitmap)
(flymake-warning-bitmap, flymake-fringe-indicator-position)
(flymake-compilation-prevents-syntax-check)
(flymake-start-syntax-check-on-newline)
(flymake-no-changes-timeout, flymake-gui-warnings-enabled)
(flymake-start-syntax-check-on-find-file, flymake-log-level)
(flymake-xml-program, flymake-master-file-dirs)
(flymake-master-file-count-limit)
(flymake-allowed-file-name-masks): Relocate.
(flymake-makehash, flymake-float-time)
(flymake-replace-regexp-in-string, flymake-split-string)
(flymake-get-temp-dir): Remove.
(flymake-popup-menu, flymake-nop, flymake-make-xemacs-menu)
(flymake-current-row, flymake-selected-frame)
(flymake-get-point-pixel-pos): Remove xemacs compatibity and
related functions.
Fixes: debbugs:16077
| -rw-r--r-- | lisp/ChangeLog | 19 | ||||
| -rw-r--r-- | lisp/progmodes/flymake.el | 535 |
2 files changed, 207 insertions, 347 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 17d7c0bdd34..c489bd362b1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2013-12-08 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * progmodes/flymake.el (flymake, flymake-error-bitmap) | ||
| 4 | (flymake-warning-bitmap, flymake-fringe-indicator-position) | ||
| 5 | (flymake-compilation-prevents-syntax-check) | ||
| 6 | (flymake-start-syntax-check-on-newline) | ||
| 7 | (flymake-no-changes-timeout, flymake-gui-warnings-enabled) | ||
| 8 | (flymake-start-syntax-check-on-find-file, flymake-log-level) | ||
| 9 | (flymake-xml-program, flymake-master-file-dirs) | ||
| 10 | (flymake-master-file-count-limit) | ||
| 11 | (flymake-allowed-file-name-masks): Relocate. | ||
| 12 | (flymake-makehash, flymake-float-time) | ||
| 13 | (flymake-replace-regexp-in-string, flymake-split-string) | ||
| 14 | (flymake-get-temp-dir): Remove. | ||
| 15 | (flymake-popup-menu, flymake-nop, flymake-make-xemacs-menu) | ||
| 16 | (flymake-current-row, flymake-selected-frame) | ||
| 17 | (flymake-get-point-pixel-pos): Remove xemacs compatibity and | ||
| 18 | related functions. (Bug#16077) | ||
| 19 | |||
| 1 | 2013-12-07 Bozhidar Batsov <bozhidar@batsov.com> | 20 | 2013-12-07 Bozhidar Batsov <bozhidar@batsov.com> |
| 2 | 21 | ||
| 3 | * emacs-lisp/helpers.el (string-blank-p): Use `string-match-p'. | 22 | * emacs-lisp/helpers.el (string-blank-p): Use `string-match-p'. |
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index ab86b83f7bf..48ff486a9e5 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | ;;; flymake.el --- a universal on-the-fly syntax checker | 1 | ;;; flymake.el --- a universal on-the-fly syntax checker -*- lexical-binding: t; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2003-2013 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2003-2013 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Pavel Kobyakov <pk_at_work@yahoo.com> | 5 | ;; Author: Pavel Kobyakov <pk_at_work@yahoo.com> |
| 6 | ;; Maintainer: Pavel Kobyakov <pk_at_work@yahoo.com> | 6 | ;; Maintainer: Leo Liu <sdl.web@gmail.com> |
| 7 | ;; Version: 0.3 | 7 | ;; Version: 0.3 |
| 8 | ;; Keywords: c languages tools | 8 | ;; Keywords: c languages tools |
| 9 | 9 | ||
| @@ -24,9 +24,9 @@ | |||
| 24 | 24 | ||
| 25 | ;;; Commentary: | 25 | ;;; Commentary: |
| 26 | ;; | 26 | ;; |
| 27 | ;; Flymake is a minor Emacs mode performing on-the-fly syntax | 27 | ;; Flymake is a minor Emacs mode performing on-the-fly syntax checks |
| 28 | ;; checks using the external syntax check tool (for C/C++ this | 28 | ;; using the external syntax check tool (for C/C++ this is usually the |
| 29 | ;; is usually the compiler) | 29 | ;; compiler). |
| 30 | 30 | ||
| 31 | ;;; Bugs/todo: | 31 | ;;; Bugs/todo: |
| 32 | 32 | ||
| @@ -36,77 +36,161 @@ | |||
| 36 | ;;; Code: | 36 | ;;; Code: |
| 37 | 37 | ||
| 38 | (eval-when-compile (require 'cl-lib)) | 38 | (eval-when-compile (require 'cl-lib)) |
| 39 | (if (featurep 'xemacs) (require 'overlay)) | ||
| 40 | 39 | ||
| 41 | (defvar flymake-is-running nil | 40 | (defgroup flymake nil |
| 41 | "Universal on-the-fly syntax checker." | ||
| 42 | :version "23.1" | ||
| 43 | :group 'tools) | ||
| 44 | |||
| 45 | (defcustom flymake-error-bitmap '(exclamation-mark error) | ||
| 46 | "Bitmap (a symbol) used in the fringe for indicating errors. | ||
| 47 | The value may also be a list of two elements where the second | ||
| 48 | element specifies the face for the bitmap. For possible bitmap | ||
| 49 | symbols, see `fringe-bitmaps'. See also `flymake-warning-bitmap'. | ||
| 50 | |||
| 51 | The option `flymake-fringe-indicator-position' controls how and where | ||
| 52 | this is used." | ||
| 53 | :group 'flymake | ||
| 54 | :version "24.3" | ||
| 55 | :type '(choice (symbol :tag "Bitmap") | ||
| 56 | (list :tag "Bitmap and face" | ||
| 57 | (symbol :tag "Bitmap") | ||
| 58 | (face :tag "Face")))) | ||
| 59 | |||
| 60 | (defcustom flymake-warning-bitmap 'question-mark | ||
| 61 | "Bitmap (a symbol) used in the fringe for indicating warnings. | ||
| 62 | The value may also be a list of two elements where the second | ||
| 63 | element specifies the face for the bitmap. For possible bitmap | ||
| 64 | symbols, see `fringe-bitmaps'. See also `flymake-error-bitmap'. | ||
| 65 | |||
| 66 | The option `flymake-fringe-indicator-position' controls how and where | ||
| 67 | this is used." | ||
| 68 | :group 'flymake | ||
| 69 | :version "24.3" | ||
| 70 | :type '(choice (symbol :tag "Bitmap") | ||
| 71 | (list :tag "Bitmap and face" | ||
| 72 | (symbol :tag "Bitmap") | ||
| 73 | (face :tag "Face")))) | ||
| 74 | |||
| 75 | (defcustom flymake-fringe-indicator-position 'left-fringe | ||
| 76 | "The position to put flymake fringe indicator. | ||
| 77 | The value can be nil (do not use indicators), `left-fringe' or `right-fringe'. | ||
| 78 | See `flymake-error-bitmap' and `flymake-warning-bitmap'." | ||
| 79 | :group 'flymake | ||
| 80 | :version "24.3" | ||
| 81 | :type '(choice (const left-fringe) | ||
| 82 | (const right-fringe) | ||
| 83 | (const :tag "No fringe indicators" nil))) | ||
| 84 | |||
| 85 | (defcustom flymake-compilation-prevents-syntax-check t | ||
| 86 | "If non-nil, don't start syntax check if compilation is running." | ||
| 87 | :group 'flymake | ||
| 88 | :type 'boolean) | ||
| 89 | |||
| 90 | (defcustom flymake-start-syntax-check-on-newline t | ||
| 91 | "Start syntax check if newline char was added/removed from the buffer." | ||
| 92 | :group 'flymake | ||
| 93 | :type 'boolean) | ||
| 94 | |||
| 95 | (defcustom flymake-no-changes-timeout 0.5 | ||
| 96 | "Time to wait after last change before starting compilation." | ||
| 97 | :group 'flymake | ||
| 98 | :type 'number) | ||
| 99 | |||
| 100 | (defcustom flymake-gui-warnings-enabled t | ||
| 101 | "Enables/disables GUI warnings." | ||
| 102 | :group 'flymake | ||
| 103 | :type 'boolean) | ||
| 104 | |||
| 105 | (defcustom flymake-start-syntax-check-on-find-file t | ||
| 106 | "Start syntax check on find file." | ||
| 107 | :group 'flymake | ||
| 108 | :type 'boolean) | ||
| 109 | |||
| 110 | (defcustom flymake-log-level -1 | ||
| 111 | "Logging level, only messages with level lower or equal will be logged. | ||
| 112 | -1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG" | ||
| 113 | :group 'flymake | ||
| 114 | :type 'integer) | ||
| 115 | |||
| 116 | (defcustom flymake-xml-program | ||
| 117 | (if (executable-find "xmlstarlet") "xmlstarlet" "xml") | ||
| 118 | "Program to use for XML validation." | ||
| 119 | :type 'file | ||
| 120 | :group 'flymake | ||
| 121 | :version "24.4") | ||
| 122 | |||
| 123 | (defcustom flymake-master-file-dirs '("." "./src" "./UnitTest") | ||
| 124 | "Dirs where to look for master files." | ||
| 125 | :group 'flymake | ||
| 126 | :type '(repeat (string))) | ||
| 127 | |||
| 128 | (defcustom flymake-master-file-count-limit 32 | ||
| 129 | "Max number of master files to check." | ||
| 130 | :group 'flymake | ||
| 131 | :type 'integer) | ||
| 132 | |||
| 133 | (defcustom flymake-allowed-file-name-masks | ||
| 134 | '(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-init) | ||
| 135 | ("\\.xml\\'" flymake-xml-init) | ||
| 136 | ("\\.html?\\'" flymake-xml-init) | ||
| 137 | ("\\.cs\\'" flymake-simple-make-init) | ||
| 138 | ("\\.p[ml]\\'" flymake-perl-init) | ||
| 139 | ("\\.php[345]?\\'" flymake-php-init) | ||
| 140 | ("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup) | ||
| 141 | ("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup) | ||
| 142 | ("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup) | ||
| 143 | ("\\.tex\\'" flymake-simple-tex-init) | ||
| 144 | ("\\.idl\\'" flymake-simple-make-init) | ||
| 145 | ;; ("\\.cpp\\'" 1) | ||
| 146 | ;; ("\\.java\\'" 3) | ||
| 147 | ;; ("\\.h\\'" 2 ("\\.cpp\\'" "\\.c\\'") | ||
| 148 | ;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2)) | ||
| 149 | ;; ("\\.idl\\'" 1) | ||
| 150 | ;; ("\\.odl\\'" 1) | ||
| 151 | ;; ("[0-9]+\\.tex\\'" 2 ("\\.tex\\'") | ||
| 152 | ;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 )) | ||
| 153 | ;; ("\\.tex\\'" 1) | ||
| 154 | ) | ||
| 155 | "Files syntax checking is allowed for. | ||
| 156 | This is an alist with elements of the form: | ||
| 157 | REGEXP INIT [CLEANUP [NAME]] | ||
| 158 | REGEXP is a regular expression that matches a file name. | ||
| 159 | INIT is the init function to use. | ||
| 160 | CLEANUP is the cleanup function to use, default `flymake-simple-cleanup'. | ||
| 161 | NAME is the file name function to use, default `flymake-get-real-file-name'." | ||
| 162 | :group 'flymake | ||
| 163 | :type '(alist :key-type (regexp :tag "File regexp") | ||
| 164 | :value-type | ||
| 165 | (list :tag "Handler functions" | ||
| 166 | (function :tag "Init function") | ||
| 167 | (choice :tag "Cleanup function" | ||
| 168 | (const :tag "flymake-simple-cleanup" nil) | ||
| 169 | function) | ||
| 170 | (choice :tag "Name function" | ||
| 171 | (const :tag "flymake-get-real-file-name" nil) | ||
| 172 | function)))) | ||
| 173 | |||
| 174 | (defvar-local flymake-is-running nil | ||
| 42 | "If t, flymake syntax check process is running for the current buffer.") | 175 | "If t, flymake syntax check process is running for the current buffer.") |
| 43 | (make-variable-buffer-local 'flymake-is-running) | ||
| 44 | 176 | ||
| 45 | (defvar flymake-timer nil | 177 | (defvar-local flymake-timer nil |
| 46 | "Timer for starting syntax check.") | 178 | "Timer for starting syntax check.") |
| 47 | (make-variable-buffer-local 'flymake-timer) | ||
| 48 | 179 | ||
| 49 | (defvar flymake-last-change-time nil | 180 | (defvar-local flymake-last-change-time nil |
| 50 | "Time of last buffer change.") | 181 | "Time of last buffer change.") |
| 51 | (make-variable-buffer-local 'flymake-last-change-time) | ||
| 52 | 182 | ||
| 53 | (defvar flymake-check-start-time nil | 183 | (defvar-local flymake-check-start-time nil |
| 54 | "Time at which syntax check was started.") | 184 | "Time at which syntax check was started.") |
| 55 | (make-variable-buffer-local 'flymake-check-start-time) | ||
| 56 | 185 | ||
| 57 | (defvar flymake-check-was-interrupted nil | 186 | (defvar-local flymake-check-was-interrupted nil |
| 58 | "Non-nil if syntax check was killed by `flymake-compile'.") | 187 | "Non-nil if syntax check was killed by `flymake-compile'.") |
| 59 | (make-variable-buffer-local 'flymake-check-was-interrupted) | ||
| 60 | 188 | ||
| 61 | (defvar flymake-err-info nil | 189 | (defvar-local flymake-err-info nil |
| 62 | "Sorted list of line numbers and lists of err info in the form (file, err-text).") | 190 | "Sorted list of line numbers and lists of err info in the form (file, err-text).") |
| 63 | (make-variable-buffer-local 'flymake-err-info) | ||
| 64 | 191 | ||
| 65 | (defvar flymake-new-err-info nil | 192 | (defvar-local flymake-new-err-info nil |
| 66 | "Same as `flymake-err-info', effective when a syntax check is in progress.") | 193 | "Same as `flymake-err-info', effective when a syntax check is in progress.") |
| 67 | (make-variable-buffer-local 'flymake-new-err-info) | ||
| 68 | |||
| 69 | ;;;; [[ cross-emacs compatibility routines | ||
| 70 | (defsubst flymake-makehash (&optional test) | ||
| 71 | "Create and return a new hash table using TEST to compare keys. | ||
| 72 | It uses the function `make-hash-table' to make a hash-table if | ||
| 73 | you use GNU Emacs, otherwise it uses `makehash'." | ||
| 74 | (if (fboundp 'make-hash-table) | ||
| 75 | (if test (make-hash-table :test test) (make-hash-table)) | ||
| 76 | (with-no-warnings | ||
| 77 | (makehash test)))) | ||
| 78 | |||
| 79 | (defalias 'flymake-float-time | ||
| 80 | (if (fboundp 'float-time) | ||
| 81 | 'float-time | ||
| 82 | (if (featurep 'xemacs) | ||
| 83 | (lambda () | ||
| 84 | (multiple-value-bind (s0 s1 s2) (values-list (current-time)) | ||
| 85 | (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2))))))) | ||
| 86 | |||
| 87 | (defalias 'flymake-replace-regexp-in-string | ||
| 88 | (if (eval-when-compile (fboundp 'replace-regexp-in-string)) | ||
| 89 | 'replace-regexp-in-string | ||
| 90 | (lambda (regexp rep str) | ||
| 91 | (replace-in-string str regexp rep)))) | ||
| 92 | |||
| 93 | (defalias 'flymake-split-string | ||
| 94 | (if (condition-case nil (equal (split-string " bc " " " t) '("bc")) | ||
| 95 | (error nil)) | ||
| 96 | (lambda (str pattern) (split-string str pattern t)) | ||
| 97 | (lambda (str pattern) | ||
| 98 | "Split STR into a list of substrings bounded by PATTERN. | ||
| 99 | Zero-length substrings at the beginning and end of the list are omitted." | ||
| 100 | (let ((split (split-string str pattern))) | ||
| 101 | (while (equal (car split) "") (setq split (cdr split))) | ||
| 102 | (setq split (nreverse split)) | ||
| 103 | (while (equal (car split) "") (setq split (cdr split))) | ||
| 104 | (nreverse split))))) | ||
| 105 | |||
| 106 | (defalias 'flymake-get-temp-dir | ||
| 107 | (if (fboundp 'temp-directory) | ||
| 108 | 'temp-directory | ||
| 109 | (lambda () temporary-file-directory))) | ||
| 110 | 194 | ||
| 111 | (defun flymake-posn-at-point-as-event (&optional position window dx dy) | 195 | (defun flymake-posn-at-point-as-event (&optional position window dx dy) |
| 112 | "Return pixel position of top left corner of glyph at POSITION. | 196 | "Return pixel position of top left corner of glyph at POSITION. |
| @@ -120,12 +204,11 @@ POSITION and WINDOW default to the position of point in the | |||
| 120 | selected window. | 204 | selected window. |
| 121 | 205 | ||
| 122 | DX and DY specify optional offsets from the top left of the glyph." | 206 | DX and DY specify optional offsets from the top left of the glyph." |
| 123 | (unless window (setq window (selected-window))) | 207 | (let* ((window (or window (selected-window))) |
| 124 | (unless position (setq position (window-point window))) | 208 | (position (or position (window-point window))) |
| 125 | (unless dx (setq dx 0)) | 209 | (dx (or dx 0)) |
| 126 | (unless dy (setq dy 0)) | 210 | (dy (or dy 0)) |
| 127 | 211 | (pos (posn-at-point position window)) | |
| 128 | (let* ((pos (posn-at-point position window)) | ||
| 129 | (x-y (posn-x-y pos)) | 212 | (x-y (posn-x-y pos)) |
| 130 | (edges (window-inside-pixel-edges window)) | 213 | (edges (window-inside-pixel-edges window)) |
| 131 | (win-x-y (window-pixel-edges window))) | 214 | (win-x-y (window-pixel-edges window))) |
| @@ -135,25 +218,16 @@ DX and DY specify optional offsets from the top left of the glyph." | |||
| 135 | (+ (cdr x-y) (cadr edges) (- (cadr win-x-y)) dy))) | 218 | (+ (cdr x-y) (cadr edges) (- (cadr win-x-y)) dy))) |
| 136 | (list 'mouse-1 pos))) | 219 | (list 'mouse-1 pos))) |
| 137 | 220 | ||
| 221 | ;;; XXX: get rid of the following two functions | ||
| 222 | |||
| 138 | (defun flymake-popup-menu (menu-data) | 223 | (defun flymake-popup-menu (menu-data) |
| 139 | "Pop up the flymake menu at point, using the data MENU-DATA. | 224 | "Pop up the flymake menu at point, using the data MENU-DATA. |
| 140 | POS is a list of the form ((X Y) WINDOW), where X and Y are | 225 | POS is a list of the form ((X Y) WINDOW), where X and Y are |
| 141 | pixels positions from the top left corner of WINDOW's frame. | 226 | pixels positions from the top left corner of WINDOW's frame. |
| 142 | MENU-DATA is a list of error and warning messages returned by | 227 | MENU-DATA is a list of error and warning messages returned by |
| 143 | `flymake-make-err-menu-data'." | 228 | `flymake-make-err-menu-data'." |
| 144 | (if (featurep 'xemacs) | 229 | (x-popup-menu (flymake-posn-at-point-as-event) |
| 145 | (let* ((pos (flymake-get-point-pixel-pos)) | 230 | (flymake-make-emacs-menu menu-data))) |
| 146 | (x-pos (nth 0 pos)) | ||
| 147 | (y-pos (nth 1 pos)) | ||
| 148 | (fake-event-props '(button 1 x 1 y 1))) | ||
| 149 | (setq fake-event-props (plist-put fake-event-props 'x x-pos)) | ||
| 150 | (setq fake-event-props (plist-put fake-event-props 'y y-pos)) | ||
| 151 | (popup-menu (flymake-make-xemacs-menu menu-data) | ||
| 152 | (make-event 'button-press fake-event-props))) | ||
| 153 | (x-popup-menu (if (eval-when-compile (fboundp 'posn-at-point)) | ||
| 154 | (flymake-posn-at-point-as-event) | ||
| 155 | (list (flymake-get-point-pixel-pos) (selected-window))) | ||
| 156 | (flymake-make-emacs-menu menu-data)))) | ||
| 157 | 231 | ||
| 158 | (defun flymake-make-emacs-menu (menu-data) | 232 | (defun flymake-make-emacs-menu (menu-data) |
| 159 | "Return a menu specifier using MENU-DATA. | 233 | "Return a menu specifier using MENU-DATA. |
| @@ -167,72 +241,6 @@ See `x-popup-menu' for the menu specifier format." | |||
| 167 | menu-items))) | 241 | menu-items))) |
| 168 | (list menu-title (cons "" menu-commands)))) | 242 | (list menu-title (cons "" menu-commands)))) |
| 169 | 243 | ||
| 170 | (if (featurep 'xemacs) (progn | ||
| 171 | |||
| 172 | (defun flymake-nop () | ||
| 173 | "Do nothing." | ||
| 174 | nil) | ||
| 175 | |||
| 176 | (defun flymake-make-xemacs-menu (menu-data) | ||
| 177 | "Return a menu specifier using MENU-DATA." | ||
| 178 | (let* ((menu-title (nth 0 menu-data)) | ||
| 179 | (menu-items (nth 1 menu-data)) | ||
| 180 | (menu-commands nil)) | ||
| 181 | (setq menu-commands (mapcar (lambda (foo) | ||
| 182 | (vector (nth 0 foo) (or (nth 1 foo) '(flymake-nop)) t)) | ||
| 183 | menu-items)) | ||
| 184 | (cons menu-title menu-commands))) | ||
| 185 | |||
| 186 | )) ;; xemacs | ||
| 187 | |||
| 188 | (unless (eval-when-compile (fboundp 'posn-at-point)) | ||
| 189 | |||
| 190 | (defun flymake-current-row () | ||
| 191 | "Return current row number in current frame." | ||
| 192 | (if (fboundp 'window-edges) | ||
| 193 | (+ (car (cdr (window-edges))) (count-lines (window-start) (point))) | ||
| 194 | (count-lines (window-start) (point)))) | ||
| 195 | |||
| 196 | (defun flymake-selected-frame () | ||
| 197 | "Return the frame that is now selected." | ||
| 198 | (if (fboundp 'window-edges) | ||
| 199 | (selected-frame) | ||
| 200 | (selected-window))) | ||
| 201 | |||
| 202 | (defun flymake-get-point-pixel-pos () | ||
| 203 | "Return point position in pixels: (x, y)." | ||
| 204 | (let ((mouse-pos (mouse-position)) | ||
| 205 | (pixel-pos nil) | ||
| 206 | (ret nil)) | ||
| 207 | (if (car (cdr mouse-pos)) | ||
| 208 | (progn | ||
| 209 | (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row)) | ||
| 210 | (setq pixel-pos (mouse-pixel-position)) | ||
| 211 | (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos))) | ||
| 212 | (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos))))) | ||
| 213 | (progn | ||
| 214 | (setq ret '(0 0)))) | ||
| 215 | (flymake-log 3 "mouse pos is %s" ret) | ||
| 216 | ret)) | ||
| 217 | |||
| 218 | ) ;; End of (unless (fboundp 'posn-at-point) | ||
| 219 | |||
| 220 | ;;;; ]] | ||
| 221 | |||
| 222 | (defcustom flymake-log-level -1 | ||
| 223 | "Logging level, only messages with level lower or equal will be logged. | ||
| 224 | -1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG" | ||
| 225 | :group 'flymake | ||
| 226 | :type 'integer) | ||
| 227 | |||
| 228 | |||
| 229 | ;; (defcustom flymake-log-file-name "~/flymake.log" | ||
| 230 | ;; "Where to put the flymake log if logging is enabled. | ||
| 231 | ;; | ||
| 232 | ;; See `flymake-log-level' if you want to control what is logged." | ||
| 233 | ;; :group 'flymake | ||
| 234 | ;; :type 'string) | ||
| 235 | |||
| 236 | (defun flymake-log (level text &rest args) | 244 | (defun flymake-log (level text &rest args) |
| 237 | "Log a message at level LEVEL. | 245 | "Log a message at level LEVEL. |
| 238 | If LEVEL is higher than `flymake-log-level', the message is | 246 | If LEVEL is higher than `flymake-log-level', the message is |
| @@ -241,13 +249,7 @@ TEXT is a format control string, and the remaining arguments ARGS | |||
| 241 | are the string substitutions (see the function `format')." | 249 | are the string substitutions (see the function `format')." |
| 242 | (if (<= level flymake-log-level) | 250 | (if (<= level flymake-log-level) |
| 243 | (let* ((msg (apply 'format text args))) | 251 | (let* ((msg (apply 'format text args))) |
| 244 | (message "%s" msg) | 252 | (message "%s" msg)))) |
| 245 | ;;(with-temp-buffer | ||
| 246 | ;; (insert msg) | ||
| 247 | ;; (insert "\n") | ||
| 248 | ;; (flymake-save-buffer-in-file "~/flymake.log") ; make log file name customizable | ||
| 249 | ;;) | ||
| 250 | ))) | ||
| 251 | 253 | ||
| 252 | (defun flymake-ins-after (list pos val) | 254 | (defun flymake-ins-after (list pos val) |
| 253 | "Insert VAL into LIST after position POS. | 255 | "Insert VAL into LIST after position POS. |
| @@ -266,61 +268,7 @@ POS counts from zero." | |||
| 266 | (defvar flymake-processes nil | 268 | (defvar flymake-processes nil |
| 267 | "List of currently active flymake processes.") | 269 | "List of currently active flymake processes.") |
| 268 | 270 | ||
| 269 | (defvar flymake-output-residual nil) | 271 | (defvar-local flymake-output-residual nil) |
| 270 | (make-variable-buffer-local 'flymake-output-residual) | ||
| 271 | |||
| 272 | (defgroup flymake nil | ||
| 273 | "Universal on-the-fly syntax checker." | ||
| 274 | :version "23.1" | ||
| 275 | :group 'tools) | ||
| 276 | |||
| 277 | (defcustom flymake-xml-program | ||
| 278 | (if (executable-find "xmlstarlet") "xmlstarlet" "xml") | ||
| 279 | "Program to use for XML validation." | ||
| 280 | :type 'file | ||
| 281 | :group 'flymake | ||
| 282 | :version "24.4") | ||
| 283 | |||
| 284 | (defcustom flymake-allowed-file-name-masks | ||
| 285 | '(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-init) | ||
| 286 | ("\\.xml\\'" flymake-xml-init) | ||
| 287 | ("\\.html?\\'" flymake-xml-init) | ||
| 288 | ("\\.cs\\'" flymake-simple-make-init) | ||
| 289 | ("\\.p[ml]\\'" flymake-perl-init) | ||
| 290 | ("\\.php[345]?\\'" flymake-php-init) | ||
| 291 | ("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup) | ||
| 292 | ("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup) | ||
| 293 | ("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup) | ||
| 294 | ("\\.tex\\'" flymake-simple-tex-init) | ||
| 295 | ("\\.idl\\'" flymake-simple-make-init) | ||
| 296 | ;; ("\\.cpp\\'" 1) | ||
| 297 | ;; ("\\.java\\'" 3) | ||
| 298 | ;; ("\\.h\\'" 2 ("\\.cpp\\'" "\\.c\\'") | ||
| 299 | ;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2)) | ||
| 300 | ;; ("\\.idl\\'" 1) | ||
| 301 | ;; ("\\.odl\\'" 1) | ||
| 302 | ;; ("[0-9]+\\.tex\\'" 2 ("\\.tex\\'") | ||
| 303 | ;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 )) | ||
| 304 | ;; ("\\.tex\\'" 1) | ||
| 305 | ) | ||
| 306 | "Files syntax checking is allowed for. | ||
| 307 | This is an alist with elements of the form: | ||
| 308 | REGEXP INIT [CLEANUP [NAME]] | ||
| 309 | REGEXP is a regular expression that matches a file name. | ||
| 310 | INIT is the init function to use. | ||
| 311 | CLEANUP is the cleanup function to use, default `flymake-simple-cleanup'. | ||
| 312 | NAME is the file name function to use, default `flymake-get-real-file-name'." | ||
| 313 | :group 'flymake | ||
| 314 | :type '(alist :key-type (regexp :tag "File regexp") | ||
| 315 | :value-type | ||
| 316 | (list :tag "Handler functions" | ||
| 317 | (function :tag "Init function") | ||
| 318 | (choice :tag "Cleanup function" | ||
| 319 | (const :tag "flymake-simple-cleanup" nil) | ||
| 320 | function) | ||
| 321 | (choice :tag "Name function" | ||
| 322 | (const :tag "flymake-get-real-file-name" nil) | ||
| 323 | function)))) | ||
| 324 | 272 | ||
| 325 | (defun flymake-get-file-name-mode-and-masks (file-name) | 273 | (defun flymake-get-file-name-mode-and-masks (file-name) |
| 326 | "Return the corresponding entry from `flymake-allowed-file-name-masks'." | 274 | "Return the corresponding entry from `flymake-allowed-file-name-masks'." |
| @@ -356,7 +304,7 @@ Return nil if we cannot, non-nil if we can." | |||
| 356 | (or (nth 2 (flymake-get-file-name-mode-and-masks file-name)) | 304 | (or (nth 2 (flymake-get-file-name-mode-and-masks file-name)) |
| 357 | 'flymake-get-real-file-name)) | 305 | 'flymake-get-real-file-name)) |
| 358 | 306 | ||
| 359 | (defvar flymake-find-buildfile-cache (flymake-makehash 'equal)) | 307 | (defvar flymake-find-buildfile-cache (make-hash-table :test #'equal)) |
| 360 | 308 | ||
| 361 | (defun flymake-get-buildfile-from-cache (dir-name) | 309 | (defun flymake-get-buildfile-from-cache (dir-name) |
| 362 | "Look up DIR-NAME in cache and return its associated value. | 310 | "Look up DIR-NAME in cache and return its associated value. |
| @@ -400,16 +348,6 @@ Return t if so, nil if not." | |||
| 400 | (equal (flymake-fix-file-name file-name-one) | 348 | (equal (flymake-fix-file-name file-name-one) |
| 401 | (flymake-fix-file-name file-name-two))) | 349 | (flymake-fix-file-name file-name-two))) |
| 402 | 350 | ||
| 403 | (defcustom flymake-master-file-dirs '("." "./src" "./UnitTest") | ||
| 404 | "Dirs where to look for master files." | ||
| 405 | :group 'flymake | ||
| 406 | :type '(repeat (string))) | ||
| 407 | |||
| 408 | (defcustom flymake-master-file-count-limit 32 | ||
| 409 | "Max number of master files to check." | ||
| 410 | :group 'flymake | ||
| 411 | :type 'integer) | ||
| 412 | |||
| 413 | ;; This is bound dynamically to pass a parameter to a sort predicate below | 351 | ;; This is bound dynamically to pass a parameter to a sort predicate below |
| 414 | (defvar flymake-included-file-name) | 352 | (defvar flymake-included-file-name) |
| 415 | 353 | ||
| @@ -456,12 +394,9 @@ to the beginning of the list (File.h -> File.cpp moved to top)." | |||
| 456 | (file-name-base file-one)) | 394 | (file-name-base file-one)) |
| 457 | (not (equal file-one file-two)))) | 395 | (not (equal file-one file-two)))) |
| 458 | 396 | ||
| 459 | (defcustom flymake-check-file-limit 8192 | 397 | (defvar flymake-check-file-limit 8192 |
| 460 | "Maximum number of chars to look at when checking possible master file. | 398 | "Maximum number of chars to look at when checking possible master file. |
| 461 | Nil means search the entire file." | 399 | Nil means search the entire file.") |
| 462 | :group 'flymake | ||
| 463 | :type '(choice (const :tag "No limit" nil) | ||
| 464 | (integer :tag "Characters"))) | ||
| 465 | 400 | ||
| 466 | (defun flymake-check-patch-master-file-buffer | 401 | (defun flymake-check-patch-master-file-buffer |
| 467 | (master-file-temp-buffer | 402 | (master-file-temp-buffer |
| @@ -537,6 +472,7 @@ instead of reading master file from disk." | |||
| 537 | (flymake-log 2 "found master file %s" master-file-name)) | 472 | (flymake-log 2 "found master file %s" master-file-name)) |
| 538 | found)) | 473 | found)) |
| 539 | 474 | ||
| 475 | ;;; XXX: remove | ||
| 540 | (defun flymake-replace-region (beg end rep) | 476 | (defun flymake-replace-region (beg end rep) |
| 541 | "Replace text in BUFFER in region (BEG END) with REP." | 477 | "Replace text in BUFFER in region (BEG END) with REP." |
| 542 | (save-excursion | 478 | (save-excursion |
| @@ -681,7 +617,7 @@ It's flymake process filter." | |||
| 681 | (setq flymake-new-err-info nil) | 617 | (setq flymake-new-err-info nil) |
| 682 | (setq flymake-err-info | 618 | (setq flymake-err-info |
| 683 | (flymake-fix-line-numbers | 619 | (flymake-fix-line-numbers |
| 684 | flymake-err-info 1 (flymake-count-lines))) | 620 | flymake-err-info 1 (count-lines (point-min) (point-max)))) |
| 685 | (flymake-delete-own-overlays) | 621 | (flymake-delete-own-overlays) |
| 686 | (flymake-highlight-err-lines flymake-err-info) | 622 | (flymake-highlight-err-lines flymake-err-info) |
| 687 | (let (err-count warn-count) | 623 | (let (err-count warn-count) |
| @@ -689,7 +625,7 @@ It's flymake process filter." | |||
| 689 | (setq warn-count (flymake-get-err-count flymake-err-info "w")) | 625 | (setq warn-count (flymake-get-err-count flymake-err-info "w")) |
| 690 | (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)" | 626 | (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)" |
| 691 | (buffer-name) err-count warn-count | 627 | (buffer-name) err-count warn-count |
| 692 | (- (flymake-float-time) flymake-check-start-time)) | 628 | (- (float-time) flymake-check-start-time)) |
| 693 | (setq flymake-check-start-time nil) | 629 | (setq flymake-check-start-time nil) |
| 694 | 630 | ||
| 695 | (if (and (equal 0 err-count) (equal 0 warn-count)) | 631 | (if (and (equal 0 err-count) (equal 0 warn-count)) |
| @@ -810,46 +746,6 @@ line number outside the file being compiled." | |||
| 810 | "Determine whether overlay OV was created by flymake." | 746 | "Determine whether overlay OV was created by flymake." |
| 811 | (and (overlayp ov) (overlay-get ov 'flymake-overlay))) | 747 | (and (overlayp ov) (overlay-get ov 'flymake-overlay))) |
| 812 | 748 | ||
| 813 | (defcustom flymake-error-bitmap '(exclamation-mark error) | ||
| 814 | "Bitmap (a symbol) used in the fringe for indicating errors. | ||
| 815 | The value may also be a list of two elements where the second | ||
| 816 | element specifies the face for the bitmap. For possible bitmap | ||
| 817 | symbols, see `fringe-bitmaps'. See also `flymake-warning-bitmap'. | ||
| 818 | |||
| 819 | The option `flymake-fringe-indicator-position' controls how and where | ||
| 820 | this is used." | ||
| 821 | :group 'flymake | ||
| 822 | :version "24.3" | ||
| 823 | :type '(choice (symbol :tag "Bitmap") | ||
| 824 | (list :tag "Bitmap and face" | ||
| 825 | (symbol :tag "Bitmap") | ||
| 826 | (face :tag "Face")))) | ||
| 827 | |||
| 828 | (defcustom flymake-warning-bitmap 'question-mark | ||
| 829 | "Bitmap (a symbol) used in the fringe for indicating warnings. | ||
| 830 | The value may also be a list of two elements where the second | ||
| 831 | element specifies the face for the bitmap. For possible bitmap | ||
| 832 | symbols, see `fringe-bitmaps'. See also `flymake-error-bitmap'. | ||
| 833 | |||
| 834 | The option `flymake-fringe-indicator-position' controls how and where | ||
| 835 | this is used." | ||
| 836 | :group 'flymake | ||
| 837 | :version "24.3" | ||
| 838 | :type '(choice (symbol :tag "Bitmap") | ||
| 839 | (list :tag "Bitmap and face" | ||
| 840 | (symbol :tag "Bitmap") | ||
| 841 | (face :tag "Face")))) | ||
| 842 | |||
| 843 | (defcustom flymake-fringe-indicator-position 'left-fringe | ||
| 844 | "The position to put flymake fringe indicator. | ||
| 845 | The value can be nil (do not use indicators), `left-fringe' or `right-fringe'. | ||
| 846 | See `flymake-error-bitmap' and `flymake-warning-bitmap'." | ||
| 847 | :group 'flymake | ||
| 848 | :version "24.3" | ||
| 849 | :type '(choice (const left-fringe) | ||
| 850 | (const right-fringe) | ||
| 851 | (const :tag "No fringe indicators" nil))) | ||
| 852 | |||
| 853 | (defun flymake-make-overlay (beg end tooltip-text face bitmap mouse-face) | 749 | (defun flymake-make-overlay (beg end tooltip-text face bitmap mouse-face) |
| 854 | "Allocate a flymake overlay in range BEG and END." | 750 | "Allocate a flymake overlay in range BEG and END." |
| 855 | (when (not (flymake-region-has-flymake-overlays beg end)) | 751 | (when (not (flymake-region-has-flymake-overlays beg end)) |
| @@ -978,7 +874,7 @@ Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting." | |||
| 978 | Return last one as residual if it does not end with newline char. | 874 | Return last one as residual if it does not end with newline char. |
| 979 | Returns ((LINES) RESIDUAL)." | 875 | Returns ((LINES) RESIDUAL)." |
| 980 | (when (and output (> (length output) 0)) | 876 | (when (and output (> (length output) 0)) |
| 981 | (let* ((lines (flymake-split-string output "[\n\r]+")) | 877 | (let* ((lines (split-string output "[\n\r]+" t)) |
| 982 | (complete (equal "\n" (char-to-string (aref output (1- (length output)))))) | 878 | (complete (equal "\n" (char-to-string (aref output (1- (length output)))))) |
| 983 | (residual nil)) | 879 | (residual nil)) |
| 984 | (when (not complete) | 880 | (when (not complete) |
| @@ -1163,26 +1059,24 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1163 | (shell-quote-argument basedir) | 1059 | (shell-quote-argument basedir) |
| 1164 | " DUMPVARS=INCLUDE_DIRS dumpvars")) | 1060 | " DUMPVARS=INCLUDE_DIRS dumpvars")) |
| 1165 | (output (shell-command-to-string command-line)) | 1061 | (output (shell-command-to-string command-line)) |
| 1166 | (lines (flymake-split-string output "\n")) | 1062 | (lines (split-string output "\n" t)) |
| 1167 | (count (length lines)) | 1063 | (count (length lines)) |
| 1168 | (idx 0) | 1064 | (idx 0) |
| 1169 | (inc-dirs nil)) | 1065 | (inc-dirs nil)) |
| 1170 | (while (and (< idx count) (not (string-match "^INCLUDE_DIRS=.*" (nth idx lines)))) | 1066 | (while (and (< idx count) (not (string-match "^INCLUDE_DIRS=.*" (nth idx lines)))) |
| 1171 | (setq idx (1+ idx))) | 1067 | (setq idx (1+ idx))) |
| 1172 | (when (< idx count) | 1068 | (when (< idx count) |
| 1173 | (let* ((inc-lines (flymake-split-string (nth idx lines) " *-I")) | 1069 | (let* ((inc-lines (split-string (nth idx lines) " *-I" t)) |
| 1174 | (inc-count (length inc-lines))) | 1070 | (inc-count (length inc-lines))) |
| 1175 | (while (> inc-count 0) | 1071 | (while (> inc-count 0) |
| 1176 | (when (not (string-match "^INCLUDE_DIRS=.*" (nth (1- inc-count) inc-lines))) | 1072 | (when (not (string-match "^INCLUDE_DIRS=.*" (nth (1- inc-count) inc-lines))) |
| 1177 | (push (flymake-replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs)) | 1073 | (push (replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs)) |
| 1178 | (setq inc-count (1- inc-count))))) | 1074 | (setq inc-count (1- inc-count))))) |
| 1179 | (flymake-add-project-include-dirs-to-cache basedir inc-dirs) | 1075 | (flymake-add-project-include-dirs-to-cache basedir inc-dirs) |
| 1180 | inc-dirs))) | 1076 | inc-dirs))) |
| 1181 | 1077 | ||
| 1182 | (defcustom flymake-get-project-include-dirs-function 'flymake-get-project-include-dirs-imp | 1078 | (defvar flymake-get-project-include-dirs-function #'flymake-get-project-include-dirs-imp |
| 1183 | "Function used to get project include dirs, one parameter: basedir name." | 1079 | "Function used to get project include dirs, one parameter: basedir name.") |
| 1184 | :group 'flymake | ||
| 1185 | :type 'function) | ||
| 1186 | 1080 | ||
| 1187 | (defun flymake-get-project-include-dirs (basedir) | 1081 | (defun flymake-get-project-include-dirs (basedir) |
| 1188 | (funcall flymake-get-project-include-dirs-function basedir)) | 1082 | (funcall flymake-get-project-include-dirs-function basedir)) |
| @@ -1190,9 +1084,9 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1190 | (defun flymake-get-system-include-dirs () | 1084 | (defun flymake-get-system-include-dirs () |
| 1191 | "System include dirs - from the 'INCLUDE' env setting." | 1085 | "System include dirs - from the 'INCLUDE' env setting." |
| 1192 | (let* ((includes (getenv "INCLUDE"))) | 1086 | (let* ((includes (getenv "INCLUDE"))) |
| 1193 | (if includes (flymake-split-string includes path-separator) nil))) | 1087 | (if includes (split-string includes path-separator t) nil))) |
| 1194 | 1088 | ||
| 1195 | (defvar flymake-project-include-dirs-cache (flymake-makehash 'equal)) | 1089 | (defvar flymake-project-include-dirs-cache (make-hash-table :test #'equal)) |
| 1196 | 1090 | ||
| 1197 | (defun flymake-get-project-include-dirs-from-cache (base-dir) | 1091 | (defun flymake-get-project-include-dirs-from-cache (base-dir) |
| 1198 | (gethash base-dir flymake-project-include-dirs-cache)) | 1092 | (gethash base-dir flymake-project-include-dirs-cache)) |
| @@ -1232,11 +1126,6 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1232 | (error | 1126 | (error |
| 1233 | (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name)))) | 1127 | (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name)))) |
| 1234 | 1128 | ||
| 1235 | (defcustom flymake-compilation-prevents-syntax-check t | ||
| 1236 | "If non-nil, don't start syntax check if compilation is running." | ||
| 1237 | :group 'flymake | ||
| 1238 | :type 'boolean) | ||
| 1239 | |||
| 1240 | (defun flymake-start-syntax-check () | 1129 | (defun flymake-start-syntax-check () |
| 1241 | "Start syntax checking for current buffer." | 1130 | "Start syntax checking for current buffer." |
| 1242 | (interactive) | 1131 | (interactive) |
| @@ -1280,7 +1169,7 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1280 | 1169 | ||
| 1281 | (setq flymake-is-running t) | 1170 | (setq flymake-is-running t) |
| 1282 | (setq flymake-last-change-time nil) | 1171 | (setq flymake-last-change-time nil) |
| 1283 | (setq flymake-check-start-time (flymake-float-time)) | 1172 | (setq flymake-check-start-time (float-time)) |
| 1284 | 1173 | ||
| 1285 | (flymake-report-status nil "*") | 1174 | (flymake-report-status nil "*") |
| 1286 | (flymake-log 2 "started process %d, command=%s, dir=%s" | 1175 | (flymake-log 2 "started process %d, command=%s, dir=%s" |
| @@ -1321,36 +1210,23 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1321 | (flymake-stop-all-syntax-checks) | 1210 | (flymake-stop-all-syntax-checks) |
| 1322 | (call-interactively 'compile)) | 1211 | (call-interactively 'compile)) |
| 1323 | 1212 | ||
| 1324 | (defcustom flymake-no-changes-timeout 0.5 | ||
| 1325 | "Time to wait after last change before starting compilation." | ||
| 1326 | :group 'flymake | ||
| 1327 | :type 'number) | ||
| 1328 | |||
| 1329 | (defun flymake-on-timer-event (buffer) | 1213 | (defun flymake-on-timer-event (buffer) |
| 1330 | "Start a syntax check for buffer BUFFER if necessary." | 1214 | "Start a syntax check for buffer BUFFER if necessary." |
| 1331 | (when (buffer-live-p buffer) | 1215 | (when (buffer-live-p buffer) |
| 1332 | (with-current-buffer buffer | 1216 | (with-current-buffer buffer |
| 1333 | (when (and (not flymake-is-running) | 1217 | (when (and (not flymake-is-running) |
| 1334 | flymake-last-change-time | 1218 | flymake-last-change-time |
| 1335 | (> (- (flymake-float-time) flymake-last-change-time) | 1219 | (> (- (float-time) flymake-last-change-time) |
| 1336 | flymake-no-changes-timeout)) | 1220 | flymake-no-changes-timeout)) |
| 1337 | 1221 | ||
| 1338 | (setq flymake-last-change-time nil) | 1222 | (setq flymake-last-change-time nil) |
| 1339 | (flymake-log 3 "starting syntax check as more than 1 second passed since last change") | 1223 | (flymake-log 3 "starting syntax check as more than 1 second passed since last change") |
| 1340 | (flymake-start-syntax-check))))) | 1224 | (flymake-start-syntax-check))))) |
| 1341 | 1225 | ||
| 1342 | (defun flymake-current-line-no () | ||
| 1343 | "Return number of current line in current buffer." | ||
| 1344 | (count-lines (point-min) (if (eobp) (point) (1+ (point))))) | ||
| 1345 | |||
| 1346 | (defun flymake-count-lines () | ||
| 1347 | "Return number of lines in buffer BUFFER." | ||
| 1348 | (count-lines (point-min) (point-max))) | ||
| 1349 | |||
| 1350 | (defun flymake-display-err-menu-for-current-line () | 1226 | (defun flymake-display-err-menu-for-current-line () |
| 1351 | "Display a menu with errors/warnings for current line if it has errors and/or warnings." | 1227 | "Display a menu with errors/warnings for current line if it has errors and/or warnings." |
| 1352 | (interactive) | 1228 | (interactive) |
| 1353 | (let* ((line-no (flymake-current-line-no)) | 1229 | (let* ((line-no (line-number-at-pos)) |
| 1354 | (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))) | 1230 | (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))) |
| 1355 | (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) | 1231 | (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) |
| 1356 | (choice nil)) | 1232 | (choice nil)) |
| @@ -1396,17 +1272,9 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1396 | (forward-line (1- line)))) | 1272 | (forward-line (1- line)))) |
| 1397 | 1273 | ||
| 1398 | ;; flymake minor mode declarations | 1274 | ;; flymake minor mode declarations |
| 1399 | (defvar flymake-mode-line nil) | 1275 | (defvar-local flymake-mode-line nil) |
| 1400 | 1276 | (defvar-local flymake-mode-line-e-w nil) | |
| 1401 | (make-variable-buffer-local 'flymake-mode-line) | 1277 | (defvar-local flymake-mode-line-status nil) |
| 1402 | |||
| 1403 | (defvar flymake-mode-line-e-w nil) | ||
| 1404 | |||
| 1405 | (make-variable-buffer-local 'flymake-mode-line-e-w) | ||
| 1406 | |||
| 1407 | (defvar flymake-mode-line-status nil) | ||
| 1408 | |||
| 1409 | (make-variable-buffer-local 'flymake-mode-line-status) | ||
| 1410 | 1278 | ||
| 1411 | (defun flymake-report-status (e-w &optional status) | 1279 | (defun flymake-report-status (e-w &optional status) |
| 1412 | "Show status in mode line." | 1280 | "Show status in mode line." |
| @@ -1425,11 +1293,6 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1425 | "Display a warning to user." | 1293 | "Display a warning to user." |
| 1426 | (message-box warning)) | 1294 | (message-box warning)) |
| 1427 | 1295 | ||
| 1428 | (defcustom flymake-gui-warnings-enabled t | ||
| 1429 | "Enables/disables GUI warnings." | ||
| 1430 | :group 'flymake | ||
| 1431 | :type 'boolean) | ||
| 1432 | |||
| 1433 | (defun flymake-report-fatal-status (status warning) | 1296 | (defun flymake-report-fatal-status (status warning) |
| 1434 | "Display a warning and switch flymake mode off." | 1297 | "Display a warning and switch flymake mode off." |
| 1435 | (when flymake-gui-warnings-enabled | 1298 | (when flymake-gui-warnings-enabled |
| @@ -1439,17 +1302,8 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1439 | (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s" | 1302 | (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s" |
| 1440 | (buffer-name) status warning)) | 1303 | (buffer-name) status warning)) |
| 1441 | 1304 | ||
| 1442 | (defcustom flymake-start-syntax-check-on-find-file t | ||
| 1443 | "Start syntax check on find file." | ||
| 1444 | :group 'flymake | ||
| 1445 | :type 'boolean) | ||
| 1446 | |||
| 1447 | ;;;###autoload | 1305 | ;;;###autoload |
| 1448 | (define-minor-mode flymake-mode | 1306 | (define-minor-mode flymake-mode nil |
| 1449 | "Toggle on-the-fly syntax checking. | ||
| 1450 | With a prefix argument ARG, enable the mode if ARG is positive, | ||
| 1451 | and disable it otherwise. If called from Lisp, enable the mode | ||
| 1452 | if ARG is omitted or nil." | ||
| 1453 | :group 'flymake :lighter flymake-mode-line | 1307 | :group 'flymake :lighter flymake-mode-line |
| 1454 | (cond | 1308 | (cond |
| 1455 | 1309 | ||
| @@ -1505,19 +1359,14 @@ if ARG is omitted or nil." | |||
| 1505 | (flymake-mode 0) | 1359 | (flymake-mode 0) |
| 1506 | (flymake-log 1 "flymake mode turned OFF for buffer %s" (buffer-name))) | 1360 | (flymake-log 1 "flymake mode turned OFF for buffer %s" (buffer-name))) |
| 1507 | 1361 | ||
| 1508 | (defcustom flymake-start-syntax-check-on-newline t | ||
| 1509 | "Start syntax check if newline char was added/removed from the buffer." | ||
| 1510 | :group 'flymake | ||
| 1511 | :type 'boolean) | ||
| 1512 | |||
| 1513 | (defun flymake-after-change-function (start stop _len) | 1362 | (defun flymake-after-change-function (start stop _len) |
| 1514 | "Start syntax check for current buffer if it isn't already running." | 1363 | "Start syntax check for current buffer if it isn't already running." |
| 1515 | ;;+(flymake-log 0 "setting change time to %s" (flymake-float-time)) | 1364 | ;;+(flymake-log 0 "setting change time to %s" (float-time)) |
| 1516 | (let((new-text (buffer-substring start stop))) | 1365 | (let((new-text (buffer-substring start stop))) |
| 1517 | (when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) | 1366 | (when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) |
| 1518 | (flymake-log 3 "starting syntax check as new-line has been seen") | 1367 | (flymake-log 3 "starting syntax check as new-line has been seen") |
| 1519 | (flymake-start-syntax-check)) | 1368 | (flymake-start-syntax-check)) |
| 1520 | (setq flymake-last-change-time (flymake-float-time)))) | 1369 | (setq flymake-last-change-time (float-time)))) |
| 1521 | 1370 | ||
| 1522 | (defun flymake-after-save-hook () | 1371 | (defun flymake-after-save-hook () |
| 1523 | (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved? | 1372 | (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved? |
| @@ -1584,7 +1433,7 @@ if ARG is omitted or nil." | |||
| 1584 | (defun flymake-goto-next-error () | 1433 | (defun flymake-goto-next-error () |
| 1585 | "Go to next error in err ring." | 1434 | "Go to next error in err ring." |
| 1586 | (interactive) | 1435 | (interactive) |
| 1587 | (let ((line-no (flymake-get-next-err-line-no flymake-err-info (flymake-current-line-no)))) | 1436 | (let ((line-no (flymake-get-next-err-line-no flymake-err-info (line-number-at-pos)))) |
| 1588 | (when (not line-no) | 1437 | (when (not line-no) |
| 1589 | (setq line-no (flymake-get-first-err-line-no flymake-err-info)) | 1438 | (setq line-no (flymake-get-first-err-line-no flymake-err-info)) |
| 1590 | (flymake-log 1 "passed end of file")) | 1439 | (flymake-log 1 "passed end of file")) |
| @@ -1595,7 +1444,7 @@ if ARG is omitted or nil." | |||
| 1595 | (defun flymake-goto-prev-error () | 1444 | (defun flymake-goto-prev-error () |
| 1596 | "Go to previous error in err ring." | 1445 | "Go to previous error in err ring." |
| 1597 | (interactive) | 1446 | (interactive) |
| 1598 | (let ((line-no (flymake-get-prev-err-line-no flymake-err-info (flymake-current-line-no)))) | 1447 | (let ((line-no (flymake-get-prev-err-line-no flymake-err-info (line-number-at-pos)))) |
| 1599 | (when (not line-no) | 1448 | (when (not line-no) |
| 1600 | (setq line-no (flymake-get-last-err-line-no flymake-err-info)) | 1449 | (setq line-no (flymake-get-last-err-line-no flymake-err-info)) |
| 1601 | (flymake-log 1 "passed beginning of file")) | 1450 | (flymake-log 1 "passed beginning of file")) |
| @@ -1631,14 +1480,14 @@ if ARG is omitted or nil." | |||
| 1631 | ;; trying to remove the leading / of absolute file names. | 1480 | ;; trying to remove the leading / of absolute file names. |
| 1632 | (slash-pos (string-match "/" dir)) | 1481 | (slash-pos (string-match "/" dir)) |
| 1633 | (temp-dir (expand-file-name (substring dir (1+ slash-pos)) | 1482 | (temp-dir (expand-file-name (substring dir (1+ slash-pos)) |
| 1634 | (flymake-get-temp-dir)))) | 1483 | temporary-file-directory))) |
| 1635 | 1484 | ||
| 1636 | (file-truename (expand-file-name (file-name-nondirectory file-name) | 1485 | (file-truename (expand-file-name (file-name-nondirectory file-name) |
| 1637 | temp-dir)))) | 1486 | temp-dir)))) |
| 1638 | 1487 | ||
| 1639 | (defun flymake-delete-temp-directory (dir-name) | 1488 | (defun flymake-delete-temp-directory (dir-name) |
| 1640 | "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error." | 1489 | "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error." |
| 1641 | (let* ((temp-dir (flymake-get-temp-dir)) | 1490 | (let* ((temp-dir temporary-file-directory) |
| 1642 | (suffix (substring dir-name (1+ (length temp-dir))))) | 1491 | (suffix (substring dir-name (1+ (length temp-dir))))) |
| 1643 | 1492 | ||
| 1644 | (while (> (length suffix) 0) | 1493 | (while (> (length suffix) 0) |
| @@ -1648,17 +1497,10 @@ if ARG is omitted or nil." | |||
| 1648 | (file-truename (expand-file-name suffix temp-dir))) | 1497 | (file-truename (expand-file-name suffix temp-dir))) |
| 1649 | (setq suffix (file-name-directory suffix))))) | 1498 | (setq suffix (file-name-directory suffix))))) |
| 1650 | 1499 | ||
| 1651 | (defvar flymake-temp-source-file-name nil) | 1500 | (defvar-local flymake-temp-source-file-name nil) |
| 1652 | (make-variable-buffer-local 'flymake-temp-source-file-name) | 1501 | (defvar-local flymake-master-file-name nil) |
| 1653 | 1502 | (defvar-local flymake-temp-master-file-name nil) | |
| 1654 | (defvar flymake-master-file-name nil) | 1503 | (defvar-local flymake-base-dir nil) |
| 1655 | (make-variable-buffer-local 'flymake-master-file-name) | ||
| 1656 | |||
| 1657 | (defvar flymake-temp-master-file-name nil) | ||
| 1658 | (make-variable-buffer-local 'flymake-temp-master-file-name) | ||
| 1659 | |||
| 1660 | (defvar flymake-base-dir nil) | ||
| 1661 | (make-variable-buffer-local 'flymake-base-dir) | ||
| 1662 | 1504 | ||
| 1663 | (defun flymake-init-create-temp-buffer-copy (create-temp-f) | 1505 | (defun flymake-init-create-temp-buffer-copy (create-temp-f) |
| 1664 | "Make a temporary copy of the current buffer, save its name in buffer data and return the name." | 1506 | "Make a temporary copy of the current buffer, save its name in buffer data and return the name." |
| @@ -1899,5 +1741,4 @@ Use CREATE-TEMP-F for creating temp copy." | |||
| 1899 | 'flymake-create-temp-inplace)))) | 1741 | 'flymake-create-temp-inplace)))) |
| 1900 | 1742 | ||
| 1901 | (provide 'flymake) | 1743 | (provide 'flymake) |
| 1902 | |||
| 1903 | ;;; flymake.el ends here | 1744 | ;;; flymake.el ends here |