aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/flymake.el113
1 files changed, 50 insertions, 63 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index b7a822515ca..3effb6e7d38 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -32,43 +32,36 @@
32 32
33;;; Code: 33;;; Code:
34 34
35;;;; [[ Overlay compatibility 35;;;; [[ Xemacs overlay compatibility
36(if (featurep 'xemacs) (progn
36(autoload 'make-overlay "overlay" "Overlay compatibility kit." t) 37(autoload 'make-overlay "overlay" "Overlay compatibility kit." t)
37(autoload 'overlayp "overlay" "Overlay compatibility kit." t) 38(autoload 'overlayp "overlay" "Overlay compatibility kit." t)
38(autoload 'overlays-in "overlay" "Overlay compatibility kit." t) 39(autoload 'overlays-in "overlay" "Overlay compatibility kit." t)
39(autoload 'delete-overlay "overlay" "Overlay compatibility kit." t) 40(autoload 'delete-overlay "overlay" "Overlay compatibility kit." t)
40(autoload 'overlay-put "overlay" "Overlay compatibility kit." t) 41(autoload 'overlay-put "overlay" "Overlay compatibility kit." t)
41(autoload 'overlay-get "overlay" "Overlay compatibility kit." t) 42(autoload 'overlay-get "overlay" "Overlay compatibility kit." t)
43))
42;;;; ]] 44;;;; ]]
43 45
44;;;; [[ cross-emacs compatibility routines 46;;;; [[ cross-emacs compatibility routines
45(defvar flymake-emacs 47(defsubst flymake-makehash (&optional test)
46 (cond 48 (if (fboundp 'make-hash-table)
47 ((string-match "XEmacs" emacs-version) 'xemacs) 49 (if test (make-hash-table :test test) (make-hash-table))
48 (t 'emacs)) 50 (makehash test)))
49 "Currently used Emacs flavor")
50
51(defun flymake-makehash (&optional test)
52 (cond
53 ((equal flymake-emacs 'xemacs) (if test (make-hash-table :test test) (make-hash-table)))
54 (t (makehash test))))
55
56(defun flymake-time-to-float (&optional tm)
57 "Convert `current-time` to a float number of seconds."
58 (multiple-value-bind (s0 s1 s2) (or tm (current-time))
59 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2))))
60 51
61(defun flymake-float-time () 52(defun flymake-float-time ()
62 (cond 53 (if (featurep 'xemacs)
63 ((equal flymake-emacs 'xemacs) (flymake-time-to-float (current-time))) 54 (let ((tm (current-time)))
64 (t (float-time)))) 55 (multiple-value-bind (s0 s1 s2) (current-time)
65 56 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2))))
66(defun flymake-replace-regexp-in-string (regexp rep str) 57 (float-time)))
67 (cond 58
68 ((equal flymake-emacs 'xemacs) (replace-in-string str regexp rep)) 59(defsubst flymake-replace-regexp-in-string (regexp rep str)
69 (t (replace-regexp-in-string regexp rep str)))) 60 (if (featurep 'xemacs)
70 61 (replace-in-string str regexp rep)
71(defun flymake-split-string-remove-empty-edges (str pattern) 62 (replace-regexp-in-string regexp rep str)))
63
64(defun flymake-split-string (str pattern)
72 "Split, then remove first and/or last in case it's empty." 65 "Split, then remove first and/or last in case it's empty."
73 (let* ((splitted (split-string str pattern))) 66 (let* ((splitted (split-string str pattern)))
74 (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0)))) 67 (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0))))
@@ -77,12 +70,10 @@
77 (setq splitted (reverse (cdr (reverse splitted))))) 70 (setq splitted (reverse (cdr (reverse splitted)))))
78 splitted)) 71 splitted))
79 72
80(defalias 'flymake-split-string 'flymake-split-string-remove-empty-edges) 73(defsubst flymake-get-temp-dir ()
81 74 (if (featurep 'xemacs)
82(defun flymake-get-temp-dir() 75 (temp-directory)
83 (cond 76 temporary-file-directory))
84 ((equal flymake-emacs 'xemacs) (temp-directory))
85 (t temporary-file-directory)))
86 77
87(defun flymake-line-beginning-position () 78(defun flymake-line-beginning-position ()
88 (save-excursion 79 (save-excursion
@@ -95,23 +86,19 @@
95 (point))) 86 (point)))
96 87
97(defun flymake-popup-menu (pos menu-data) 88(defun flymake-popup-menu (pos menu-data)
98 (cond 89 (if (featurep 'xemacs)
99 ((equal flymake-emacs 'xemacs) 90 (let* ((x-pos (nth 0 (nth 0 pos)))
100 (let* ((x-pos (nth 0 (nth 0 pos))) 91 (y-pos (nth 1 (nth 0 pos)))
101 (y-pos (nth 1 (nth 0 pos))) 92 (fake-event-props '(button 1 x 1 y 1)))
102 (fake-event-props '(button 1 x 1 y 1))) 93 (setq fake-event-props (plist-put fake-event-props 'x x-pos))
103 (setq fake-event-props (plist-put fake-event-props 'x x-pos)) 94 (setq fake-event-props (plist-put fake-event-props 'y y-pos))
104 (setq fake-event-props (plist-put fake-event-props 'y y-pos)) 95 (popup-menu (flymake-make-xemacs-menu menu-data) (make-event 'button-press fake-event-props)))
105 (popup-menu (flymake-make-xemacs-menu menu-data) (make-event 'button-press fake-event-props)) 96 (x-popup-menu pos (flymake-make-emacs-menu menu-data))))
106 )
107 )
108 (t (x-popup-menu pos (flymake-make-emacs-menu menu-data)))))
109 97
110(defun flymake-make-emacs-menu (menu-data) 98(defun flymake-make-emacs-menu (menu-data)
111 (let* ((menu-title (nth 0 menu-data)) 99 (let* ((menu-title (nth 0 menu-data))
112 (menu-items (nth 1 menu-data)) 100 (menu-items (nth 1 menu-data))
113 (menu-commands nil)) 101 (menu-commands nil))
114
115 (setq menu-commands (mapcar (lambda (foo) 102 (setq menu-commands (mapcar (lambda (foo)
116 (cons (nth 0 foo) (nth 1 foo))) 103 (cons (nth 0 foo) (nth 1 foo)))
117 menu-items)) 104 menu-items))
@@ -119,6 +106,8 @@
119 106
120(defun flymake-nop ()) 107(defun flymake-nop ())
121 108
109(if (featurep 'xemacs) (progn
110
122(defun flymake-make-xemacs-menu (menu-data) 111(defun flymake-make-xemacs-menu (menu-data)
123 (let* ((menu-title (nth 0 menu-data)) 112 (let* ((menu-title (nth 0 menu-data))
124 (menu-items (nth 1 menu-data)) 113 (menu-items (nth 1 menu-data))
@@ -141,20 +130,18 @@
141 (setcar tmp (/ (car tmp) (face-height 'default))) 130 (setcar tmp (/ (car tmp) (face-height 'default)))
142 edges)) 131 edges))
143 132
133)) ;; xemacs
134
144(defun flymake-current-row () 135(defun flymake-current-row ()
145 "Return current row number in current frame." 136 "Return current row number in current frame."
146 (cond 137 (if (featurep 'xemacs)
147 ((equal flymake-emacs 'xemacs) (count-lines (window-start) (point))) 138 (count-lines (window-start) (point))
148 (t (+ (car (cdr (window-edges))) (count-lines (window-start) (point)))) 139 (+ (car (cdr (window-edges))) (count-lines (window-start) (point)))))
149 )
150 )
151 140
152(defun flymake-selected-frame () 141(defun flymake-selected-frame ()
153 (cond 142 (if (featurep 'xemacs)
154 ((equal flymake-emacs 'xemacs) (selected-window)) 143 (selected-window)
155 (t (selected-frame)) 144 (selected-frame)))
156 )
157 )
158 145
159;;;; ]] 146;;;; ]]
160 147
@@ -435,11 +422,12 @@ Return t if so, nil if not."
435 :group 'flymake 422 :group 'flymake
436 :type 'integer) 423 :type 'integer)
437 424
438(defvar flymake-included-file-name nil " ") ; this is used to pass a parameter to a sort predicate below 425;; This is bound dynamically to pass a parameter to a sort predicate below
426(defvar flymake-included-file-name)
439 427
440(defun flymake-find-possible-master-files (file-name master-file-dirs masks) 428(defun flymake-find-possible-master-files (file-name master-file-dirs masks)
441 "Find (by name and location) all posible master files. 429 "Find (by name and location) all posible master files.
442Mater files are .cpp and .c for and .h. Files are searched for 430Mater files are .cpp and .c for and .h. Files are searched for
443starting from the .h directory and max max-level parent dirs. 431starting from the .h directory and max max-level parent dirs.
444File contents are not checked." 432File contents are not checked."
445 (let* ((dir-idx 0) 433 (let* ((dir-idx 0)
@@ -468,9 +456,8 @@ File contents are not checked."
468 (setq masks-idx (1+ masks-idx)))) 456 (setq masks-idx (1+ masks-idx))))
469 (setq dir-idx (1+ dir-idx))) 457 (setq dir-idx (1+ dir-idx)))
470 (when files 458 (when files
471 (setq flymake-included-file-name (file-name-nondirectory file-name)) 459 (let ((flymake-included-file-name (file-name-nondirectory file-name)))
472 (setq files (sort files 'flymake-master-file-compare)) 460 (setq files (sort files 'flymake-master-file-compare))))
473 (setq flymake-included-file-name nil))
474 (flymake-log 3 "found %d possible master file(s)" (length files)) 461 (flymake-log 3 "found %d possible master file(s)" (length files))
475 files)) 462 files))
476 463
@@ -840,7 +827,7 @@ Value of TYPE is eigher e or w."
840 "Replace line numbers with fixed value. 827 "Replace line numbers with fixed value.
841If line-numbers is less than MIN-LINE, set line numbers to MIN-LINE. 828If line-numbers is less than MIN-LINE, set line numbers to MIN-LINE.
842If line numbers is greater than MAX-LINE, set line numbers to MAX-LINE. 829If line numbers is greater than MAX-LINE, set line numbers to MAX-LINE.
843The reason for this fix is because some compilers might report 830The reason for this fix is because some compilers might report
844line number outside the file being compiled." 831line number outside the file being compiled."
845 (let* ((count (length err-info-list)) 832 (let* ((count (length err-info-list))
846 (err-info nil) 833 (err-info nil)
@@ -1039,7 +1026,7 @@ Convert it to flymake internal format."
1039 (" *\\(\\[javac\\]\\)? *\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)" 1026 (" *\\(\\[javac\\]\\)? *\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)"
1040 2 4 nil 5)) 1027 2 4 nil 5))
1041 ;; compilation-error-regexp-alist) 1028 ;; compilation-error-regexp-alist)
1042 (flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist)) 1029 (flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist))
1043 "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx). Use flymake-reformat-err-line-patterns-from-compile-el to add patterns from compile.el") 1030 "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx). Use flymake-reformat-err-line-patterns-from-compile-el to add patterns from compile.el")
1044 1031
1045 ;(defcustom flymake-err-line-patterns 1032 ;(defcustom flymake-err-line-patterns
@@ -1237,7 +1224,7 @@ Return first 'INCLUDE-DIRS/REL-FILE-NAME' that exists, or just REL-FILE-NAME if
1237 (error 1224 (error
1238 (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name)))) 1225 (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name))))
1239 1226
1240(defcustom flymake-compilation-prevents-syntax-check t 1227(defcustom flymake-compilation-prevents-syntax-check t
1241 "If non-nil, syntax check won't be started in case compilation is running." 1228 "If non-nil, syntax check won't be started in case compilation is running."
1242 :group 'flymake 1229 :group 'flymake
1243 :type 'boolean) 1230 :type 'boolean)
@@ -1799,7 +1786,7 @@ Delete temp file."
1799 (flymake-set-buffer-last-change-time buffer nil))) 1786 (flymake-set-buffer-last-change-time buffer nil)))
1800 1787
1801(defun flymake-get-real-file-name (buffer file-name-from-err-msg) 1788(defun flymake-get-real-file-name (buffer file-name-from-err-msg)
1802 "Translate file name from error message to `real' file name. 1789 "Translate file name from error message to `real' file name.
1803Return full-name. Names are real, not patched." 1790Return full-name. Names are real, not patched."
1804 (let* ((real-name nil) 1791 (let* ((real-name nil)
1805 (source-file-name (buffer-file-name buffer)) 1792 (source-file-name (buffer-file-name buffer))